1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

More implementation of breakpoints.

This commit is contained in:
Mikhail Khodjaiants 2002-09-03 14:37:25 +00:00
parent dccf5a3e6a
commit c52732cf99
2 changed files with 96 additions and 2 deletions

View file

@ -192,4 +192,34 @@ public abstract class CBreakpoint extends Breakpoint
{
return null;
}
/**
* Increments the install count of this breakpoint
*/
public void incrementInstallCount() throws CoreException
{
int count = getInstallCount();
setAttribute( INSTALL_COUNT, count + 1 );
}
/**
* Returns the <code>INSTALL_COUNT</code> attribute of this breakpoint
* or 0 if the attribute is not set.
*/
public int getInstallCount() throws CoreException
{
return ensureMarker().getAttribute( INSTALL_COUNT, 0 );
}
/**
* Decrements the install count of this breakpoint.
*/
public void decrementInstallCount() throws CoreException
{
int count = getInstallCount();
if ( count > 0 )
{
setAttribute( INSTALL_COUNT, count - 1 );
}
}
}

View file

@ -557,6 +557,15 @@ public class CDebugTarget extends CDebugElement
*/
public void breakpointRemoved( IBreakpoint breakpoint, IMarkerDelta delta )
{
try
{
if ( breakpoint instanceof CBreakpoint )
removeBreakpoint( (CBreakpoint)breakpoint );
}
catch( DebugException e )
{
CDebugCorePlugin.log( e );
}
}
/* (non-Javadoc)
@ -946,7 +955,14 @@ public class CDebugTarget extends CDebugElement
getCDISession().getEventManager().removeEventListener( this );
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this );
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener( this );
removeAllBreakpoints();
try
{
removeAllBreakpoints();
}
catch( DebugException e )
{
CDebugCorePlugin.log( e );
}
}
/**
@ -969,8 +985,50 @@ public class CDebugTarget extends CDebugElement
* Removes all breakpoints from this target.
*
*/
protected void removeAllBreakpoints()
protected void removeAllBreakpoints() throws DebugException
{
ICDIBreakpoint[] cdiBreakpoints = (ICDIBreakpoint[])getBreakpoints().values().toArray( new ICDIBreakpoint[0] );
ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
try
{
bm.deleteBreakpoints( cdiBreakpoints );
Iterator it = getBreakpoints().keySet().iterator();
while( it.hasNext() )
{
((CBreakpoint)it.next()).decrementInstallCount();
}
getBreakpoints().clear();
}
catch( CoreException ce )
{
requestFailed( "Operation failed. Reason: ", ce );
}
catch( CDIException e )
{
requestFailed( "Operation failed. Reason: ", e );
}
}
protected void removeBreakpoint( CBreakpoint breakpoint ) throws DebugException
{
ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint );
if ( cdiBreakpoint == null )
return;
ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
try
{
bm.deleteBreakpoints( new ICDIBreakpoint[] { cdiBreakpoint } );
getBreakpoints().remove( breakpoint );
breakpoint.decrementInstallCount();
}
catch( CoreException ce )
{
requestFailed( "Operation failed. Reason: ", ce );
}
catch( CDIException e )
{
requestFailed( "Operation failed. Reason: ", e );
}
}
/**
@ -1370,6 +1428,7 @@ public class CDebugTarget extends CDebugElement
if ( !getBreakpoints().containsKey( breakpoint ) )
{
getBreakpoints().put( breakpoint, cdiBreakpoint );
((CBreakpoint)breakpoint).incrementInstallCount();
}
}
catch( CoreException ce )
@ -1381,4 +1440,9 @@ public class CDebugTarget extends CDebugElement
requestFailed( "Operation failed. Reason: ", e );
}
}
private ICDIBreakpoint findCDIBreakpoint( IBreakpoint breakpoint )
{
return (ICDIBreakpoint)getBreakpoints().get( breakpoint );
}
}