1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bugzilla 218194. Fix how install count is associated with a breakpoint.

This commit is contained in:
John Cortell 2008-02-07 16:33:35 +00:00
parent 8565f9f346
commit 21b8ccf0a5
3 changed files with 42 additions and 37 deletions

View file

@ -269,21 +269,6 @@ public class CDebugCorePlugin extends Plugin {
return dbgCfg; return dbgCfg;
} }
protected void resetBreakpointsInstallCount() {
IBreakpointManager bm = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = bm.getBreakpoints( getUniqueIdentifier() );
for( int i = 0; i < breakpoints.length; ++i ) {
if ( breakpoints[i] instanceof CBreakpoint ) {
try {
((CBreakpoint)breakpoints[i]).resetInstallCount();
}
catch( CoreException e ) {
log( e.getStatus() );
}
}
}
}
protected SessionManager getSessionManager() { protected SessionManager getSessionManager() {
return fSessionManager; return fSessionManager;
} }
@ -347,7 +332,6 @@ public class CDebugCorePlugin extends Plugin {
super.start( context ); super.start( context );
initializeCommonSourceLookupDirector(); initializeCommonSourceLookupDirector();
createBreakpointListenersList(); createBreakpointListenersList();
resetBreakpointsInstallCount();
setSessionManager( new SessionManager() ); setSessionManager( new SessionManager() );
} }
@ -357,7 +341,6 @@ public class CDebugCorePlugin extends Plugin {
public void stop( BundleContext context ) throws Exception { public void stop( BundleContext context ) throws Exception {
setSessionManager( null ); setSessionManager( null );
disposeBreakpointListenersList(); disposeBreakpointListenersList();
resetBreakpointsInstallCount();
disposeCommonSourceLookupDirector(); disposeCommonSourceLookupDirector();
disposeDebugConfigurations(); disposeDebugConfigurations();
super.stop( context ); super.stop( context );

View file

@ -26,11 +26,13 @@ import org.eclipse.debug.core.model.IBreakpoint;
public interface ICBreakpoint extends IBreakpoint { public interface ICBreakpoint extends IBreakpoint {
/** /**
* Breakpoint attribute storing the number of debug targets a breakpoint is * Breakpoint attribute that we use merely as a way to force the marker to
* installed in (value <code>"org.eclipse.cdt.debug.core.installCount"</code>). * refresh. When a CDT internal, but not persisted, state of the breakpoint
* This attribute is an <code>int</code>. * changes in a way that calls for the marker to refresh, we simply store a
* timestamp (Long.toString(Date.getTime())) into this setting. The platform
* responds to all marker attrib changes with a marker refresh.
*/ */
public static final String INSTALL_COUNT = "org.eclipse.cdt.debug.core.installCount"; //$NON-NLS-1$ public static final String FORCE_UPDATE = "org.eclipse.cdt.debug.core.forceupdate"; //$NON-NLS-1$
/** /**
* Breakpoint attribute storing the conditional expression associated with * Breakpoint attribute storing the conditional expression associated with

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -48,6 +49,11 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
*/ */
private Map fExtensions = new HashMap(1); private Map fExtensions = new HashMap(1);
/**
* The number of debug targets the breakpoint is installed in.
*/
private int fInstallCount = 0;
/** /**
* Constructor for CBreakpoint. * Constructor for CBreakpoint.
*/ */
@ -107,7 +113,7 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
* @see org.eclipse.cdt.debug.core.ICBreakpoint#isInstalled() * @see org.eclipse.cdt.debug.core.ICBreakpoint#isInstalled()
*/ */
public boolean isInstalled() throws CoreException { public boolean isInstalled() throws CoreException {
return ensureMarker().getAttribute( INSTALL_COUNT, 0 ) > 0; return fInstallCount > 0;
} }
/* /*
@ -215,20 +221,19 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
abstract protected String getMarkerMessage() throws CoreException; abstract protected String getMarkerMessage() throws CoreException;
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#resetInstallCount()
*/
public synchronized void resetInstallCount() throws CoreException {
setAttribute( INSTALL_COUNT, 0 );
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#incrementInstallCount() * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#incrementInstallCount()
*/ */
public synchronized int incrementInstallCount() throws CoreException { public synchronized int incrementInstallCount() throws CoreException {
int count = getInstallCount(); ++fInstallCount;
setAttribute( INSTALL_COUNT, ++count );
return count; // handle the crossing into the installed state; we decorate
// an installed marker with a blue checkmark
if (fInstallCount == 1) {
setAttribute(FORCE_UPDATE, Long.toString((new Date()).getTime())); // force a refresh of the marker through a dummy attribute
}
return fInstallCount;
} }
/** /**
@ -236,20 +241,35 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
* 0 if the attribute is not set. * 0 if the attribute is not set.
*/ */
public int getInstallCount() throws CoreException { public int getInstallCount() throws CoreException {
return ensureMarker().getAttribute( INSTALL_COUNT, 0 ); return fInstallCount;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#decrementInstallCount() * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#decrementInstallCount()
*/ */
public synchronized int decrementInstallCount() throws CoreException { public synchronized int decrementInstallCount() throws CoreException {
int count = getInstallCount(); fInstallCount--;
if ( count > 0 ) {
setAttribute( INSTALL_COUNT, --count ); // handle the crossing into the uninstalled state; we decorate
// an installed marker with a blue checkmark
if (fInstallCount == 0) {
setAttribute(FORCE_UPDATE, Long.toString((new Date()).getTime())); // force a refresh of the marker through a dummy attribute
} }
return count;
return fInstallCount;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#resetInstallCount()
*/
public synchronized void resetInstallCount() throws CoreException {
int previous = fInstallCount;
fInstallCount = 0;
if (previous != 0) {
setAttribute(FORCE_UPDATE, Long.toString((new Date()).getTime())); // force a refresh of the marker through a dummy attribute
}
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *