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:
parent
8565f9f346
commit
21b8ccf0a5
3 changed files with 42 additions and 37 deletions
|
@ -269,21 +269,6 @@ public class CDebugCorePlugin extends Plugin {
|
|||
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() {
|
||||
return fSessionManager;
|
||||
}
|
||||
|
@ -347,7 +332,6 @@ public class CDebugCorePlugin extends Plugin {
|
|||
super.start( context );
|
||||
initializeCommonSourceLookupDirector();
|
||||
createBreakpointListenersList();
|
||||
resetBreakpointsInstallCount();
|
||||
setSessionManager( new SessionManager() );
|
||||
}
|
||||
|
||||
|
@ -357,7 +341,6 @@ public class CDebugCorePlugin extends Plugin {
|
|||
public void stop( BundleContext context ) throws Exception {
|
||||
setSessionManager( null );
|
||||
disposeBreakpointListenersList();
|
||||
resetBreakpointsInstallCount();
|
||||
disposeCommonSourceLookupDirector();
|
||||
disposeDebugConfigurations();
|
||||
super.stop( context );
|
||||
|
|
|
@ -26,11 +26,13 @@ import org.eclipse.debug.core.model.IBreakpoint;
|
|||
public interface ICBreakpoint extends IBreakpoint {
|
||||
|
||||
/**
|
||||
* Breakpoint attribute storing the number of debug targets a breakpoint is
|
||||
* installed in (value <code>"org.eclipse.cdt.debug.core.installCount"</code>).
|
||||
* This attribute is an <code>int</code>.
|
||||
* Breakpoint attribute that we use merely as a way to force the marker to
|
||||
* refresh. When a CDT internal, but not persisted, state of the breakpoint
|
||||
* 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
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.internal.core.breakpoints;
|
|||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -48,6 +49,11 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
|
|||
*/
|
||||
private Map fExtensions = new HashMap(1);
|
||||
|
||||
/**
|
||||
* The number of debug targets the breakpoint is installed in.
|
||||
*/
|
||||
private int fInstallCount = 0;
|
||||
|
||||
/**
|
||||
* Constructor for CBreakpoint.
|
||||
*/
|
||||
|
@ -107,7 +113,7 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
|
|||
* @see org.eclipse.cdt.debug.core.ICBreakpoint#isInstalled()
|
||||
*/
|
||||
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;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#resetInstallCount()
|
||||
*/
|
||||
public synchronized void resetInstallCount() throws CoreException {
|
||||
setAttribute( INSTALL_COUNT, 0 );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#incrementInstallCount()
|
||||
*/
|
||||
public synchronized int incrementInstallCount() throws CoreException {
|
||||
int count = getInstallCount();
|
||||
setAttribute( INSTALL_COUNT, ++count );
|
||||
return count;
|
||||
++fInstallCount;
|
||||
|
||||
// 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,18 +241,33 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
|
|||
* 0 if the attribute is not set.
|
||||
*/
|
||||
public int getInstallCount() throws CoreException {
|
||||
return ensureMarker().getAttribute( INSTALL_COUNT, 0 );
|
||||
return fInstallCount;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#decrementInstallCount()
|
||||
*/
|
||||
public synchronized int decrementInstallCount() throws CoreException {
|
||||
int count = getInstallCount();
|
||||
if ( count > 0 ) {
|
||||
setAttribute( INSTALL_COUNT, --count );
|
||||
fInstallCount--;
|
||||
|
||||
// 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 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
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue