1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

More implementation.

This commit is contained in:
Mikhail Khodjaiants 2002-08-20 22:24:56 +00:00
parent 5ff3a637a0
commit ff8adf11c3
2 changed files with 63 additions and 92 deletions

View file

@ -413,18 +413,13 @@ public class CDebugTarget extends CDebugElement
public void resume() throws DebugException public void resume() throws DebugException
{ {
if ( !isSuspended() ) if ( !isSuspended() )
{
return; return;
}
try try
{ {
setSuspended( false );
getCDITarget().resume(); getCDITarget().resume();
resumeThreads();
} }
catch( CDIException e ) catch( CDIException e )
{ {
setSuspended( true );
targetRequestFailed( MessageFormat.format( "{0} occurred resuming target.", new String[] { e.toString() } ), e ); targetRequestFailed( MessageFormat.format( "{0} occurred resuming target.", new String[] { e.toString() } ), e );
} }
} }
@ -435,18 +430,13 @@ public class CDebugTarget extends CDebugElement
public void suspend() throws DebugException public void suspend() throws DebugException
{ {
if ( isSuspended() ) if ( isSuspended() )
{
return; return;
}
try try
{ {
setSuspended( true );
getCDITarget().suspend(); getCDITarget().suspend();
suspendThreads();
} }
catch( CDIException e ) catch( CDIException e )
{ {
setSuspended( false );
targetRequestFailed( MessageFormat.format( "{0} occurred suspending target.", new String[] { e.toString()} ), e ); targetRequestFailed( MessageFormat.format( "{0} occurred suspending target.", new String[] { e.toString()} ), e );
} }
} }
@ -507,7 +497,7 @@ public class CDebugTarget extends CDebugElement
/** /**
* Notifies threads that they have been resumed * Notifies threads that they have been resumed
*/ */
protected void resumeThreads() protected void resumeThreads( ICDIResumedEvent event )
{ {
} }
@ -1032,6 +1022,7 @@ public class CDebugTarget extends CDebugElement
setSuspended( false ); setSuspended( false );
setCurrentStateId( IState.RUNNING ); setCurrentStateId( IState.RUNNING );
setCurrentStateInfo( null ); setCurrentStateInfo( null );
resumeThreads( event );
fireResumeEvent( DebugEvent.UNSPECIFIED ); fireResumeEvent( DebugEvent.UNSPECIFIED );
} }

View file

@ -30,6 +30,7 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
@ -157,12 +158,8 @@ public class CThread extends CDebugElement
if ( fStackFrames.isEmpty() ) if ( fStackFrames.isEmpty() )
{ {
fStackFrames = createAllStackFrames(); fStackFrames = createAllStackFrames();
if ( fStackFrames.isEmpty() ) setRefreshChildren( false );
{ return fStackFrames;
fRefreshChildren = false; // ????
//leave fRefreshChildren == true
return fStackFrames;
}
} }
ICDIStackFrame[] frames = getCDIStackFrames(); ICDIStackFrame[] frames = getCDIStackFrames();
// compute new or removed stack frames // compute new or removed stack frames
@ -173,8 +170,7 @@ public class CThread extends CDebugElement
offset = length - fStackFrames.size(); offset = length - fStackFrames.size();
for ( int i = offset - 1; i >= 0; i-- ) for ( int i = offset - 1; i >= 0; i-- )
{ {
CStackFrame newStackFrame = new CStackFrame( this, frames[i] ); fStackFrames.add( 0, new CStackFrame( this, frames[i] ) );
fStackFrames.add( 0, newStackFrame );
} }
length = fStackFrames.size() - offset; length = fStackFrames.size() - offset;
} }
@ -184,6 +180,7 @@ public class CThread extends CDebugElement
int removed = fStackFrames.size() - length; int removed = fStackFrames.size() - length;
for ( int i = 0; i < removed; i++ ) for ( int i = 0; i < removed; i++ )
{ {
((CStackFrame)fStackFrames.get( 0 )).dispose();
fStackFrames.remove( 0 ); fStackFrames.remove( 0 );
} }
} }
@ -199,9 +196,14 @@ public class CThread extends CDebugElement
// method, replace all frames // method, replace all frames
ICDIStackFrame newTop = frames[0]; ICDIStackFrame newTop = frames[0];
ICDIStackFrame oldTop = ((CStackFrame)fStackFrames.get( 0 ) ).getLastCDIStackFrame(); ICDIStackFrame oldTop = ((CStackFrame)fStackFrames.get( 0 ) ).getLastCDIStackFrame();
if (!CStackFrame.equalFrame( newTop, oldTop ) ) if ( !CStackFrame.equalFrame( newTop, oldTop ) )
{ {
fStackFrames = createAllStackFrames(); disposeStackFrames();
fStackFrames = new ArrayList( frames.length );
for ( int i = 0; i < frames.length; ++i )
{
fStackFrames.add( new CStackFrame( this, frames[i] ) );
}
offset = fStackFrames.size(); offset = fStackFrames.size();
} }
} }
@ -212,11 +214,7 @@ public class CThread extends CDebugElement
updateStackFrames( frames, offset, fStackFrames, length ); updateStackFrames( frames, offset, fStackFrames, length );
} }
} }
fRefreshChildren = false; setRefreshChildren( false );
}
else
{
return Collections.EMPTY_LIST;
} }
return fStackFrames; return fStackFrames;
} }
@ -265,6 +263,7 @@ public class CThread extends CDebugElement
{ {
CStackFrame frame = (CStackFrame)oldFrames.get( offset ); CStackFrame frame = (CStackFrame)oldFrames.get( offset );
frame.setCDIStackFrame( newFrames[offset] ); frame.setCDIStackFrame( newFrames[offset] );
frame.fireChangeEvent( DebugEvent.STATE );
offset++; offset++;
} }
} }
@ -296,7 +295,7 @@ public class CThread extends CDebugElement
*/ */
public List computeStackFrames() throws DebugException public List computeStackFrames() throws DebugException
{ {
return computeStackFrames( fRefreshChildren ); return computeStackFrames( refreshChildren() );
} }
/** /**
@ -330,8 +329,7 @@ public class CThread extends CDebugElement
List list= new ArrayList( frames.length ); List list= new ArrayList( frames.length );
for ( int i = 0; i < frames.length; ++i ) for ( int i = 0; i < frames.length; ++i )
{ {
CStackFrame newStackFrame = new CStackFrame( this, frames[i] ); list.add( new CStackFrame( this, frames[i] ) );
list.add( newStackFrame );
} }
return list; return list;
} }
@ -388,7 +386,8 @@ public class CThread extends CDebugElement
} }
else if ( event instanceof ICDIResumedEvent ) else if ( event instanceof ICDIResumedEvent )
{ {
if ( source instanceof ICDIThread ) if ( ( source instanceof ICDIThread && source.equals( getCDIThread() ) ) ||
source instanceof ICDITarget )
{ {
handleResumedEvent( (ICDIResumedEvent)event ); handleResumedEvent( (ICDIResumedEvent)event );
} }
@ -454,20 +453,13 @@ public class CThread extends CDebugElement
public void resume() throws DebugException public void resume() throws DebugException
{ {
if ( !isSuspended() ) if ( !isSuspended() )
{
return; return;
}
try try
{ {
setRunning( true );
disposeStackFrames();
fireResumeEvent( DebugEvent.CLIENT_REQUEST );
getCDIThread().resume(); getCDIThread().resume();
} }
catch( CDIException e ) catch( CDIException e )
{ {
setRunning( false );
fireSuspendEvent( DebugEvent.CLIENT_REQUEST );
targetRequestFailed( MessageFormat.format( "{0} occurred resuming thread.", new String[] { e.toString()} ), e ); targetRequestFailed( MessageFormat.format( "{0} occurred resuming thread.", new String[] { e.toString()} ), e );
} }
} }
@ -483,14 +475,10 @@ public class CThread extends CDebugElement
} }
try try
{ {
setRunning( false );
getCDIThread().suspend(); getCDIThread().suspend();
fireSuspendEvent( DebugEvent.CLIENT_REQUEST );
} }
catch( CDIException e ) catch( CDIException e )
{ {
setRunning( true );
fireResumeEvent( DebugEvent.CLIENT_REQUEST );
targetRequestFailed( MessageFormat.format( "{0} occurred suspending thread.", new String[] { e.toString()} ), e ); targetRequestFailed( MessageFormat.format( "{0} occurred suspending thread.", new String[] { e.toString()} ), e );
} }
} }
@ -552,20 +540,13 @@ public class CThread extends CDebugElement
public void stepInto() throws DebugException public void stepInto() throws DebugException
{ {
if ( !canStepInto() ) if ( !canStepInto() )
{
return; return;
}
try try
{ {
setRunning( true );
preserveStackFrames();
fireResumeEvent( DebugEvent.STEP_INTO );
getCDIThread().stepInto(); getCDIThread().stepInto();
} }
catch( CDIException e ) catch( CDIException e )
{ {
setRunning( false );
fireSuspendEvent( DebugEvent.STEP_INTO );
targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e ); targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e );
} }
} }
@ -576,20 +557,13 @@ public class CThread extends CDebugElement
public void stepOver() throws DebugException public void stepOver() throws DebugException
{ {
if ( !canStepOver() ) if ( !canStepOver() )
{
return; return;
}
try try
{ {
setRunning( true ); getCDIThread().stepOver();
preserveStackFrames();
fireResumeEvent( DebugEvent.STEP_OVER );
getCDIThread().stepInto();
} }
catch( CDIException e ) catch( CDIException e )
{ {
setRunning( false );
fireSuspendEvent( DebugEvent.STEP_OVER );
targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e ); targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e );
} }
} }
@ -600,20 +574,13 @@ public class CThread extends CDebugElement
public void stepReturn() throws DebugException public void stepReturn() throws DebugException
{ {
if ( !canStepReturn() ) if ( !canStepReturn() )
{
return; return;
}
try try
{ {
setRunning( true ); getCDIThread().stepReturn();
preserveStackFrames();
fireResumeEvent( DebugEvent.STEP_RETURN );
getCDIThread().stepInto();
} }
catch( CDIException e ) catch( CDIException e )
{ {
setRunning( false );
fireSuspendEvent( DebugEvent.STEP_RETURN );
targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e ); targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e );
} }
} }
@ -685,12 +652,7 @@ public class CThread extends CDebugElement
*/ */
protected void preserveStackFrames() protected void preserveStackFrames()
{ {
fRefreshChildren = true; setRefreshChildren( true );
Iterator frames = fStackFrames.iterator();
while( frames.hasNext() )
{
((CStackFrame)frames.next()).setCDIStackFrame( null );
}
} }
/** /**
@ -707,8 +669,8 @@ public class CThread extends CDebugElement
{ {
((CStackFrame)it.next()).dispose(); ((CStackFrame)it.next()).dispose();
} }
fStackFrames = Collections.EMPTY_LIST; fStackFrames.clear();
fRefreshChildren = true; setRefreshChildren( true );
} }
/** /**
@ -780,20 +742,13 @@ public class CThread extends CDebugElement
public void stepIntoInstruction() throws DebugException public void stepIntoInstruction() throws DebugException
{ {
if ( !canStepIntoInstruction() ) if ( !canStepIntoInstruction() )
{
return; return;
}
try try
{ {
setRunning( true );
preserveStackFrames();
fireResumeEvent( DebugEvent.STEP_INTO );
getCDIThread().stepIntoInstruction(); getCDIThread().stepIntoInstruction();
} }
catch( CDIException e ) catch( CDIException e )
{ {
setRunning( false );
fireSuspendEvent( DebugEvent.STEP_INTO );
targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e ); targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e );
} }
} }
@ -804,20 +759,13 @@ public class CThread extends CDebugElement
public void stepOverInstruction() throws DebugException public void stepOverInstruction() throws DebugException
{ {
if ( !canStepOverInstruction() ) if ( !canStepOverInstruction() )
{
return; return;
}
try try
{ {
setRunning( true );
preserveStackFrames();
fireResumeEvent( DebugEvent.STEP_OVER );
getCDIThread().stepOverInstruction(); getCDIThread().stepOverInstruction();
} }
catch( CDIException e ) catch( CDIException e )
{ {
setRunning( false );
fireSuspendEvent( DebugEvent.STEP_OVER );
targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e ); targetRequestFailed( MessageFormat.format( "{0} occurred stepping in thread.", new String[] { e.toString()} ), e );
} }
} }
@ -840,6 +788,10 @@ public class CThread extends CDebugElement
{ {
handleSuspendedBySignal( (ICDISignal)reason ); handleSuspendedBySignal( (ICDISignal)reason );
} }
else
{
fireSuspendEvent( DebugEvent.CLIENT_REQUEST );
}
} }
private void handleResumedEvent( ICDIResumedEvent event ) private void handleResumedEvent( ICDIResumedEvent event )
@ -847,12 +799,34 @@ public class CThread extends CDebugElement
setRunning( true ); setRunning( true );
setCurrentStateId( IState.RUNNING ); setCurrentStateId( IState.RUNNING );
setCurrentStateInfo( null ); setCurrentStateInfo( null );
fireResumeEvent( DebugEvent.UNSPECIFIED ); int detail = DebugEvent.UNSPECIFIED;
switch( event.getType() )
{
case ICDIResumedEvent.CONTINUE:
detail = DebugEvent.CLIENT_REQUEST;
disposeStackFrames();
break;
case ICDIResumedEvent.STEP_INTO:
case ICDIResumedEvent.STEP_INTO_INSTRUCTION:
detail = DebugEvent.STEP_INTO;
preserveStackFrames();
break;
case ICDIResumedEvent.STEP_OVER:
case ICDIResumedEvent.STEP_OVER_INSTRUCTION:
detail = DebugEvent.STEP_OVER;
preserveStackFrames();
break;
case ICDIResumedEvent.STEP_RETURN:
detail = DebugEvent.STEP_RETURN;
preserveStackFrames();
break;
}
fireResumeEvent( detail );
} }
private void handleEndSteppingRange( ICDIEndSteppingRange endSteppingRange ) private void handleEndSteppingRange( ICDIEndSteppingRange endSteppingRange )
{ {
fireSuspendEvent( DebugEvent.UNSPECIFIED ); fireSuspendEvent( DebugEvent.STEP_END );
} }
private void handleBreakpointHit( ICDIBreakpoint breakpoint ) private void handleBreakpointHit( ICDIBreakpoint breakpoint )
@ -911,9 +885,15 @@ public class CThread extends CDebugElement
*/ */
protected synchronized void stepToFrame( IStackFrame frame ) throws DebugException protected synchronized void stepToFrame( IStackFrame frame ) throws DebugException
{ {
if ( !canStepReturn() )
{
return;
}
} }
private void setRefreshChildren( boolean refresh )
{
fRefreshChildren = refresh;
}
private boolean refreshChildren()
{
return fRefreshChildren;
}
} }