mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merging changes from 1.2.1 branch.
This commit is contained in:
parent
9a439466fc
commit
fd9750f26f
4 changed files with 292 additions and 83 deletions
|
@ -1,7 +1,20 @@
|
||||||
|
2004-02-10 Mikhail Khodjaiants
|
||||||
|
Cache the endianness flag.
|
||||||
|
* CDebugTarget.java
|
||||||
|
|
||||||
2004-01-30 Mikhail Khodjaiants
|
2004-01-30 Mikhail Khodjaiants
|
||||||
Fix for bug 50981: In the 'getValue' method of CVariable 'getType' should be only called once.
|
Fix for bug 50981: In the 'getValue' method of CVariable 'getType' should be only called once.
|
||||||
* CVariable.java
|
* CVariable.java
|
||||||
|
|
||||||
|
2004-01-29 Mikhail Khodjaiants
|
||||||
|
Fire sets of debug events instead of firing it one by one.
|
||||||
|
* CDebugTarget.java
|
||||||
|
* CThread.java
|
||||||
|
|
||||||
|
2004-01-29 Mikhail Khodjaiants
|
||||||
|
Added DebugEvent factory methods to 'CDebugElement'.
|
||||||
|
* CDebugElement.java
|
||||||
|
|
||||||
2004-01-15 Mikhail Khodjaiants
|
2004-01-15 Mikhail Khodjaiants
|
||||||
Fix for bug 48682: IThread.getBreakpoints() stubbed out.
|
Fix for bug 48682: IThread.getBreakpoints() stubbed out.
|
||||||
* CDebugTarget.java
|
* CDebugTarget.java
|
||||||
|
|
|
@ -125,6 +125,11 @@ public class CDebugElement extends PlatformObject
|
||||||
DebugPlugin.getDefault().fireDebugEventSet( new DebugEvent[] { event } );
|
DebugPlugin.getDefault().fireDebugEventSet( new DebugEvent[] { event } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void fireEventSet( DebugEvent[] events )
|
||||||
|
{
|
||||||
|
DebugPlugin.getDefault().fireDebugEventSet( events );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a debug event marking the creation of this element.
|
* Fires a debug event marking the creation of this element.
|
||||||
*/
|
*/
|
||||||
|
@ -133,6 +138,11 @@ public class CDebugElement extends PlatformObject
|
||||||
fireEvent( new DebugEvent( this, DebugEvent.CREATE ) );
|
fireEvent( new DebugEvent( this, DebugEvent.CREATE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DebugEvent createCreateEvent()
|
||||||
|
{
|
||||||
|
return new DebugEvent( this, DebugEvent.CREATE );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a debug event marking the RESUME of this element with
|
* Fires a debug event marking the RESUME of this element with
|
||||||
* the associated detail.
|
* the associated detail.
|
||||||
|
@ -145,6 +155,11 @@ public class CDebugElement extends PlatformObject
|
||||||
fireEvent( new DebugEvent( this, DebugEvent.RESUME, detail ) );
|
fireEvent( new DebugEvent( this, DebugEvent.RESUME, detail ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DebugEvent createResumeEvent( int detail )
|
||||||
|
{
|
||||||
|
return new DebugEvent( this, DebugEvent.RESUME, detail );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a debug event marking the SUSPEND of this element with
|
* Fires a debug event marking the SUSPEND of this element with
|
||||||
* the associated detail.
|
* the associated detail.
|
||||||
|
@ -157,6 +172,11 @@ public class CDebugElement extends PlatformObject
|
||||||
fireEvent( new DebugEvent( this, DebugEvent.SUSPEND, detail ) );
|
fireEvent( new DebugEvent( this, DebugEvent.SUSPEND, detail ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DebugEvent createSuspendEvent( int detail )
|
||||||
|
{
|
||||||
|
return new DebugEvent( this, DebugEvent.SUSPEND, detail );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a debug event marking the termination of this element.
|
* Fires a debug event marking the termination of this element.
|
||||||
*/
|
*/
|
||||||
|
@ -165,6 +185,11 @@ public class CDebugElement extends PlatformObject
|
||||||
fireEvent( new DebugEvent( this, DebugEvent.TERMINATE ) );
|
fireEvent( new DebugEvent( this, DebugEvent.TERMINATE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DebugEvent createTerminateEvent()
|
||||||
|
{
|
||||||
|
return new DebugEvent( this, DebugEvent.TERMINATE );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a debug event marking the CHANGE of this element
|
* Fires a debug event marking the CHANGE of this element
|
||||||
* with the specifed detail code.
|
* with the specifed detail code.
|
||||||
|
@ -176,6 +201,11 @@ public class CDebugElement extends PlatformObject
|
||||||
fireEvent( new DebugEvent( this, DebugEvent.CHANGE, detail ) );
|
fireEvent( new DebugEvent( this, DebugEvent.CHANGE, detail ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DebugEvent createChangeEvent( int detail )
|
||||||
|
{
|
||||||
|
return new DebugEvent( this, DebugEvent.CHANGE, detail );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the CDI session associated with this element.
|
* Returns the CDI session associated with this element.
|
||||||
*
|
*
|
||||||
|
|
|
@ -137,6 +137,8 @@ public class CDebugTarget extends CDebugElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean fSuspending;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of this target.
|
* The type of this target.
|
||||||
*/
|
*/
|
||||||
|
@ -259,6 +261,11 @@ public class CDebugTarget extends CDebugElement
|
||||||
*/
|
*/
|
||||||
private IFile fExecFile;
|
private IFile fExecFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the target is little endian.
|
||||||
|
*/
|
||||||
|
private Boolean fIsLittleEndian = null;
|
||||||
|
|
||||||
private RunningInfo fRunningInfo = null;
|
private RunningInfo fRunningInfo = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,6 +341,16 @@ public class CDebugTarget extends CDebugElement
|
||||||
}
|
}
|
||||||
for ( int i = 0; i < threads.length; ++i )
|
for ( int i = 0; i < threads.length; ++i )
|
||||||
createThread( threads[i] );
|
createThread( threads[i] );
|
||||||
|
|
||||||
|
// Fire thread creation events.
|
||||||
|
List list = getThreadList();
|
||||||
|
ArrayList debugEvents = new ArrayList( list.size() );
|
||||||
|
Iterator it = list.iterator();
|
||||||
|
while( it.hasNext() )
|
||||||
|
{
|
||||||
|
debugEvents.add( ((CThread)it.next()).createCreateEvent() );
|
||||||
|
}
|
||||||
|
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -513,17 +530,35 @@ public class CDebugTarget extends CDebugElement
|
||||||
* @see org.eclipse.debug.core.model.ITerminate#terminate()
|
* @see org.eclipse.debug.core.model.ITerminate#terminate()
|
||||||
*/
|
*/
|
||||||
public void terminate() throws DebugException
|
public void terminate() throws DebugException
|
||||||
|
{
|
||||||
|
if ( isTerminating() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setTerminating( true );
|
||||||
|
DebugPlugin.getDefault().asyncExec(
|
||||||
|
new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
setTerminating( true );
|
|
||||||
getCDITarget().terminate();
|
getCDITarget().terminate();
|
||||||
}
|
}
|
||||||
catch( CDIException e )
|
catch( CDIException e )
|
||||||
{
|
{
|
||||||
setTerminating( false );
|
setTerminating( false );
|
||||||
|
try
|
||||||
|
{
|
||||||
targetRequestFailed( e.getMessage(), e );
|
targetRequestFailed( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
catch( DebugException e1 )
|
||||||
|
{
|
||||||
|
CDebugUtils.error( e1.getStatus(), CDebugTarget.this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -581,7 +616,7 @@ public class CDebugTarget extends CDebugElement
|
||||||
*/
|
*/
|
||||||
public void resume() throws DebugException
|
public void resume() throws DebugException
|
||||||
{
|
{
|
||||||
if ( !isSuspended() )
|
if ( !isSuspended() && !isSuspending() )
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -598,16 +633,39 @@ public class CDebugTarget extends CDebugElement
|
||||||
*/
|
*/
|
||||||
public void suspend() throws DebugException
|
public void suspend() throws DebugException
|
||||||
{
|
{
|
||||||
if ( isSuspended() )
|
if ( isSuspended() || isSuspending() )
|
||||||
return;
|
return;
|
||||||
try
|
|
||||||
{
|
setSuspending(true);
|
||||||
|
DebugPlugin.getDefault().asyncExec(new Runnable() {
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Runnable#run()
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
getCDITarget().suspend();
|
getCDITarget().suspend();
|
||||||
}
|
} catch( CDIException e ) {
|
||||||
catch( CDIException e )
|
try {
|
||||||
{
|
|
||||||
targetRequestFailed( e.getMessage(), e );
|
targetRequestFailed( e.getMessage(), e );
|
||||||
|
} catch (DebugException e1) {
|
||||||
|
CDebugUtils.error(e1.getStatus(), CDebugTarget.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
setSuspending(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSuspending( boolean value )
|
||||||
|
{
|
||||||
|
fSuspending = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isSuspending()
|
||||||
|
{
|
||||||
|
return fSuspending;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -629,14 +687,23 @@ public class CDebugTarget extends CDebugElement
|
||||||
*/
|
*/
|
||||||
protected synchronized List refreshThreads()
|
protected synchronized List refreshThreads()
|
||||||
{
|
{
|
||||||
ArrayList list = new ArrayList( 5 );
|
|
||||||
ArrayList newThreads = new ArrayList( 5 );
|
ArrayList newThreads = new ArrayList( 5 );
|
||||||
|
ArrayList list = new ArrayList( 5 );
|
||||||
|
ArrayList debugEvents = new ArrayList( 5 );
|
||||||
|
List oldList = (List)getThreadList().clone();
|
||||||
|
|
||||||
|
ICDIThread[] cdiThreads = new ICDIThread[0];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ICDIThread[] cdiThreads = getCDITarget().getThreads();
|
cdiThreads = getCDITarget().getThreads();
|
||||||
|
}
|
||||||
|
catch( CDIException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( e );
|
||||||
|
}
|
||||||
for ( int i = 0; i < cdiThreads.length; ++i )
|
for ( int i = 0; i < cdiThreads.length; ++i )
|
||||||
{
|
{
|
||||||
CThread thread = findThread( cdiThreads[i] );
|
CThread thread = findThread( oldList, cdiThreads[i] );
|
||||||
if ( thread == null )
|
if ( thread == null )
|
||||||
{
|
{
|
||||||
thread = new CThread( this, cdiThreads[i] );
|
thread = new CThread( this, cdiThreads[i] );
|
||||||
|
@ -644,27 +711,26 @@ public class CDebugTarget extends CDebugElement
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getThreadList().remove( thread );
|
oldList.remove( thread );
|
||||||
}
|
}
|
||||||
list.add( thread );
|
list.add( thread );
|
||||||
}
|
}
|
||||||
Iterator it = getThreadList().iterator();
|
|
||||||
|
Iterator it = oldList.iterator();
|
||||||
while( it.hasNext() )
|
while( it.hasNext() )
|
||||||
{
|
{
|
||||||
((CThread)it.next()).terminated();
|
CThread thread = (CThread)it.next();
|
||||||
|
thread.terminated();
|
||||||
|
debugEvents.add( thread.createTerminateEvent() );
|
||||||
}
|
}
|
||||||
getThreadList().clear();
|
|
||||||
setThreadList( list );
|
setThreadList( list );
|
||||||
it = newThreads.iterator();
|
it = newThreads.iterator();
|
||||||
while( it.hasNext() )
|
while( it.hasNext() )
|
||||||
{
|
{
|
||||||
((CThread)it.next()).fireCreationEvent();
|
debugEvents.add( ((CThread)it.next()).createCreateEvent() );
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( CDIException e )
|
|
||||||
{
|
|
||||||
CDebugCorePlugin.log( e );
|
|
||||||
}
|
}
|
||||||
|
if ( debugEvents.size() > 0 )
|
||||||
|
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
|
||||||
setCurrentThread();
|
setCurrentThread();
|
||||||
return newThreads;
|
return newThreads;
|
||||||
}
|
}
|
||||||
|
@ -672,8 +738,13 @@ public class CDebugTarget extends CDebugElement
|
||||||
/**
|
/**
|
||||||
* Notifies threads that they have been resumed
|
* Notifies threads that they have been resumed
|
||||||
*/
|
*/
|
||||||
protected void resumeThreads( ICDIResumedEvent event )
|
protected synchronized void resumeThreads( List debugEvents, int detail )
|
||||||
{
|
{
|
||||||
|
Iterator it = getThreadList().iterator();
|
||||||
|
while( it.hasNext() )
|
||||||
|
{
|
||||||
|
((CThread)it.next()).resumed( detail, debugEvents );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -1167,13 +1238,17 @@ public class CDebugTarget extends CDebugElement
|
||||||
*/
|
*/
|
||||||
protected void removeAllThreads()
|
protected void removeAllThreads()
|
||||||
{
|
{
|
||||||
Iterator itr = getThreadList().iterator();
|
List threads = getThreadList();
|
||||||
setThreadList( new ArrayList( 0 ) );
|
setThreadList( new ArrayList( 0 ) );
|
||||||
while( itr.hasNext() )
|
ArrayList debugEvents = new ArrayList( threads.size() );
|
||||||
|
Iterator it = threads.iterator();
|
||||||
|
while( it.hasNext() )
|
||||||
{
|
{
|
||||||
CThread thread = (CThread)itr.next();
|
CThread thread = (CThread)it.next();
|
||||||
thread.terminated();
|
thread.terminated();
|
||||||
|
debugEvents.add( thread.createTerminateEvent() );
|
||||||
}
|
}
|
||||||
|
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1206,7 +1281,6 @@ public class CDebugTarget extends CDebugElement
|
||||||
{
|
{
|
||||||
CThread thread = new CThread( this, cdiThread );
|
CThread thread = new CThread( this, cdiThread );
|
||||||
getThreadList().add( thread );
|
getThreadList().add( thread );
|
||||||
thread.fireCreationEvent();
|
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1221,7 +1295,6 @@ public class CDebugTarget extends CDebugElement
|
||||||
CThread thread = new CThread( this, cdiThread );
|
CThread thread = new CThread( this, cdiThread );
|
||||||
thread.setRunning( true );
|
thread.setRunning( true );
|
||||||
getThreadList().add( thread );
|
getThreadList().add( thread );
|
||||||
thread.fireCreationEvent();
|
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1237,7 +1310,6 @@ public class CDebugTarget extends CDebugElement
|
||||||
if ( event.getSource() instanceof ICDITarget )
|
if ( event.getSource() instanceof ICDITarget )
|
||||||
{
|
{
|
||||||
suspendThreads( event );
|
suspendThreads( event );
|
||||||
fireSuspendEvent( DebugEvent.UNSPECIFIED );
|
|
||||||
}
|
}
|
||||||
// We need this for debuggers that don't have notifications
|
// We need this for debuggers that don't have notifications
|
||||||
// for newly created threads.
|
// for newly created threads.
|
||||||
|
@ -1387,7 +1459,7 @@ public class CDebugTarget extends CDebugElement
|
||||||
setCurrentStateId( IState.RUNNING );
|
setCurrentStateId( IState.RUNNING );
|
||||||
setCurrentStateInfo( null );
|
setCurrentStateInfo( null );
|
||||||
resetStatus();
|
resetStatus();
|
||||||
resumeThreads( event );
|
ArrayList debugEvents = new ArrayList( 10 );
|
||||||
int detail = DebugEvent.UNSPECIFIED;
|
int detail = DebugEvent.UNSPECIFIED;
|
||||||
switch( event.getType() )
|
switch( event.getType() )
|
||||||
{
|
{
|
||||||
|
@ -1406,9 +1478,11 @@ public class CDebugTarget extends CDebugElement
|
||||||
detail = DebugEvent.STEP_RETURN;
|
detail = DebugEvent.STEP_RETURN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
resumeThreads( debugEvents, detail );
|
||||||
if ( getRunningInfo() == null )
|
if ( getRunningInfo() == null )
|
||||||
setRunningInfo( event.getType() );
|
setRunningInfo( event.getType() );
|
||||||
fireResumeEvent( detail );
|
debugEvents.add( createResumeEvent( detail ) );
|
||||||
|
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleEndSteppingRange( ICDIEndSteppingRange endSteppingRange )
|
private void handleEndSteppingRange( ICDIEndSteppingRange endSteppingRange )
|
||||||
|
@ -1516,7 +1590,8 @@ public class CDebugTarget extends CDebugElement
|
||||||
CThread thread = findThread( cdiThread );
|
CThread thread = findThread( cdiThread );
|
||||||
if ( thread == null )
|
if ( thread == null )
|
||||||
{
|
{
|
||||||
createThread( cdiThread );
|
thread = createThread( cdiThread );
|
||||||
|
thread.fireCreationEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1528,6 +1603,7 @@ public class CDebugTarget extends CDebugElement
|
||||||
{
|
{
|
||||||
getThreadList().remove( thread );
|
getThreadList().remove( thread );
|
||||||
thread.terminated();
|
thread.terminated();
|
||||||
|
thread.fireTerminateEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1550,6 +1626,17 @@ public class CDebugTarget extends CDebugElement
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CThread findThread( List threads, ICDIThread cdiThread )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < threads.size(); i++ )
|
||||||
|
{
|
||||||
|
CThread t = (CThread)threads.get( i );
|
||||||
|
if ( t.getCDIThread().equals( cdiThread ) )
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.IState#getCurrentStateId()
|
* @see org.eclipse.cdt.debug.core.IState#getCurrentStateId()
|
||||||
*/
|
*/
|
||||||
|
@ -1902,15 +1989,19 @@ public class CDebugTarget extends CDebugElement
|
||||||
*/
|
*/
|
||||||
public boolean isLittleEndian()
|
public boolean isLittleEndian()
|
||||||
{
|
{
|
||||||
|
if ( fIsLittleEndian == null )
|
||||||
|
{
|
||||||
|
fIsLittleEndian = Boolean.TRUE;
|
||||||
if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) )
|
if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) )
|
||||||
{
|
{
|
||||||
ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() );
|
ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() );
|
||||||
if ( cFile instanceof IBinary )
|
if ( cFile instanceof IBinary )
|
||||||
{
|
{
|
||||||
((IBinary)cFile).isLittleEndian();
|
fIsLittleEndian = new Boolean( ((IBinary)cFile).isLittleEndian() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
|
return fIsLittleEndian.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFile getExecFile()
|
public IFile getExecFile()
|
||||||
|
@ -2274,4 +2365,20 @@ public class CDebugTarget extends CDebugElement
|
||||||
}
|
}
|
||||||
return (IBreakpoint[])list.toArray( new IBreakpoint[list.size()]);
|
return (IBreakpoint[])list.toArray( new IBreakpoint[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
String result = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = getName();
|
||||||
|
}
|
||||||
|
catch( DebugException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
|
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
|
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
|
||||||
|
@ -40,6 +41,7 @@ import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.debug.core.DebugEvent;
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.model.IBreakpoint;
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
import org.eclipse.debug.core.model.IStackFrame;
|
import org.eclipse.debug.core.model.IStackFrame;
|
||||||
import org.eclipse.debug.core.model.IThread;
|
import org.eclipse.debug.core.model.IThread;
|
||||||
|
@ -59,6 +61,8 @@ public class CThread extends CDebugElement
|
||||||
ISwitchToFrame,
|
ISwitchToFrame,
|
||||||
ICDIEventListener
|
ICDIEventListener
|
||||||
{
|
{
|
||||||
|
private boolean fSuspending;
|
||||||
|
|
||||||
private final static int MAX_STACK_DEPTH = 100;
|
private final static int MAX_STACK_DEPTH = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -435,8 +439,7 @@ public class CThread extends CDebugElement
|
||||||
}
|
}
|
||||||
else if ( event instanceof ICDIResumedEvent )
|
else if ( event instanceof ICDIResumedEvent )
|
||||||
{
|
{
|
||||||
if ( ( source instanceof ICDIThread && source.equals( getCDIThread() ) ) ||
|
if ( ( source instanceof ICDIThread && source.equals( getCDIThread() ) ) )
|
||||||
source instanceof ICDITarget )
|
|
||||||
{
|
{
|
||||||
handleResumedEvent( (ICDIResumedEvent)event );
|
handleResumedEvent( (ICDIResumedEvent)event );
|
||||||
}
|
}
|
||||||
|
@ -494,7 +497,7 @@ public class CThread extends CDebugElement
|
||||||
*/
|
*/
|
||||||
public void resume() throws DebugException
|
public void resume() throws DebugException
|
||||||
{
|
{
|
||||||
if ( !isSuspended() )
|
if ( !isSuspended() && !isSuspending() )
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -511,18 +514,39 @@ public class CThread extends CDebugElement
|
||||||
*/
|
*/
|
||||||
public void suspend() throws DebugException
|
public void suspend() throws DebugException
|
||||||
{
|
{
|
||||||
if ( isSuspended() )
|
if ( isSuspended() || isSuspending() )
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
try
|
setSuspending(true);
|
||||||
{
|
DebugPlugin.getDefault().asyncExec(new Runnable() {
|
||||||
getCDIThread().suspend();
|
/* (non-Javadoc)
|
||||||
}
|
* @see java.lang.Runnable#run()
|
||||||
catch( CDIException e )
|
*/
|
||||||
{
|
public void run() {
|
||||||
|
try {
|
||||||
|
getCDITarget().suspend();
|
||||||
|
} catch( CDIException e ) {
|
||||||
|
try {
|
||||||
targetRequestFailed( e.getMessage(), e );
|
targetRequestFailed( e.getMessage(), e );
|
||||||
|
} catch (DebugException e1) {
|
||||||
|
CDebugUtils.error(e1.getStatus(), CThread.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
setSuspending(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSuspending( boolean value )
|
||||||
|
{
|
||||||
|
fSuspending = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isSuspending()
|
||||||
|
{
|
||||||
|
return fSuspending;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -735,7 +759,7 @@ public class CThread extends CDebugElement
|
||||||
CStackFrame frame = (CStackFrame)(((IAdaptable)it.next()).getAdapter( CStackFrame.class ));
|
CStackFrame frame = (CStackFrame)(((IAdaptable)it.next()).getAdapter( CStackFrame.class ));
|
||||||
if ( frame != null )
|
if ( frame != null )
|
||||||
{
|
{
|
||||||
frame.dispose();
|
((CStackFrame)frame).dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fStackFrames.clear();
|
fStackFrames.clear();
|
||||||
|
@ -771,7 +795,6 @@ public class CThread extends CDebugElement
|
||||||
setRunning( false );
|
setRunning( false );
|
||||||
dispose();
|
dispose();
|
||||||
cleanup();
|
cleanup();
|
||||||
fireTerminateEvent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -865,7 +888,7 @@ public class CThread extends CDebugElement
|
||||||
setRunning( false );
|
setRunning( false );
|
||||||
if ( event.getSource() instanceof ICDITarget )
|
if ( event.getSource() instanceof ICDITarget )
|
||||||
{
|
{
|
||||||
if ( isCurrent() )
|
if ( isCurrent() && getCurrentStateId() != IState.SUSPENDED )
|
||||||
{
|
{
|
||||||
setCurrentStateId( IState.SUSPENDED );
|
setCurrentStateId( IState.SUSPENDED );
|
||||||
ICDISessionObject reason = event.getReason();
|
ICDISessionObject reason = event.getReason();
|
||||||
|
@ -1152,4 +1175,40 @@ public class CThread extends CDebugElement
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
String result = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = getName();
|
||||||
|
}
|
||||||
|
catch( DebugException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void resumed( int detail, List events )
|
||||||
|
{
|
||||||
|
setRunning( true );
|
||||||
|
setLastStackFrame( null );
|
||||||
|
int state = IState.RUNNING;
|
||||||
|
if ( isCurrent() && detail != DebugEvent.CLIENT_REQUEST && detail != DebugEvent.UNSPECIFIED )
|
||||||
|
{
|
||||||
|
preserveStackFrames();
|
||||||
|
state = IState.STEPPING;
|
||||||
|
events.add( createResumeEvent( detail ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disposeStackFrames();
|
||||||
|
events.add( createChangeEvent( DebugEvent.CONTENT ) );
|
||||||
|
}
|
||||||
|
setCurrentStateId( state );
|
||||||
|
setCurrentStateInfo( null );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue