diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java index 036a7e9a425..19323f6535e 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java @@ -131,18 +131,7 @@ public class CDebugModel if ( stopInMain ) { ICDILocation location = cdiTarget.getSession().getBreakpointManager().createLocation( "", "main", 0 ); - try - { - ICDIBreakpoint bkpt = cdiTarget.getSession().getBreakpointManager(). - setLocationBreakpoint( ICDIBreakpoint.REGULAR, //ICDIBreakpoint.TEMPORARY, - location, - null, - null ); - } - catch( CDIException e ) - { - ((CDebugElement)target[0]).targetRequestFailed( MessageFormat.format( "{0} occurred setting temporary breakpoint.", new String[] { e.toString() } ), e ); - } + ((CDebugTarget)target[0]).setInternalTemporaryBreakpoint( location ); } target[0].resume(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java index 8f6bc0b4c74..9f45d25ff77 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java @@ -185,6 +185,11 @@ public class CDebugTarget extends CDebugElement */ private List fRegisterGroups; + /** + * Collection of temporary breakpoints set at this target. Values are of type ICBreakpoint. + */ + private List fTemporaryBreakpoints; + /** * Constructor for CDebugTarget. * @param target @@ -204,6 +209,7 @@ public class CDebugTarget extends CDebugElement setProcess( process ); setCDITarget( cdiTarget ); setBreakpoints( new HashMap( 5 ) ); + setTemporaryBreakpoints( new ArrayList() ); setConfiguration( cdiTarget.getSession().getConfiguration() ); fSupportsTerminate = allowsTerminate & getConfiguration().supportsTerminate(); fSupportsDisconnect = allowsDisconnect & getConfiguration().supportsDisconnect(); @@ -1095,6 +1101,25 @@ public class CDebugTarget extends CDebugElement } } + /** + * Removes all temporary breakpoints from this target. + * + */ + protected void removeAllTemporaryBreakpoints() + { + ICDIBreakpoint[] cdiBreakpoints = (ICDIBreakpoint[])getTemporaryBreakpoints().toArray( new ICDIBreakpoint[0] ); + ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); + try + { + bm.deleteBreakpoints( cdiBreakpoints ); + getTemporaryBreakpoints().clear(); + } + catch( CDIException e ) + { + logError( e ); + } + } + protected void changeBreakpointProperties( CBreakpoint breakpoint, IMarkerDelta delta ) throws DebugException { ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint ); @@ -1187,6 +1212,7 @@ public class CDebugTarget extends CDebugElement setCurrentStateId( IState.SUSPENDED ); ICDISessionObject reason = event.getReason(); setCurrentStateInfo( reason ); + removeAllTemporaryBreakpoints(); List newThreads = refreshThreads(); if ( event.getSource() instanceof ICDITarget ) { @@ -1512,6 +1538,24 @@ public class CDebugTarget extends CDebugElement return fBreakpoints; } + /** + * Returns the list of temporary breakpoints installed in this debug target. + * + * @return list of installed temporary breakpoints + */ + protected List getTemporaryBreakpoints() + { + return fTemporaryBreakpoints; + } + + /** + * Uninstalles all temporary breakpoints installed in this debug target. + * + */ + protected void deleteTemporaryBreakpoints() + { + } + /** * Sets the map of breakpoints installed in this debug target. * @@ -1522,6 +1566,16 @@ public class CDebugTarget extends CDebugElement fBreakpoints = breakpoints; } + /** + * Sets the list of temporary breakpoints installed in this debug target. + * + * @param breakpoints breakpoints list + */ + private void setTemporaryBreakpoints( List breakpoints ) + { + fTemporaryBreakpoints = breakpoints; + } + /** * Returns the debug configuration of this target. * @@ -1716,4 +1770,21 @@ public class CDebugTarget extends CDebugElement } } } + + public void setInternalTemporaryBreakpoint( ICDILocation location ) throws DebugException + { + try + { + ICDIBreakpoint bkpt = getCDISession().getBreakpointManager(). + setLocationBreakpoint( ICDIBreakpoint.REGULAR, //ICDIBreakpoint.TEMPORARY, + location, + null, + null ); + getTemporaryBreakpoints().add( bkpt ); + } + catch( CDIException e ) + { + targetRequestFailed( e.getMessage(), null ); + } + } }