1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

[303004] Allow to extend MIBreakpoints instead of copying it. Use inheritance for GDBBreakpoints_7_0 now that we can.

This commit is contained in:
Marc Khouzam 2010-02-17 17:44:31 +00:00
parent 5eec05f77f
commit 72be877f9b
3 changed files with 140 additions and 786 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2010 Ericsson and others.
* Copyright (c) 2010 Ericsson 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
@ -16,10 +16,7 @@ import java.util.Map;
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Immutable;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.AbstractDMContext;
import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
@ -29,149 +26,27 @@ import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIPasscount;
import org.eclipse.cdt.dsf.mi.service.command.commands.CLITrace;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakAfter;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakCondition;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakDelete;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakDisable;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakEnable;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakInsert;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakList;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakWatch;
import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakListInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakpoint;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.service.AbstractDsfService;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;
/**
* Initial breakpoint service implementation.
* Implements the IBreakpoints interface.
* Breakpoint service for GDB 7.0.
* It also supports tracepoints
* @since 3.0
*/
public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoints
public class GDBBreakpoints_7_0 extends MIBreakpoints
{
// Services
ICommandControl fConnection;
private ICommandControl fConnection;
// Service breakpoints tracking
// The breakpoints are stored per context and keyed on the back-end breakpoint reference
private Map<IBreakpointsTargetDMContext, Map<Integer, MIBreakpointDMData>> fBreakpoints =
new HashMap<IBreakpointsTargetDMContext, Map<Integer, MIBreakpointDMData>>();
// Error messages
final String NULL_STRING = ""; //$NON-NLS-1$
final String UNKNOWN_EXECUTION_CONTEXT = "Unknown execution context"; //$NON-NLS-1$
final String UNKNOWN_BREAKPOINT_CONTEXT = "Unknown breakpoint context"; //$NON-NLS-1$
final String UNKNOWN_BREAKPOINT_TYPE = "Unknown breakpoint type"; //$NON-NLS-1$
final String UNKNOWN_BREAKPOINT = "Unknown breakpoint"; //$NON-NLS-1$
final String BREAKPOINT_INSERTION_FAILURE = "Breakpoint insertion failure"; //$NON-NLS-1$
final String WATCHPOINT_INSERTION_FAILURE = "Watchpoint insertion failure"; //$NON-NLS-1$
final String TRACEPOINT_INSERTION_FAILURE = "Tracepoint insertion failure"; //$NON-NLS-1$
final String INVALID_CONDITION = "Invalid condition"; //$NON-NLS-1$
final String INVALID_BREAKPOINT_TYPE = "Invalid breakpoint type"; //$NON-NLS-1$
///////////////////////////////////////////////////////////////////////////
// Breakpoint Events
///////////////////////////////////////////////////////////////////////////
static private class BreakpointsChangedEvent extends AbstractDMEvent<IBreakpointsTargetDMContext> implements IBreakpointsChangedEvent {
private IBreakpointDMContext[] fEventBreakpoints;
public BreakpointsChangedEvent(IBreakpointDMContext bp) {
super(DMContexts.getAncestorOfType(bp, IBreakpointsTargetDMContext.class));
fEventBreakpoints = new IBreakpointDMContext[] { bp };
}
public IBreakpointDMContext[] getBreakpoints() {
return fEventBreakpoints;
}
}
static private class BreakpointAddedEvent extends BreakpointsChangedEvent implements IBreakpointsAddedEvent {
public BreakpointAddedEvent(IBreakpointDMContext context) {
super(context);
}
}
static private class BreakpointUpdatedEvent extends BreakpointsChangedEvent implements IBreakpointsUpdatedEvent {
public BreakpointUpdatedEvent(IBreakpointDMContext context) {
super(context);
}
}
static private class BreakpointRemovedEvent extends BreakpointsChangedEvent implements IBreakpointsRemovedEvent {
public BreakpointRemovedEvent(IBreakpointDMContext context) {
super(context);
}
}
///////////////////////////////////////////////////////////////////////////
// IBreakpointDMContext
// Used to hold the back-end breakpoint references. The reference can then
// be used to get the actual DsfMIBreakpoint.
///////////////////////////////////////////////////////////////////////////
@Immutable
private static final class MIBreakpointDMContext extends AbstractDMContext implements IBreakpointDMContext {
// The breakpoint reference
private final int fReference;
/**
* @param session the DsfSession for this service
* @param parents the parent contexts
* @param reference the DsfMIBreakpoint reference
*/
public MIBreakpointDMContext(DsfSession session, IDMContext[] parents, int reference) {
super(session.getId(), parents);
fReference = reference;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.debug.service.IBreakpoints.IDsfBreakpointDMContext#getReference()
*/
public int getReference() {
return fReference;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.datamodel.AbstractDMContext#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
return baseEquals(obj) && (fReference == ((MIBreakpointDMContext) obj).fReference);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.datamodel.AbstractDMContext#hashCode()
*/
@Override
public int hashCode() {
return baseHashCode() + fReference;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return baseToString() + ".reference(" + fReference + ")"; //$NON-NLS-1$//$NON-NLS-2$
}
}
///////////////////////////////////////////////////////////////////////////
// AbstractDsfService
///////////////////////////////////////////////////////////////////////////
/**
* The service constructor
*
* @param session The debugging session
*/
public GDBBreakpoints_7_0(DsfSession session) {
super(session);
}
@ -189,231 +64,40 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
});
}
/*
* Asynchronous service initialization
*/
private void doInitialize(final RequestMonitor rm) {
// Get the services references
fConnection = getServicesTracker().getService(ICommandControl.class);
// Register this service
register(new String[] { IBreakpoints.class.getName(),
MIBreakpoints.class.getName(),
GDBBreakpoints_7_0.class.getName() },
new Hashtable<String, String>());
rm.done();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.service.AbstractDsfService#shutdown(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void shutdown(final RequestMonitor rm) {
unregister();
rm.done();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.service.AbstractDsfService#getBundleContext()
*/
@Override
protected BundleContext getBundleContext() {
return GdbPlugin.getBundleContext();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#getBreakpoints(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor)
*/
public void getBreakpoints(final IBreakpointsTargetDMContext context, final DataRequestMonitor<IBreakpointDMContext[]> drm)
{
// Validate the context
if (context == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
drm.done();
return;
}
// Select the breakpoints context map
// If it doesn't exist then no breakpoint was ever inserted for this breakpoint space.
// In that case, return an empty list.
final Map<Integer, MIBreakpointDMData> breakpointContext = fBreakpoints.get(context);
if (breakpointContext == null) {
drm.setData(new IBreakpointDMContext[0]);
drm.done();
return;
}
// Execute the command
fConnection.queueCommand(new MIBreakList(context),
new DataRequestMonitor<MIBreakListInfo>(getExecutor(), drm) {
@Override
protected void handleSuccess() {
// Refresh the breakpoints map and format the result
breakpointContext.clear();
MIBreakpoint[] breakpoints = getData().getMIBreakpoints();
IBreakpointDMContext[] result = new IBreakpointDMContext[breakpoints.length];
for (int i = 0; i < breakpoints.length; i++) {
MIBreakpointDMData breakpoint = new MIBreakpointDMData(breakpoints[i]);
int reference = breakpoint.getReference();
result[i] = new MIBreakpointDMContext(getSession(), new IDMContext[] { context }, reference);
breakpointContext.put(reference, breakpoint);
}
drm.setData(result);
drm.done();
}
});
}
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#getBreakpointDMData(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IDsfBreakpointDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor)
*/
public void getBreakpointDMData(IBreakpointDMContext dmc, DataRequestMonitor<IBreakpointDMData> drm)
{
// Validate the breakpoint context
if (dmc == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
return;
}
// Validate the breakpoint type
MIBreakpointDMContext breakpoint;
if (dmc instanceof MIBreakpointDMContext) {
breakpoint = (MIBreakpointDMContext) dmc;
}
else {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
drm.done();
return;
}
// Validate the target context
IBreakpointsTargetDMContext context = DMContexts.getAncestorOfType(breakpoint, IBreakpointsTargetDMContext.class);
if (context == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
drm.done();
return;
}
// Select the breakpoints context map
Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
if (contextBreakpoints == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
drm.done();
return;
}
// No need to go to the back-end for this one
IBreakpointDMData breakpointCopy = new MIBreakpointDMData(contextBreakpoints.get(breakpoint.getReference()));
drm.setData(breakpointCopy);
drm.done();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#insertBreakpoint(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext, java.util.Map, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor)
*/
public void insertBreakpoint(IBreakpointsTargetDMContext context, Map<String, Object> attributes, DataRequestMonitor<IBreakpointDMContext> drm) {
// Validate the context
if (context == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
drm.done();
return;
}
// Select the breakpoints context map. If it doesn't exist, create it.
Map<Integer, MIBreakpointDMData> breakpointContext = fBreakpoints.get(context);
if (breakpointContext == null) {
breakpointContext = new HashMap<Integer, MIBreakpointDMData>();
fBreakpoints.put(context, breakpointContext);
}
// Validate the breakpoint type
String type = (String) attributes.get(MIBreakpoints.BREAKPOINT_TYPE);
if (type == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
drm.done();
return;
}
// And go...
if (type.equals(MIBreakpoints.BREAKPOINT)) {
addBreakpoint(context, attributes, drm);
}
else if (type.equals(MIBreakpoints.WATCHPOINT)) {
addWatchpoint(context, attributes, drm);
}
else if (type.equals(MIBreakpoints.TRACEPOINT)) {
addTracepoint(context, attributes, drm);
}
else {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
drm.done();
}
public void shutdown(RequestMonitor requestMonitor) {
unregister();
super.shutdown(requestMonitor);
}
/**
* @param map
* @param key
* @param defaultValue
* @return
*/
public Object getProperty(Map<String, Object> map, String key, Object defaultValue) {
Object value = map.get(key);
return (value != null) ? value : defaultValue;
}
/**
* @param attributes
* @return
*/
private String formatLocation(Map<String, Object> attributes) {
// Unlikely default location
String location = (String) getProperty(attributes, MIBreakpoints.ADDRESS, NULL_STRING);
// Get the relevant parameters
String fileName = (String) getProperty(attributes, MIBreakpoints.FILE_NAME, NULL_STRING);
Integer lineNumber = (Integer) getProperty(attributes, MIBreakpoints.LINE_NUMBER, -1);
String function = (String) getProperty(attributes, MIBreakpoints.FUNCTION, NULL_STRING);
// Fix for Bug264721
if (fileName.contains(" ")) { //$NON-NLS-1$
fileName = "\"" + fileName + "\""; //$NON-NLS-1$//$NON-NLS-2$
}
if (!fileName.equals(NULL_STRING)) {
if (lineNumber != -1) {
location = fileName + ":" + lineNumber; //$NON-NLS-1$
} else {
location = fileName + ":" + function; //$NON-NLS-1$
}
} else if (!function.equals(NULL_STRING)) {
// function location without source
location = function;
} else if (location.length() > 0) {
// address location
if (Character.isDigit(location.charAt(0))) {
// numeric address needs '*' prefix
location = '*' + location;
}
}
return location;
}
/**
* Add a breakpoint of type BREAKPOINT
* Add a breakpoint of type BREAKPOINT.
* With GDB 7.0, we can create a breakpoint that is disabled. This avoids having to disable it as
* a separate command. It is also much better because in non-stop, we don't risk habing a thread
* hitting the breakpoint between creation and disablement.
*
* @param context
* @param breakpoint
* @param drm
*/
private void addBreakpoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
@Override
protected void addBreakpoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
{
// Select the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
@ -460,7 +144,7 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
contextBreakpoints.put(reference, newBreakpoint);
// Format the return value
MIBreakpointDMContext dmc = new MIBreakpointDMContext(getSession(), new IDMContext[] { context }, reference);
MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_0.this, new IDMContext[] { context }, reference);
drm.setData(dmc);
// Flag the event
@ -488,10 +172,11 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
* @param breakpoint
* @param drm
*/
private void addTracepoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
@Override
protected void addTracepoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
{
// Select the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
@ -537,7 +222,7 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
contextBreakpoints.put(reference, newBreakpoint);
// Format the return value
MIBreakpointDMContext dmc = new MIBreakpointDMContext(getSession(), new IDMContext[] { context }, reference);
MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_0.this, new IDMContext[] { context }, reference);
drm.setData(dmc);
// Flag the event
@ -562,214 +247,20 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
});
}
/**
* Add a breakpoint of type WATCHPOINT
*
* @param context
* @param watchpoint
* @param drm
*/
private void addWatchpoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
if (contextBreakpoints == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
return;
}
// Extract the relevant parameters (providing default values to avoid potential NPEs)
String expression = (String) getProperty(attributes, MIBreakpoints.EXPRESSION, NULL_STRING);
boolean isRead = (Boolean) getProperty(attributes, MIBreakpoints.READ, false);
boolean isWrite = (Boolean) getProperty(attributes, MIBreakpoints.WRITE, false);
// The DataRequestMonitor for the add request
DataRequestMonitor<MIBreakInsertInfo> addWatchpointDRM =
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), drm) {
@Override
protected void handleSuccess() {
// With MI, an invalid location won't generate an error
if (getData().getMIBreakpoints().length == 0) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, WATCHPOINT_INSERTION_FAILURE, null));
drm.done();
return;
}
// Create a breakpoint object and store it in the map
final MIBreakpointDMData newBreakpoint = new MIBreakpointDMData(getData().getMIBreakpoints()[0]);
int reference = newBreakpoint.getNumber();
if (reference == -1) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, WATCHPOINT_INSERTION_FAILURE, null));
drm.done();
return;
}
contextBreakpoints.put(reference, newBreakpoint);
// Format the return value
MIBreakpointDMContext dmc = new MIBreakpointDMContext(getSession(), new IDMContext[] { context }, reference);
drm.setData(dmc);
// Flag the event
getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties());
// Condition, ignore count and state can not be specified at watchpoint creation time.
// Therefore, we have to update the watchpoint if any of these is present
Map<String,Object> delta = new HashMap<String,Object>();
delta.put(MIBreakpoints.CONDITION, getProperty(attributes, MIBreakpoints.CONDITION, NULL_STRING));
delta.put(MIBreakpoints.IGNORE_COUNT, getProperty(attributes, MIBreakpoints.IGNORE_COUNT, 0 ));
delta.put(MIBreakpoints.IS_ENABLED, getProperty(attributes, MIBreakpoints.IS_ENABLED, true));
modifyBreakpoint(dmc, delta, drm, false);
}
@Override
protected void handleError() {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, WATCHPOINT_INSERTION_FAILURE, null));
drm.done();
}
};
// Execute the command
fConnection.queueCommand(new MIBreakWatch(context, isRead, isWrite, expression), addWatchpointDRM);
}
//-------------------------------------------------------------------------
// removeBreakpoint
//-------------------------------------------------------------------------
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#removeBreakpoint(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext, org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
public void removeBreakpoint(final IBreakpointDMContext dmc, final RequestMonitor rm) {
// Validate the breakpoint context
if (dmc == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
return;
}
// Validate the breakpoint type
MIBreakpointDMContext breakpointCtx;
if (dmc instanceof MIBreakpointDMContext) {
breakpointCtx = (MIBreakpointDMContext) dmc;
}
else {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
rm.done();
return;
}
// Validate the target context
IBreakpointsTargetDMContext context = DMContexts.getAncestorOfType(dmc, IBreakpointsTargetDMContext.class);
if (context == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
rm.done();
return;
}
// Pick the context breakpoints map
final Map<Integer,MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
// Validate the breakpoint
final int reference = breakpointCtx.getReference();
MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
if (breakpoint == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
// Queue the command
fConnection.queueCommand(
new MIBreakDelete(context, new int[] { reference }),
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
getSession().dispatchEvent(new BreakpointRemovedEvent(dmc), getProperties());
contextBreakpoints.remove(reference);
rm.done();
}
});
}
// -------------------------------------------------------------------------
// updateBreakpoint
//-------------------------------------------------------------------------
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#updateBreakpoint(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext, java.util.Map, org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
public void updateBreakpoint(IBreakpointDMContext dmc, Map<String, Object> properties, RequestMonitor rm)
{
// Validate the breakpoint context
if (dmc == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
return;
}
// Validate the breakpoint type
MIBreakpointDMContext breakpointCtx;
if (dmc instanceof MIBreakpointDMContext) {
breakpointCtx = (MIBreakpointDMContext) dmc;
}
else {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
rm.done();
return;
}
// Validate the context
IBreakpointsTargetDMContext context = DMContexts.getAncestorOfType(dmc, IBreakpointsTargetDMContext.class);
if (context == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
rm.done();
return;
}
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
// Validate the breakpoint
final int reference = breakpointCtx.getReference();
MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
if (breakpoint == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
modifyBreakpoint(breakpointCtx, properties, rm, true);
}
/**
* @param dmc
* @param properties
* @param rm
* @param generateUpdateEvent
*/
private void modifyBreakpoint(final MIBreakpointDMContext breakpointCtx, Map<String, Object> attributes,
final RequestMonitor rm, final boolean generateUpdateEvent)
@Override
protected void modifyBreakpoint(final IBreakpointDMContext dmc, final Map<String, Object> attributes, final RequestMonitor rm, final boolean generateUpdateEvent)
{
// Use a working copy of the attributes since we are going to tamper happily with them
Map<String, Object> properties = new HashMap<String, Object>(attributes);
// Retrieve the breakpoint parameters
// At this point, we know their are OK so there is no need to re-validate
MIBreakpointDMContext breakpointCtx = (MIBreakpointDMContext) dmc;
IBreakpointsTargetDMContext context = DMContexts.getAncestorOfType(breakpointCtx, IBreakpointsTargetDMContext.class);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
final int reference = breakpointCtx.getReference();
MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
@ -777,66 +268,22 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
int numberOfChanges = 0;
final CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), rm) {
@Override
protected void handleSuccess() {
if (generateUpdateEvent)
getSession().dispatchEvent(new BreakpointUpdatedEvent(breakpointCtx), getProperties());
rm.done();
protected void handleCompleted() {
GDBBreakpoints_7_0.super.modifyBreakpoint(dmc, attributes, rm, generateUpdateEvent);
}
};
// Determine if the breakpoint condition changed
String conditionAttribute = MIBreakpoints.CONDITION;
if (properties.containsKey(conditionAttribute)) {
String oldValue = breakpoint.getCondition();
String newValue = (String) properties.get(conditionAttribute);
if (newValue == null) newValue = NULL_STRING;
if (!oldValue.equals(newValue)) {
changeCondition(context, reference, newValue, countingRm);
numberOfChanges++;
}
properties.remove(conditionAttribute);
}
// Determine if the breakpoint ignore count changed
String ignoreCountAttribute = MIBreakpoints.IGNORE_COUNT;
if (properties.containsKey(ignoreCountAttribute)) {
Integer oldValue = breakpoint.getIgnoreCount();
Integer newValue = (Integer) properties.get(ignoreCountAttribute);
if (newValue == null) newValue = 0;
if (!oldValue.equals(newValue)) {
changeIgnoreCount(context, reference, newValue, countingRm);
numberOfChanges++;
}
properties.remove(ignoreCountAttribute);
}
// Determine if the tracepoint pass count changed
String passCountAttribute = MIBreakpoints.PASS_COUNT;
if (properties.containsKey(passCountAttribute)) {
if (attributes.containsKey(passCountAttribute)) {
Integer oldValue = breakpoint.getPassCount();
Integer newValue = (Integer) properties.get(passCountAttribute);
Integer newValue = (Integer) attributes.get(passCountAttribute);
if (newValue == null) newValue = 0;
if (!oldValue.equals(newValue)) {
changePassCount(context, reference, newValue, countingRm);
numberOfChanges++;
}
properties.remove(passCountAttribute);
}
// Determine if the breakpoint state changed
String enableAttribute = MIBreakpoints.IS_ENABLED;
if (properties.containsKey(enableAttribute)) {
Boolean oldValue = breakpoint.isEnabled();
Boolean newValue = (Boolean) properties.get(enableAttribute);
if (newValue == null) newValue = false;
if (!oldValue.equals(newValue)) {
numberOfChanges++;
if (newValue)
enableBreakpoint(context, reference, countingRm);
else
disableBreakpoint(context, reference, countingRm);
}
properties.remove(enableAttribute);
attributes.remove(passCountAttribute);
}
// // Determine if the breakpoint state changed
@ -867,69 +314,6 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
// }
// return actions;
// }
/**
* Update the breakpoint condition
*
* @param context
* @param dmc
* @param condition
* @param rm
*/
private void changeCondition(final IBreakpointsTargetDMContext context,
final int reference, final String condition, final RequestMonitor rm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
return;
}
// Queue the command
fConnection.queueCommand(
new MIBreakCondition(context, reference, condition),
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
if (breakpoint == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
breakpoint.setCondition(condition);
rm.done();
}
// In case of error (new condition could not be installed for whatever reason),
// GDB "offers" different behaviours depending on its version: it can either keep
// the original condition (the right thing to do) or keep the invalid condition.
// Our sole option is to remove the condition in case of error and rely on the
// upper layer to re-install the right condition.
@Override
protected void handleError() {
MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
if (breakpoint == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
// Remove invalid condition from the back-end breakpoint
breakpoint.setCondition(NULL_STRING);
fConnection.queueCommand(
new MIBreakCondition(context, reference, NULL_STRING),
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
// The report the initial problem
protected void handleCompleted() {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, INVALID_CONDITION, null));
rm.done();
}
});
}
});
}
// private void changeActions(final IBreakpointsTargetDMContext context,
// final int reference, final IBreakpointAction[] actions, final RequestMonitor rm)
@ -972,18 +356,15 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
/**
* Update the breakpoint ignoreCount
*
* @param context
* @param reference
* @param ignoreCount
* @param rm
* Update the breakpoint ignoreCount.
* IgnoreCount is not supported by tracepoints
*/
private void changeIgnoreCount(IBreakpointsTargetDMContext context,
@Override
protected void changeIgnoreCount(IBreakpointsTargetDMContext context,
final int reference, final int ignoreCount, final RequestMonitor rm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
@ -991,29 +372,14 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
}
final MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
if (breakpoint.getBreakpointType().equals(MIBreakpoints.TRACEPOINT)) {
// Ingorecount is not supported for tracepoints
if (breakpoint == null || breakpoint.getBreakpointType().equals(MIBreakpoints.TRACEPOINT)) {
// Ignorecount is not supported for tracepoints
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, INVALID_BREAKPOINT_TYPE, null));
rm.done();
return;
}
// Queue the command
fConnection.queueCommand(
new MIBreakAfter(context, reference, ignoreCount),
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
if (breakpoint == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
breakpoint.setIgnoreCount(ignoreCount);
rm.done();
}
});
super.changeIgnoreCount(context, reference, ignoreCount, rm);
}
/**
@ -1024,11 +390,11 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
* @param ignoreCount
* @param rm
*/
private void changePassCount(IBreakpointsTargetDMContext context,
protected void changePassCount(IBreakpointsTargetDMContext context,
final int reference, final int ignoreCount, final RequestMonitor rm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
@ -1036,7 +402,7 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
}
final MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
if (breakpoint.getBreakpointType().equals(MIBreakpoints.TRACEPOINT) == false) {
if (breakpoint == null || breakpoint.getBreakpointType().equals(MIBreakpoints.TRACEPOINT) == false) {
// Passcount is just for tracepoints
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, INVALID_BREAKPOINT_TYPE, null));
rm.done();
@ -1049,86 +415,9 @@ public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoin
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
if (breakpoint == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
breakpoint.setPassCount(ignoreCount);
rm.done();
}
});
}
/**
* Enable the breakpoint
*
* @param context
* @param reference
* @param rm
*/
private void enableBreakpoint(IBreakpointsTargetDMContext context,
final int reference, final RequestMonitor rm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
return;
}
// Queue the command
fConnection.queueCommand(
new MIBreakEnable(context, new int[] { reference }),
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
if (breakpoint == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
breakpoint.setEnabled(true);
rm.done();
}
});
}
/**
* Disable the breakpoint
*
* @param context
* @param dmc
* @param rm
*/
private void disableBreakpoint(IBreakpointsTargetDMContext context,
final int reference, final RequestMonitor rm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
return;
}
// Queue the command
fConnection.queueCommand(
new MIBreakDisable(context, new int[] { reference }),
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
if (breakpoint == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
return;
}
breakpoint.setEnabled(false);
rm.done();
}
});
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 Ericsson and others.
* Copyright (c) 2007, 2010 Ericsson 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
@ -95,15 +95,49 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
private Map<IBreakpointsTargetDMContext, Map<Integer, MIBreakpointDMData>> fBreakpoints =
new HashMap<IBreakpointsTargetDMContext, Map<Integer, MIBreakpointDMData>>();
/**
* Returns a map of existing breakpoints for the specified context
*
* @since 3.0
*/
protected Map<Integer, MIBreakpointDMData> getBreakpointMap(IBreakpointsTargetDMContext ctx) {
return fBreakpoints.get(ctx);
}
/**
* Create an empty breakpoint map and store it with the specific context.
*
* @return The newly created empty map.
*
* @since 3.0
*/
protected Map<Integer, MIBreakpointDMData> createNewBreakpointMap(IBreakpointsTargetDMContext ctx) {
Map<Integer, MIBreakpointDMData> map = new HashMap<Integer, MIBreakpointDMData>();
fBreakpoints.put(ctx, map);
return map;
}
// Error messages
final String NULL_STRING = ""; //$NON-NLS-1$
final String UNKNOWN_EXECUTION_CONTEXT = "Unknown execution context"; //$NON-NLS-1$
final String UNKNOWN_BREAKPOINT_CONTEXT = "Unknown breakpoint context"; //$NON-NLS-1$
final String UNKNOWN_BREAKPOINT_TYPE = "Unknown breakpoint type"; //$NON-NLS-1$
final String UNKNOWN_BREAKPOINT = "Unknown breakpoint"; //$NON-NLS-1$
final String BREAKPOINT_INSERTION_FAILURE = "Breakpoint insertion failure"; //$NON-NLS-1$
final String WATCHPOINT_INSERTION_FAILURE = "Watchpoint insertion failure"; //$NON-NLS-1$
final String INVALID_CONDITION = "Invalid condition"; //$NON-NLS-1$
/** @since 3.0 */
public final static String NULL_STRING = ""; //$NON-NLS-1$
/** @since 3.0 */
public final static String UNKNOWN_EXECUTION_CONTEXT = "Unknown execution context"; //$NON-NLS-1$
/** @since 3.0 */
public final static String UNKNOWN_BREAKPOINT_CONTEXT = "Unknown breakpoint context"; //$NON-NLS-1$
/** @since 3.0 */
public final static String UNKNOWN_BREAKPOINT_TYPE = "Unknown breakpoint type"; //$NON-NLS-1$
/** @since 3.0 */
public final static String UNKNOWN_BREAKPOINT = "Unknown breakpoint"; //$NON-NLS-1$
/** @since 3.0 */
public final static String BREAKPOINT_INSERTION_FAILURE = "Breakpoint insertion failure"; //$NON-NLS-1$
/** @since 3.0 */
public final static String WATCHPOINT_INSERTION_FAILURE = "Watchpoint insertion failure"; //$NON-NLS-1$
/** @since 3.0 */
public final static String INVALID_CONDITION = "Invalid condition"; //$NON-NLS-1$
/** @since 3.0 */
public final static String TRACEPOINT_INSERTION_FAILURE = "Tracepoint insertion failure"; //$NON-NLS-1$
/** @since 3.0 */
public final static String INVALID_BREAKPOINT_TYPE = "Invalid breakpoint type"; //$NON-NLS-1$
///////////////////////////////////////////////////////////////////////////
@ -271,7 +305,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
// remove it from our breakpoints map.
IBreakpointsTargetDMContext bpContext = DMContexts.getAncestorOfType(e.getDMContext(), IBreakpointsTargetDMContext.class);
if (bpContext != null) {
Map<Integer, MIBreakpointDMData> contextBps = fBreakpoints.get(bpContext);
Map<Integer, MIBreakpointDMData> contextBps = getBreakpointMap(bpContext);
if (contextBps != null) {
contextBps.remove(e.getNumber());
}
@ -310,7 +344,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
// Select the breakpoints context map
// If it doesn't exist then no breakpoint was ever inserted for this breakpoint space.
// In that case, return an empty list.
final Map<Integer, MIBreakpointDMData> breakpointContext = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> breakpointContext = getBreakpointMap(context);
if (breakpointContext == null) {
drm.setData(new IBreakpointDMContext[0]);
drm.done();
@ -374,7 +408,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
}
// Select the breakpoints context map
Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
drm.done();
@ -404,10 +438,9 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
}
// Select the breakpoints context map. If it doesn't exist, create it.
Map<Integer, MIBreakpointDMData> breakpointContext = fBreakpoints.get(context);
Map<Integer, MIBreakpointDMData> breakpointContext = getBreakpointMap(context);
if (breakpointContext == null) {
breakpointContext = new HashMap<Integer, MIBreakpointDMData>();
fBreakpoints.put(context, breakpointContext);
breakpointContext = createNewBreakpointMap(context);
}
// Validate the breakpoint type
@ -425,6 +458,9 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
else if (type.equals(WATCHPOINT)) {
addWatchpoint(context, attributes, drm);
}
else if (type.equals(MIBreakpoints.TRACEPOINT)) {
addTracepoint(context, attributes, drm);
}
else {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
drm.done();
@ -444,8 +480,9 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
/**
* @param attributes
* @return
* @since 3.0
*/
private String formatLocation(Map<String, Object> attributes) {
protected String formatLocation(Map<String, Object> attributes) {
// Unlikely default location
String location = (String) getProperty(attributes, ADDRESS, NULL_STRING);
@ -486,11 +523,13 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
* @param context
* @param breakpoint
* @param drm
*
* @since 3.0
*/
private void addBreakpoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
protected void addBreakpoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
{
// Select the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
@ -561,17 +600,34 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
new MIBreakInsert(context, isTemporary, isHardware, condition, ignoreCount, location, tid), addBreakpointDRM);
}
/**
* Add a tracepoint. Currently not supported in this version, but only in our GDB 7.0 version.
*
* @param context
* @param attributes
* @param drm
*
* @since 3.0
*/
protected void addTracepoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm) {
// Not supported
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
drm.done();
}
/**
* Add a breakpoint of type WATCHPOINT
*
* @param context
* @param watchpoint
* @param drm
* @since 3.0
*/
private void addWatchpoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
protected void addWatchpoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
@ -669,7 +725,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
}
// Pick the context breakpoints map
final Map<Integer,MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer,MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
@ -736,7 +792,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
}
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
rm.done();
@ -760,8 +816,10 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
* @param properties
* @param rm
* @param generateUpdateEvent
*
* @since 3.0
*/
private void modifyBreakpoint(final IBreakpointDMContext dmc, Map<String, Object> attributes, final RequestMonitor rm, final boolean generateUpdateEvent)
protected void modifyBreakpoint(final IBreakpointDMContext dmc, Map<String, Object> attributes, final RequestMonitor rm, final boolean generateUpdateEvent)
{
// Use a working copy of the attributes since we are going to tamper happily with them
Map<String, Object> properties = new HashMap<String, Object>(attributes);
@ -770,7 +828,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
// At this point, we know their are OK so there is no need to re-validate
MIBreakpointDMContext breakpointCtx = (MIBreakpointDMContext) dmc;
IBreakpointsTargetDMContext context = DMContexts.getAncestorOfType(dmc, IBreakpointsTargetDMContext.class);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
final int reference = breakpointCtx.getReference();
MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
@ -838,12 +896,14 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
* @param dmc
* @param condition
* @param rm
*
* @since 3.0
*/
private void changeCondition(final IBreakpointsTargetDMContext context,
protected void changeCondition(final IBreakpointsTargetDMContext context,
final int reference, final String condition, final RequestMonitor rm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
@ -903,12 +963,14 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
* @param reference
* @param ignoreCount
* @param rm
*
* @since 3.0
*/
private void changeIgnoreCount(IBreakpointsTargetDMContext context,
protected void changeIgnoreCount(IBreakpointsTargetDMContext context,
final int reference, final int ignoreCount, final RequestMonitor rm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
@ -939,12 +1001,14 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
* @param context
* @param reference
* @param rm
*
* @since 3.0
*/
private void enableBreakpoint(IBreakpointsTargetDMContext context,
protected void enableBreakpoint(IBreakpointsTargetDMContext context,
final int reference, final RequestMonitor rm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();
@ -975,12 +1039,14 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
* @param context
* @param dmc
* @param rm
*
* @since 3.0
*/
private void disableBreakpoint(IBreakpointsTargetDMContext context,
protected void disableBreakpoint(IBreakpointsTargetDMContext context,
final int reference, final RequestMonitor rm)
{
// Pick the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
rm.done();

View file

@ -50,7 +50,6 @@ public class MIBreakInsertInfo extends MIInfo {
} else if (var.equals("bkpt")) { //$NON-NLS-1$
if (val instanceof MITuple) {
bpt = new MIBreakpoint((MITuple)val);
bpt.setEnabled(true);
}
} else if (var.equals("hw-awpt")) { //$NON-NLS-1$
if (val instanceof MITuple) {