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

Addressed two loose ends of bugzilla 118100

This commit is contained in:
John Cortell 2008-05-08 02:42:34 +00:00
parent 79aa62cd97
commit b36ad37def
6 changed files with 135 additions and 31 deletions

View file

@ -37,17 +37,16 @@ public interface ICDIBreakpoint extends ICDIObject {
final static public int TEMPORARY = ICBreakpointType.TEMPORARY; final static public int TEMPORARY = ICBreakpointType.TEMPORARY;
/** @deprecated use ICBreakpointTyped.HARDWARE */ /** @deprecated use ICBreakpointTyped.HARDWARE */
final static public int HARDWARE = ICBreakpointType.HARDWARE; final static public int HARDWARE = ICBreakpointType.HARDWARE;
/** /**
* Returns whether this breakpoint is temporary.
*
* @return whether this breakpoint is temporary * @return whether this breakpoint is temporary
* @deprecated by {@link ICDIBreakpoint2#getType()}
*/ */
boolean isTemporary(); boolean isTemporary();
/** /**
* Returns whether this breakpoint is hardware-assisted.
*
* @return whether this breakpoint is hardware-assisted * @return whether this breakpoint is hardware-assisted
* @deprecated by {@link ICDIBreakpoint2#getType()}
*/ */
boolean isHardware(); boolean isHardware();

View file

@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2008 Freescale and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Freescale - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.cdi.model;
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
/**
* Extension of the ICDIBreakpoint interface
*/
public interface ICDIBreakpoint2 extends ICDIBreakpoint {
/**
* Return the type of the breakpoint. If the breakpoint's creation
* originated in CDT, then CDT specified the type as part of that request
* and this method must return that value. If the breakpoint's creation
* originated in the CDI client, then this method is invoked by CDT to
* discover the type of the breakpoint.
*
* If the CDI breakpoint implements this interface, then
* {@link ICDIBreakpoint#isTemporary()} and
* {@link ICDIBreakpoint#isHardware()} will never get called by CDT, as this
* method is meant to replace those.
*
* @return one of the type constants defined in ICBreakpointType (note that
* {@link ICBreakpointType#TEMPORARY} can be bit-applied to any of
* the type values to qualify it as a temporary breakpoint.
*/
int getType();
}

View file

@ -179,6 +179,8 @@ public class CDIDebugModel {
* the handle to the breakpoint source * the handle to the breakpoint source
* @param resource * @param resource
* the resource on which to create the associated breakpoint marker * the resource on which to create the associated breakpoint marker
* @param type
* a type constant from ICBreakpointType
* @param lineNumber * @param lineNumber
* the line number on which the breakpoint is set - line numbers are 1 based, associated with the source file in which the breakpoint is set * the line number on which the breakpoint is set - line numbers are 1 based, associated with the source file in which the breakpoint is set
* @param enabled * @param enabled
@ -196,7 +198,7 @@ public class CDIDebugModel {
* <li>Failure creating underlying marker. The exception's status contains the underlying exception responsible for the failure.</li> * <li>Failure creating underlying marker. The exception's status contains the underlying exception responsible for the failure.</li>
* </ul> * </ul>
*/ */
public static ICLineBreakpoint createLineBreakpoint( String sourceHandle, IResource resource, int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException { public static ICLineBreakpoint createLineBreakpoint( String sourceHandle, IResource resource, int type, int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
HashMap attributes = new HashMap( 10 ); HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() ); attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) ); attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
@ -204,7 +206,7 @@ public class CDIDebugModel {
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) ); attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition ); attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle ); attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
attributes.put( ICBreakpointType.TYPE, ICBreakpointType.REGULAR ); attributes.put( ICBreakpointType.TYPE, type );
return new CLineBreakpoint( resource, attributes, register ); return new CLineBreakpoint( resource, attributes, register );
} }
@ -216,6 +218,7 @@ public class CDIDebugModel {
* @param module the module name the breakpoint is set in * @param module the module name the breakpoint is set in
* @param sourceHandle the handle to the breakpoint source * @param sourceHandle the handle to the breakpoint source
* @param resource the resource on which to create the associated breakpoint marker * @param resource the resource on which to create the associated breakpoint marker
* @param type a type constant from ICBreakpointType
* @param address the address on which the breakpoint is set * @param address the address on which the breakpoint is set
* @param enabled whether to enable or disable this breakpoint * @param enabled whether to enable or disable this breakpoint
* @param ignoreCount the number of times this breakpoint will be ignored * @param ignoreCount the number of times this breakpoint will be ignored
@ -229,8 +232,8 @@ public class CDIDebugModel {
* failure.</li> * failure.</li>
* </ul> * </ul>
*/ */
public static ICAddressBreakpoint createAddressBreakpoint( String module, String sourceHandle, IResource resource, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException { public static ICAddressBreakpoint createAddressBreakpoint( String module, String sourceHandle, IResource resource, int type, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
return createAddressBreakpoint( module, sourceHandle, resource, -1, address, enabled, ignoreCount, condition, register ); return createAddressBreakpoint( module, sourceHandle, resource, type, -1, address, enabled, ignoreCount, condition, register );
} }
/** /**
@ -241,6 +244,7 @@ public class CDIDebugModel {
* @param module the module name the breakpoint is set in * @param module the module name the breakpoint is set in
* @param sourceHandle the handle to the breakpoint source * @param sourceHandle the handle to the breakpoint source
* @param resource the resource on which to create the associated breakpoint marker * @param resource the resource on which to create the associated breakpoint marker
* @param type a type constant from ICBreakpointType
* @param lineNumber the line number in the source file * @param lineNumber the line number in the source file
* @param address the address on which the breakpoint is set * @param address the address on which the breakpoint is set
* @param enabled whether to enable or disable this breakpoint * @param enabled whether to enable or disable this breakpoint
@ -255,7 +259,7 @@ public class CDIDebugModel {
* failure.</li> * failure.</li>
* </ul> * </ul>
*/ */
public static ICAddressBreakpoint createAddressBreakpoint( String module, String sourceHandle, IResource resource, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException { public static ICAddressBreakpoint createAddressBreakpoint( String module, String sourceHandle, IResource resource, int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
HashMap attributes = new HashMap( 10 ); HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() ); attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IMarker.CHAR_START, new Integer( -1 ) ); attributes.put( IMarker.CHAR_START, new Integer( -1 ) );
@ -267,6 +271,7 @@ public class CDIDebugModel {
attributes.put( ICBreakpoint.CONDITION, condition ); attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle ); attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
attributes.put( ICBreakpoint.MODULE, module ); attributes.put( ICBreakpoint.MODULE, module );
attributes.put( ICBreakpointType.TYPE, type );
return new CAddressBreakpoint( resource, attributes, register ); return new CAddressBreakpoint( resource, attributes, register );
} }
@ -394,6 +399,7 @@ public class CDIDebugModel {
* *
* @param sourceHandle the handle to the breakpoint source * @param sourceHandle the handle to the breakpoint source
* @param resource the resource on which to create the associated breakpoint marker * @param resource the resource on which to create the associated breakpoint marker
* @param type a type constant from ICBreakpointType
* @param function the name of the function this breakpoint suspends execution in * @param function the name of the function this breakpoint suspends execution in
* @param charStart the first character index associated with the breakpoint, or * @param charStart the first character index associated with the breakpoint, or
* -1 if unspecified, in the source file in which the breakpoint * -1 if unspecified, in the source file in which the breakpoint
@ -416,7 +422,7 @@ public class CDIDebugModel {
* failure.</li> * failure.</li>
* </ul> * </ul>
*/ */
public static ICFunctionBreakpoint createFunctionBreakpoint( String sourceHandle, IResource resource, String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException { public static ICFunctionBreakpoint createFunctionBreakpoint( String sourceHandle, IResource resource, int type, String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
HashMap attributes = new HashMap( 10 ); HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() ); attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IMarker.CHAR_START, new Integer( charStart ) ); attributes.put( IMarker.CHAR_START, new Integer( charStart ) );
@ -427,6 +433,7 @@ public class CDIDebugModel {
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) ); attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition ); attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle ); attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
attributes.put( ICBreakpointType.TYPE, type );
return new CFunctionBreakpoint( resource, attributes, register ); return new CFunctionBreakpoint( resource, attributes, register );
} }

View file

@ -49,6 +49,7 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
import org.eclipse.cdt.debug.core.cdi.event.ICDIExecutableReloadedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIExecutableReloadedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIAddressBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIAddressBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint2;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement2; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement2;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement3; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement3;
import org.eclipse.cdt.debug.core.cdi.model.ICDIEventBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIEventBreakpoint;
@ -459,6 +460,18 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
return ( b instanceof IBreakpoint ) ? (IBreakpoint)b : null; return ( b instanceof IBreakpoint ) ? (IBreakpoint)b : null;
} }
/**
* @return true if the breakpoint is of a temporary type, otherwise false
*/
private boolean isTemporary(ICDIBreakpoint cdiBreakpoint) {
if (cdiBreakpoint instanceof ICDIBreakpoint2) {
return (((ICDIBreakpoint2)cdiBreakpoint).getType() & ICBreakpointType.TEMPORARY) != 0;
}
else {
return cdiBreakpoint.isTemporary();
}
}
private void handleBreakpointCreatedEvent( ICDIBreakpoint cdiBreakpoint ) { private void handleBreakpointCreatedEvent( ICDIBreakpoint cdiBreakpoint ) {
if ( cdiBreakpoint instanceof ICDIWatchpoint ) if ( cdiBreakpoint instanceof ICDIWatchpoint )
doHandleWatchpointCreatedEvent( (ICDIWatchpoint)cdiBreakpoint ); doHandleWatchpointCreatedEvent( (ICDIWatchpoint)cdiBreakpoint );
@ -466,7 +479,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
doHandleCatachpointCreatedEvent( (ICDIEventBreakpoint)cdiBreakpoint ); doHandleCatachpointCreatedEvent( (ICDIEventBreakpoint)cdiBreakpoint );
else if ( cdiBreakpoint instanceof ICDILocationBreakpoint ) else if ( cdiBreakpoint instanceof ICDILocationBreakpoint )
doHandleLocationBreakpointCreatedEvent( (ICDILocationBreakpoint)cdiBreakpoint ); doHandleLocationBreakpointCreatedEvent( (ICDILocationBreakpoint)cdiBreakpoint );
if ( !cdiBreakpoint.isTemporary() && !DebugPlugin.getDefault().getBreakpointManager().isEnabled() ) { if ( !isTemporary(cdiBreakpoint) && !DebugPlugin.getDefault().getBreakpointManager().isEnabled() ) {
changeBreakpointPropertiesOnTarget(cdiBreakpoint, new Boolean(false), null); changeBreakpointPropertiesOnTarget(cdiBreakpoint, new Boolean(false), null);
} }
} }
@ -503,7 +516,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
} }
private void doHandleLocationBreakpointCreatedEvent( ICDILocationBreakpoint cdiBreakpoint ) { private void doHandleLocationBreakpointCreatedEvent( ICDILocationBreakpoint cdiBreakpoint ) {
if ( cdiBreakpoint.isTemporary() ) if ( isTemporary(cdiBreakpoint) )
return; return;
ICBreakpoint breakpoint = null; ICBreakpoint breakpoint = null;
synchronized( getBreakpointMap() ) { synchronized( getBreakpointMap() ) {
@ -935,6 +948,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
private ICLineBreakpoint createLineBreakpoint( String sourceHandle, IResource resource, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException { private ICLineBreakpoint createLineBreakpoint( String sourceHandle, IResource resource, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException {
ICLineBreakpoint breakpoint = CDIDebugModel.createLineBreakpoint( sourceHandle, ICLineBreakpoint breakpoint = CDIDebugModel.createLineBreakpoint( sourceHandle,
resource, resource,
getCdiBreakpointType(cdiBreakpoint),
cdiBreakpoint.getLocator().getLineNumber(), cdiBreakpoint.getLocator().getLineNumber(),
cdiBreakpoint.isEnabled(), cdiBreakpoint.isEnabled(),
cdiBreakpoint.getCondition().getIgnoreCount(), cdiBreakpoint.getCondition().getIgnoreCount(),
@ -950,12 +964,36 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
return breakpoint; return breakpoint;
} }
/**
* Utility method that queries the CDI client for the breakpoint type.
*
* @param cdiBreakpoint
* the CDI breakpoint
* @return an ICDIBreakpointType constant
*/
@SuppressWarnings("deprecation")
private int getCdiBreakpointType(ICDIBreakpoint cdiBreakpoint) {
if (cdiBreakpoint instanceof ICDIBreakpoint2) {
// the new way
return ((ICDIBreakpoint2)cdiBreakpoint).getType();
}
else {
// the old way
int type = cdiBreakpoint.isHardware() ? ICBreakpointType.HARDWARE : ICBreakpointType.REGULAR;
if (cdiBreakpoint.isTemporary()) {
type |= ICBreakpointType.TEMPORARY;
}
return type;
}
}
private ICFunctionBreakpoint createFunctionBreakpoint( String sourceHandle, IResource resource, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException { private ICFunctionBreakpoint createFunctionBreakpoint( String sourceHandle, IResource resource, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException {
ICDILocator location = cdiBreakpoint.getLocator(); ICDILocator location = cdiBreakpoint.getLocator();
int line = location.getLineNumber(); int line = location.getLineNumber();
ICFunctionBreakpoint breakpoint = CDIDebugModel.createFunctionBreakpoint( ICFunctionBreakpoint breakpoint = CDIDebugModel.createFunctionBreakpoint(
sourceHandle, sourceHandle,
resource, resource,
getCdiBreakpointType(cdiBreakpoint),
location.getFunction(), location.getFunction(),
-1, -1,
-1, -1,

View file

@ -15,7 +15,7 @@ import java.util.List;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint2;
import org.eclipse.cdt.debug.core.model.ICBreakpointType; import org.eclipse.cdt.debug.core.model.ICBreakpointType;
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager; import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager;
import org.eclipse.cdt.debug.mi.core.cdi.Condition; import org.eclipse.cdt.debug.mi.core.cdi.Condition;
@ -24,18 +24,30 @@ import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint;
/** /**
*/ */
public abstract class Breakpoint extends CObject implements ICDIBreakpoint { public abstract class Breakpoint extends CObject implements ICDIBreakpoint2 {
ICDICondition condition; ICDICondition condition;
MIBreakpoint[] miBreakpoints; MIBreakpoint[] miBreakpoints;
int type;
boolean enable;
public Breakpoint(Target target, int kind, ICDICondition cond, boolean enabled) { /**
* One of the type constants in ICBreakpointType
*/
int type;
boolean enabled;
public Breakpoint(Target target, int type, ICDICondition condition, boolean enabled) {
super(target); super(target);
type = kind; this.type = type;
condition = cond; this.condition = condition;
enable = enabled; this.enabled = enabled;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint2#getType()
*/
public int getType() {
return type;
} }
public MIBreakpoint[] getMIBreakpoints() { public MIBreakpoint[] getMIBreakpoints() {
@ -78,21 +90,28 @@ public abstract class Breakpoint extends CObject implements ICDIBreakpoint {
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isEnabled() * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isEnabled()
*/ */
public boolean isEnabled() throws CDIException { public boolean isEnabled() throws CDIException {
return enable; return enabled;
} }
/** /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isHardware() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint#isHardware()
*
* CDT 5.0 won't call this deprecated method (since we implement
* ICDIBreakpoint2), but we use it ourselves.
*/ */
public boolean isHardware() { public boolean isHardware() {
return (type == ICBreakpointType.HARDWARE); // ignore the TEMPORARY bit qualifier
return ((type & ~ICBreakpointType.TEMPORARY) == ICBreakpointType.HARDWARE);
} }
/** /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isTemporary() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint#isTemporary()
*
* CDT 5.0 won't call this deprecated method (since we implement
* ICDIBreakpoint2), but we use it ourselves.
*/ */
public boolean isTemporary() { public boolean isTemporary() {
return (type == ICBreakpointType.TEMPORARY); return (type & ICBreakpointType.TEMPORARY) != 0;
} }
/** /**
@ -123,7 +142,7 @@ public abstract class Breakpoint extends CObject implements ICDIBreakpoint {
} }
public void setEnabled0(boolean on) { public void setEnabled0(boolean on) {
enable = on; enabled = on;
} }
} }

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IVariable; import org.eclipse.cdt.core.model.IVariable;
import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
@ -132,6 +133,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
else { else {
CDIDebugModel.createLineBreakpoint( sourceHandle, CDIDebugModel.createLineBreakpoint( sourceHandle,
resource, resource,
ICBreakpointType.REGULAR,
lineNumber, lineNumber,
true, true,
0, 0,
@ -510,6 +512,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
} }
CDIDebugModel.createFunctionBreakpoint( sourceHandle, CDIDebugModel.createFunctionBreakpoint( sourceHandle,
resource, resource,
ICBreakpointType.REGULAR,
functionName, functionName,
charStart, charStart,
charEnd, charEnd,