mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Partial solution for multithreaded resume and suspend.
This commit is contained in:
parent
9461885204
commit
dd5492be14
2 changed files with 129 additions and 50 deletions
|
@ -445,8 +445,13 @@ public class CDebugTarget extends CDebugElement
|
|||
* Notifies threads that they have been suspended.
|
||||
*
|
||||
*/
|
||||
protected void suspendThreads()
|
||||
protected void suspendThreads( ICDISuspendedEvent event )
|
||||
{
|
||||
Iterator it = getThreadList().iterator();
|
||||
while( it.hasNext() )
|
||||
{
|
||||
((CThread)it.next()).handleDebugEvent( event );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -491,6 +496,7 @@ public class CDebugTarget extends CDebugElement
|
|||
{
|
||||
CDebugCorePlugin.log( e );
|
||||
}
|
||||
setCurrentThread();
|
||||
return newThreads;
|
||||
}
|
||||
|
||||
|
@ -698,7 +704,7 @@ public class CDebugTarget extends CDebugElement
|
|||
handleSuspendedEvent( (ICDISuspendedEvent)event );
|
||||
}
|
||||
}
|
||||
else if ( event instanceof ICDIResumedEvent || source instanceof ICDIThread )
|
||||
else if ( event instanceof ICDIResumedEvent )
|
||||
{
|
||||
if ( source instanceof ICDITarget )
|
||||
{
|
||||
|
@ -995,7 +1001,13 @@ public class CDebugTarget extends CDebugElement
|
|||
ICDISessionObject reason = event.getReason();
|
||||
setCurrentStateInfo( reason );
|
||||
List newThreads = refreshThreads();
|
||||
if ( event.getSource() instanceof ICDIThread )
|
||||
if ( event.getSource() instanceof ICDITarget )
|
||||
{
|
||||
suspendThreads( event );
|
||||
}
|
||||
// We need this for debuggers that don't have notifications
|
||||
// for newly created threads.
|
||||
else if ( event.getSource() instanceof ICDIThread )
|
||||
{
|
||||
CThread thread = findThread( (ICDIThread)event.getSource() );
|
||||
if ( thread != null && newThreads.contains( thread ) )
|
||||
|
@ -1023,7 +1035,25 @@ public class CDebugTarget extends CDebugElement
|
|||
setCurrentStateId( IState.RUNNING );
|
||||
setCurrentStateInfo( null );
|
||||
resumeThreads( event );
|
||||
fireResumeEvent( DebugEvent.UNSPECIFIED );
|
||||
int detail = DebugEvent.UNSPECIFIED;
|
||||
switch( event.getType() )
|
||||
{
|
||||
case ICDIResumedEvent.CONTINUE:
|
||||
detail = DebugEvent.CLIENT_REQUEST;
|
||||
break;
|
||||
case ICDIResumedEvent.STEP_INTO:
|
||||
case ICDIResumedEvent.STEP_INTO_INSTRUCTION:
|
||||
detail = DebugEvent.STEP_INTO;
|
||||
break;
|
||||
case ICDIResumedEvent.STEP_OVER:
|
||||
case ICDIResumedEvent.STEP_OVER_INSTRUCTION:
|
||||
detail = DebugEvent.STEP_OVER;
|
||||
break;
|
||||
case ICDIResumedEvent.STEP_RETURN:
|
||||
detail = DebugEvent.STEP_RETURN;
|
||||
break;
|
||||
}
|
||||
fireResumeEvent( detail );
|
||||
}
|
||||
|
||||
private void handleEndSteppingRange( ICDIEndSteppingRange endSteppingRange )
|
||||
|
@ -1240,4 +1270,27 @@ public class CDebugTarget extends CDebugElement
|
|||
{
|
||||
return fSourceLocator;
|
||||
}
|
||||
|
||||
protected void setCurrentThread()
|
||||
{
|
||||
ICDIThread currentCDIThread = null;
|
||||
try
|
||||
{
|
||||
currentCDIThread = getCDITarget().getCurrentThread();
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
CDebugCorePlugin.log( e );
|
||||
}
|
||||
Iterator it = getThreadList().iterator();
|
||||
while( it.hasNext() )
|
||||
{
|
||||
CThread thread = (CThread)it.next();
|
||||
thread.setCurrent( currentCDIThread != null && thread.getCDIThread().equals( currentCDIThread ) );
|
||||
}
|
||||
if ( currentCDIThread == null && !getThreadList().isEmpty() )
|
||||
{
|
||||
((CThread)getThreadList().get( 0 )).setCurrent( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.IInstructionStep;
|
||||
import org.eclipse.cdt.debug.core.IRestart;
|
||||
import org.eclipse.cdt.debug.core.IState;
|
||||
|
@ -89,6 +90,11 @@ public class CThread extends CDebugElement
|
|||
*/
|
||||
private ICDIConfiguration fConfig;
|
||||
|
||||
/**
|
||||
* Whether this thread is current.
|
||||
*/
|
||||
private boolean fIsCurrent = false;
|
||||
|
||||
/**
|
||||
* Constructor for CThread.
|
||||
* @param target
|
||||
|
@ -381,7 +387,8 @@ public class CThread extends CDebugElement
|
|||
{
|
||||
if ( event instanceof ICDISuspendedEvent )
|
||||
{
|
||||
if ( source instanceof ICDIThread )
|
||||
if ( ( source instanceof ICDIThread && getCDIThread().equals( (ICDIThread)source ) ) ||
|
||||
source instanceof ICDITarget )
|
||||
{
|
||||
handleSuspendedEvent( (ICDISuspendedEvent)event );
|
||||
}
|
||||
|
@ -415,13 +422,6 @@ public class CThread extends CDebugElement
|
|||
handleChangedEvent( (ICDIChangedEvent)event );
|
||||
}
|
||||
}
|
||||
//else if ( event instanceof ICDISteppingEvent )
|
||||
//{
|
||||
// if ( source instanceof ICDIThread )
|
||||
// {
|
||||
// handleSteppingEvent( (ICDISteppingEvent)event );
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -780,25 +780,34 @@ public class CThread extends CDebugElement
|
|||
private void handleSuspendedEvent( ICDISuspendedEvent event )
|
||||
{
|
||||
setRunning( false );
|
||||
if ( event.getSource() instanceof ICDITarget )
|
||||
{
|
||||
if ( isCurrent() )
|
||||
{
|
||||
setCurrentStateId( IState.SUSPENDED );
|
||||
ICDISessionObject reason = event.getReason();
|
||||
setCurrentStateInfo( reason );
|
||||
if ( reason instanceof ICDIEndSteppingRange )
|
||||
{
|
||||
handleEndSteppingRange( (ICDIEndSteppingRange)reason );
|
||||
}
|
||||
else if ( reason instanceof ICDIBreakpoint )
|
||||
{
|
||||
handleBreakpointHit( (ICDIBreakpoint)reason );
|
||||
}
|
||||
else if ( reason instanceof ICDISignal )
|
||||
{
|
||||
handleSuspendedBySignal( (ICDISignal)reason );
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSuspendEvent( DebugEvent.CLIENT_REQUEST );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
setCurrentStateId( IState.SUSPENDED );
|
||||
ICDISessionObject reason = event.getReason();
|
||||
setCurrentStateInfo( reason );
|
||||
if ( reason instanceof ICDIEndSteppingRange )
|
||||
{
|
||||
handleEndSteppingRange( (ICDIEndSteppingRange)reason );
|
||||
}
|
||||
else if ( reason instanceof ICDIBreakpoint )
|
||||
{
|
||||
handleBreakpointHit( (ICDIBreakpoint)reason );
|
||||
}
|
||||
else if ( reason instanceof ICDISignal )
|
||||
{
|
||||
handleSuspendedBySignal( (ICDISignal)reason );
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSuspendEvent( DebugEvent.CLIENT_REQUEST );
|
||||
}
|
||||
setCurrentStateInfo( null );
|
||||
}
|
||||
|
||||
private void handleResumedEvent( ICDIResumedEvent event )
|
||||
|
@ -807,28 +816,35 @@ public class CThread extends CDebugElement
|
|||
setCurrentStateId( IState.RUNNING );
|
||||
setCurrentStateInfo( null );
|
||||
int detail = DebugEvent.UNSPECIFIED;
|
||||
switch( event.getType() )
|
||||
if ( isCurrent() )
|
||||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
disposeStackFrames();
|
||||
fireResumeEvent( DebugEvent.CLIENT_REQUEST );
|
||||
}
|
||||
fireResumeEvent( detail );
|
||||
}
|
||||
|
||||
private void handleEndSteppingRange( ICDIEndSteppingRange endSteppingRange )
|
||||
|
@ -921,4 +937,14 @@ public class CThread extends CDebugElement
|
|||
((IRestart)getDebugTarget()).restart();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isCurrent()
|
||||
{
|
||||
return fIsCurrent;
|
||||
}
|
||||
|
||||
protected void setCurrent( boolean current )
|
||||
{
|
||||
fIsCurrent = current;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue