1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-11 02:05:39 +02:00

Implementation of deferred breakpoints.

This commit is contained in:
Mikhail Khodjaiants 2003-08-29 21:57:08 +00:00
parent dab5b46aed
commit c4517804fd
3 changed files with 208 additions and 4 deletions

View file

@ -1,3 +1,8 @@
2003-08-29 Mikhail Khodjaiants
Implementation of deferred breakpoints.
* CDebugTarget.java
* CThread.java
2003-08-29 Mikhail Khodjaiants
Moving shared library features from mi to CDI.
Added new launch configuration constants to ICDTLaunchConfigurationConstants.

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICBreakpointManager;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICMemoryManager;
import org.eclipse.cdt.debug.core.ICRegisterManager;
import org.eclipse.cdt.debug.core.ICSharedLibraryManager;
@ -36,6 +37,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDIErrorInfo;
import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryEvent;
import org.eclipse.cdt.debug.core.cdi.ICDISignalReceived;
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope;
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger;
@ -54,6 +56,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.cdi.model.ICDISignal;
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.ICDIWatchpoint;
@ -124,6 +127,28 @@ public class CDebugTarget extends CDebugElement
ILaunchListener,
IExpressionListener
{
public class RunningInfo
{
private int fType = 0;
private int fStackDepth;
public RunningInfo( int type, int stackDepth )
{
fType = type;
fStackDepth = stackDepth;
}
public int getType()
{
return fType;
}
public int getStackDepth()
{
return fStackDepth;
}
}
/**
* The type of this target.
*/
@ -257,6 +282,8 @@ public class CDebugTarget extends CDebugElement
*/
private boolean fSetBreakpoints = true;
private RunningInfo fRunningInfo = null;
/**
* Constructor for CDebugTarget.
* @param target
@ -988,7 +1015,14 @@ public class CDebugTarget extends CDebugElement
}
else if ( event instanceof ICDISuspendedEvent )
{
if ( source instanceof ICDITarget || source instanceof ICDIThread )
boolean pass = true;
if ( source instanceof ICDITarget &&
((ICDISuspendedEvent)event).getReason() instanceof ICDISharedLibraryEvent &&
applyDeferredBreakpoints() )
{
pass = handleInternalSuspendedEvent( (ICDISuspendedEvent)event );
}
if ( pass && (source instanceof ICDITarget || source instanceof ICDIThread) )
{
handleSuspendedEvent( (ICDISuspendedEvent)event );
}
@ -1369,6 +1403,7 @@ public class CDebugTarget extends CDebugElement
setCurrentStateId( IState.SUSPENDED );
ICDISessionObject reason = event.getReason();
setCurrentStateInfo( reason );
setRunningInfo( null );
List newThreads = refreshThreads();
if ( event.getSource() instanceof ICDITarget )
{
@ -1411,6 +1446,107 @@ public class CDebugTarget extends CDebugElement
}
}
private boolean handleInternalSuspendedEvent( ICDISuspendedEvent event )
{
setRetryBreakpoints( true );
setBreakpoints();
RunningInfo info = getRunningInfo();
if ( info != null )
{
switch( info.getType() )
{
case ICDIResumedEvent.CONTINUE:
return internalResume();
case ICDIResumedEvent.STEP_INTO:
return internalStepInto( info.getStackDepth() );
case ICDIResumedEvent.STEP_OVER:
return internalStepOver( info.getStackDepth() );
case ICDIResumedEvent.STEP_RETURN:
return internalStepReturn( info.getStackDepth() );
}
}
return internalResume();
}
private boolean internalResume()
{
boolean result = false;
try
{
getCDITarget().resume();
}
catch( CDIException e )
{
result = true;
}
return result;
}
private boolean internalStepInto( int oldDepth )
{
return internalStepOver( oldDepth );
}
private boolean internalStepOver( int oldDepth )
{
boolean result = true;
try
{
CThread thread = (CThread)getCurrentThread();
if ( thread != null )
{
int depth = thread.getStackDepth();
if ( oldDepth < depth )
{
ICDIStackFrame[] frames = thread.getCDIStackFrames( depth - oldDepth - 1, depth - oldDepth - 1 );
if ( frames.length == 1 )
{
thread.getCDIThread().setCurrentStackFrame( frames[0] );
getCDITarget().stepReturn();
result = false;
}
}
}
}
catch( CDIException e )
{
}
catch( DebugException e )
{
}
return result;
}
private boolean internalStepReturn( int oldDepth )
{
boolean result = true;
try
{
CThread thread = (CThread)getCurrentThread();
if ( thread != null )
{
int depth = thread.getStackDepth();
if ( oldDepth < depth )
{
ICDIStackFrame[] frames = thread.getCDIStackFrames( depth - oldDepth, depth - oldDepth );
if ( frames.length == 1 )
{
thread.getCDIThread().setCurrentStackFrame( frames[0] );
getCDITarget().stepReturn();
result = false;
}
}
}
}
catch( CDIException e )
{
}
catch( DebugException e )
{
}
return result;
}
private void handleResumedEvent( ICDIResumedEvent event )
{
setSuspended( false );
@ -1436,6 +1572,8 @@ public class CDebugTarget extends CDebugElement
detail = DebugEvent.STEP_RETURN;
break;
}
if ( getRunningInfo() == null )
setRunningInfo( event.getType() );
fireResumeEvent( detail );
}
@ -2609,4 +2747,48 @@ public class CDebugTarget extends CDebugElement
CCorePlugin.getWorkspace().removeResourceChangeListener( listener );
}
}
protected RunningInfo getRunningInfo()
{
return fRunningInfo;
}
protected void setRunningInfo( RunningInfo info )
{
fRunningInfo = info;
}
protected void setRunningInfo( int type )
{
RunningInfo info = null;
try
{
CThread thread = (CThread)getCurrentThread();
if ( thread != null )
{
int depth = thread.getLastStackDepth();
if ( depth > 0 )
{
info = new RunningInfo( type, depth );
}
}
}
catch( DebugException e )
{
}
setRunningInfo( info );
}
private boolean applyDeferredBreakpoints()
{
boolean result = false;
try
{
result = getLaunch().getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_DEFERRED_BREAKPOINTS, false );
}
catch( CoreException e )
{
}
return result;
}
}

View file

@ -10,10 +10,12 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryEvent;
import org.eclipse.cdt.debug.core.cdi.ICDISignalReceived;
import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent;
@ -36,6 +38,7 @@ import org.eclipse.cdt.debug.core.model.IRunToLine;
import org.eclipse.cdt.debug.core.model.IState;
import org.eclipse.cdt.debug.core.model.ISwitchToFrame;
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
@ -425,9 +428,10 @@ public class CThread extends CDebugElement
if ( event instanceof ICDISuspendedEvent )
{
if ( ( source instanceof ICDIThread && getCDIThread().equals( (ICDIThread)source ) ) ||
source instanceof ICDITarget )
source instanceof ICDITarget )
{
handleSuspendedEvent( (ICDISuspendedEvent)event );
if ( !(((ICDISuspendedEvent)event).getReason() instanceof ICDISharedLibraryEvent && applyDeferredBreakpoints()) )
handleSuspendedEvent( (ICDISuspendedEvent)event );
}
}
else if ( event instanceof ICDIResumedEvent )
@ -1097,7 +1101,7 @@ public class CThread extends CDebugElement
fLastStackDepth = depth;
}
private int getLastStackDepth()
protected int getLastStackDepth()
{
return fLastStackDepth;
}
@ -1141,4 +1145,17 @@ public class CThread extends CDebugElement
((IResumeWithoutSignal)getDebugTarget()).resumeWithoutSignal();
}
}
private boolean applyDeferredBreakpoints()
{
boolean result = false;
try
{
result = getLaunch().getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_DEFERRED_BREAKPOINTS, false );
}
catch( CoreException e )
{
}
return result;
}
}