1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 12:55:40 +02:00

Bug 360280 - [breakpoints] Reposition breakpoints when planted on invalid line (PDA Example - Added updating of C Breakpoint status to set installed flag and update line number)

This commit is contained in:
Pawel Piech 2012-01-30 21:49:01 -08:00
parent b9255e88a5
commit 1dbaf3c1ba
5 changed files with 150 additions and 39 deletions

View file

@ -14,6 +14,7 @@
package org.eclipse.cdt.dsf.debug.service; package org.eclipse.cdt.dsf.debug.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -181,8 +182,8 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
* - Modified on breakpointChanged() * - Modified on breakpointChanged()
* - Diminished on breakpointRemoved() * - Diminished on breakpointRemoved()
*/ */
private Map<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>> fPlatformBPs = private Map<IBreakpointsTargetDMContext, Map<IBreakpoint, List<ITargetBreakpointInfo>>> fPlatformBPs =
new HashMap<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>>(); new HashMap<IBreakpointsTargetDMContext, Map<IBreakpoint, List<ITargetBreakpointInfo>>>();
/** /**
* BreakpointsTargetDMContext's that are being removed from {@link #fPlatformBPs}. * BreakpointsTargetDMContext's that are being removed from {@link #fPlatformBPs}.
@ -352,7 +353,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
// - Install the platform breakpoints on the selected target // - Install the platform breakpoints on the selected target
// Make sure a mapping for this execution context does not already exist // Make sure a mapping for this execution context does not already exist
Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc); Map<IBreakpoint, List<ITargetBreakpointInfo>> platformBPs = fPlatformBPs.get(dmc);
if (platformBPs != null) { if (platformBPs != null) {
rm.setStatus(new Status(IStatus.ERROR, getPluginID(), INTERNAL_ERROR, "Context already initialized", null)); //$NON-NLS-1$ rm.setStatus(new Status(IStatus.ERROR, getPluginID(), INTERNAL_ERROR, "Context already initialized", null)); //$NON-NLS-1$
rm.done(); rm.done();
@ -361,7 +362,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
// Create entries in the breakpoint tables for the new context. These entries should only // Create entries in the breakpoint tables for the new context. These entries should only
// be removed when this service stops tracking breakpoints for the given context. // be removed when this service stops tracking breakpoints for the given context.
fPlatformBPs.put(dmc, new HashMap<IBreakpoint, List<TargetBP>>()); fPlatformBPs.put(dmc, new HashMap<IBreakpoint, List<ITargetBreakpointInfo>>());
// Install the platform breakpoints (stored in fPlatformBPs) on the target. // Install the platform breakpoints (stored in fPlatformBPs) on the target.
// We need to use a background thread for this operation because we are // We need to use a background thread for this operation because we are
@ -391,7 +392,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
// - Remove the target breakpoints for the given DMC // - Remove the target breakpoints for the given DMC
// - Remove the given DMC from the internal maps. // - Remove the given DMC from the internal maps.
// //
Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc); Map<IBreakpoint, List<ITargetBreakpointInfo>> platformBPs = fPlatformBPs.get(dmc);
if (platformBPs == null) { if (platformBPs == null) {
rm.setStatus(new Status(IStatus.INFO /* NOT error */, getPluginID(), INTERNAL_ERROR, "Breakpoints not installed for given context", null)); //$NON-NLS-1$ rm.setStatus(new Status(IStatus.INFO /* NOT error */, getPluginID(), INTERNAL_ERROR, "Breakpoints not installed for given context", null)); //$NON-NLS-1$
rm.done(); rm.done();
@ -449,11 +450,11 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
public ITargetBreakpointInfo[] getTargetBreakpoints(IBreakpointsTargetDMContext dmc, IBreakpoint platformBp) { public ITargetBreakpointInfo[] getTargetBreakpoints(IBreakpointsTargetDMContext dmc, IBreakpoint platformBp) {
assert getExecutor().isInExecutorThread(); assert getExecutor().isInExecutorThread();
Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc); Map<IBreakpoint, List<ITargetBreakpointInfo>> platformBPs = fPlatformBPs.get(dmc);
if (platformBPs != null) if (platformBPs != null)
{ {
List<TargetBP> bpInfo = platformBPs.get(platformBp); List<ITargetBreakpointInfo> bpInfo = platformBPs.get(platformBp);
if (bpInfo != null) { if (bpInfo != null) {
return bpInfo.toArray(new ITargetBreakpointInfo[bpInfo.size()]); return bpInfo.toArray(new ITargetBreakpointInfo[bpInfo.size()]);
} }
@ -475,14 +476,14 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
if (dmc != null && !dmc.equals(bpContext)) if (dmc != null && !dmc.equals(bpContext))
continue; continue;
Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(bpContext); Map<IBreakpoint, List<ITargetBreakpointInfo>> platformBPs = fPlatformBPs.get(bpContext);
if (platformBPs != null && platformBPs.size() > 0) if (platformBPs != null && platformBPs.size() > 0)
{ {
for(Map.Entry<IBreakpoint, List<TargetBP>> e: platformBPs.entrySet()) for(Map.Entry<IBreakpoint, List<ITargetBreakpointInfo>> e: platformBPs.entrySet())
{ {
// Stop at the first occurrence // Stop at the first occurrence
for (TargetBP tbp : e.getValue()) for (ITargetBreakpointInfo tbp : e.getValue())
if(tbp.getTargetBreakpoint().equals(bp)) if(tbp.getTargetBreakpoint().equals(bp))
return e.getKey(); return e.getKey();
} }
@ -510,7 +511,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
final List<Map<String, Object>> attrsList, final DataRequestMonitor<List<TargetBP>> rm) final List<Map<String, Object>> attrsList, final DataRequestMonitor<List<TargetBP>> rm)
{ {
// Retrieve the set of breakpoints for this context // Retrieve the set of breakpoints for this context
final Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc); final Map<IBreakpoint, List<ITargetBreakpointInfo>> platformBPs = fPlatformBPs.get(dmc);
assert platformBPs != null; assert platformBPs != null;
// Ensure the breakpoint is not already installed // Ensure the breakpoint is not already installed
@ -521,7 +522,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
targetBPsAttempted.add(new TargetBP(attrsList.get(i))); targetBPsAttempted.add(new TargetBP(attrsList.get(i)));
} }
final ArrayList<TargetBP> targetBPsInstalled = new ArrayList<TargetBP>(attrsList.size()); final ArrayList<ITargetBreakpointInfo> targetBPsInstalled = new ArrayList<ITargetBreakpointInfo>(attrsList.size());
// Update the breakpoint status when all back-end breakpoints have been installed // Update the breakpoint status when all back-end breakpoints have been installed
final CountingRequestMonitor installRM = new CountingRequestMonitor(getExecutor(), rm) { final CountingRequestMonitor installRM = new CountingRequestMonitor(getExecutor(), rm) {
@ -575,17 +576,17 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
* regardless of success or failure in the removal. * regardless of success or failure in the removal.
*/ */
private void uninstallBreakpoint(final IBreakpointsTargetDMContext dmc, final IBreakpoint breakpoint, private void uninstallBreakpoint(final IBreakpointsTargetDMContext dmc, final IBreakpoint breakpoint,
final DataRequestMonitor<List<TargetBP>> drm) final DataRequestMonitor<List<ITargetBreakpointInfo>> drm)
{ {
// Remove the back-end breakpoints // Remove the back-end breakpoints
final Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc); final Map<IBreakpoint, List<ITargetBreakpointInfo>> platformBPs = fPlatformBPs.get(dmc);
if (platformBPs == null) { if (platformBPs == null) {
drm.setStatus(new Status(IStatus.ERROR, getPluginID(), INVALID_HANDLE, "Invalid breakpoint", null)); //$NON-NLS-1$ drm.setStatus(new Status(IStatus.ERROR, getPluginID(), INVALID_HANDLE, "Invalid breakpoint", null)); //$NON-NLS-1$
drm.done(); drm.done();
return; return;
} }
final List<TargetBP> bpList = platformBPs.get(breakpoint); final List<ITargetBreakpointInfo> bpList = platformBPs.get(breakpoint);
assert bpList != null; assert bpList != null;
// Only try to remove those targetBPs that are successfully installed. // Only try to remove those targetBPs that are successfully installed.
@ -604,7 +605,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
int count = 0; int count = 0;
for (int i = 0; i < bpList.size(); i++) { for (int i = 0; i < bpList.size(); i++) {
final TargetBP bp = bpList.get(i); final ITargetBreakpointInfo bp = bpList.get(i);
if (bp.getTargetBreakpoint() != null) { if (bp.getTargetBreakpoint() != null) {
fBreakpointsService.removeBreakpoint( fBreakpointsService.removeBreakpoint(
bp.getTargetBreakpoint(), bp.getTargetBreakpoint(),
@ -612,16 +613,16 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
// Remember result of the removal, success or failure. // Remember result of the removal, success or failure.
bp.setStatus(getStatus()); ((TargetBP)bp).setStatus(getStatus());
if (isSuccess()) { if (isSuccess()) {
bp.setTargetBreakpoint(null); ((TargetBP)bp).setTargetBreakpoint(null);
} }
countingRm.done(); countingRm.done();
} }
}); });
count++; count++;
} else { } else {
bp.setStatus(Status.OK_STATUS); ((TargetBP)bp).setStatus(Status.OK_STATUS);
} }
} }
countingRm.setDoneCount(count); countingRm.setDoneCount(count);
@ -712,6 +713,11 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
processPendingRequests(); processPendingRequests();
for (Map.Entry<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>> eventEntry : eventBPs.entrySet()) {
for (Map.Entry<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]> bpEntry : eventEntry.getValue().entrySet()) {
fPlatformBPs.get(bpEntry.getKey()).put(eventEntry.getKey(), Arrays.asList( bpEntry.getValue() ));
}
}
fireUpdateBreakpointsStatus(eventBPs, BreakpointEventType.ADDED); fireUpdateBreakpointsStatus(eventBPs, BreakpointEventType.ADDED);
if (rm != null) if (rm != null)
// don't call this if "rm" is null as this will // don't call this if "rm" is null as this will
@ -930,9 +936,9 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
fRunningEvents.add(bp); fRunningEvents.add(bp);
for (IBreakpointsTargetDMContext context : updateContexts) { for (IBreakpointsTargetDMContext context : updateContexts) {
List<TargetBP> targetBPs = fPlatformBPs.get(context).get(bp); List<ITargetBreakpointInfo> targetBPs = fPlatformBPs.get(context).get(bp);
if (targetBPs != null) { if (targetBPs != null) {
for (TargetBP tbp : targetBPs) { for (ITargetBreakpointInfo tbp : targetBPs) {
// this must be an installed breakpoint. // this must be an installed breakpoint.
assert (tbp.getTargetBreakpoint() != null); assert (tbp.getTargetBreakpoint() != null);
@ -1016,6 +1022,11 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
protected void handleCompleted() { protected void handleCompleted() {
processPendingRequests(); processPendingRequests();
fireUpdateBreakpointsStatus(eventBPs, BreakpointEventType.REMOVED); fireUpdateBreakpointsStatus(eventBPs, BreakpointEventType.REMOVED);
for (Map.Entry<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>> eventEntry : eventBPs.entrySet()) {
for (IBreakpointsTargetDMContext bpTarget : eventEntry.getValue().keySet()) {
fPlatformBPs.get(bpTarget).remove(eventEntry.getKey());
}
}
if (rm != null) if (rm != null)
// don't call this if "rm" is null as this will // don't call this if "rm" is null as this will
// log errors if any and pack Eclipse error // log errors if any and pack Eclipse error
@ -1063,7 +1074,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
uninstallBreakpoint( uninstallBreakpoint(
dmc, breakpoint, dmc, breakpoint,
new DataRequestMonitor<List<TargetBP>>(getExecutor(), bpTargetsCountingRM) { new DataRequestMonitor<List<ITargetBreakpointInfo>>(getExecutor(), bpTargetsCountingRM) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
targetBPs.put(dmc, getData().toArray(new ITargetBreakpointInfo[getData().size()])); targetBPs.put(dmc, getData().toArray(new ITargetBreakpointInfo[getData().size()]));

View file

@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.variables, org.eclipse.core.variables,
org.eclipse.debug.core, org.eclipse.debug.core,
org.eclipse.cdt.dsf, org.eclipse.cdt.dsf,
org.eclipse.cdt.core;bundle-version="5.0.0" org.eclipse.cdt.core;bundle-version="5.0.0",
org.eclipse.cdt.debug.core;bundle-version="7.2.0"
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.cdt.examples.dsf.pda, Export-Package: org.eclipse.cdt.examples.dsf.pda,
org.eclipse.cdt.examples.dsf.pda.breakpoints, org.eclipse.cdt.examples.dsf.pda.breakpoints,

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.examples.dsf.pda.launch;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Sequence; import org.eclipse.cdt.dsf.concurrent.Sequence;
import org.eclipse.cdt.dsf.datamodel.DataModelInitializedEvent; import org.eclipse.cdt.dsf.datamodel.DataModelInitializedEvent;
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator; import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2;
import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.examples.dsf.pda.service.PDABackend; import org.eclipse.cdt.examples.dsf.pda.service.PDABackend;
import org.eclipse.cdt.examples.dsf.pda.service.PDABreakpointAttributeTranslator; import org.eclipse.cdt.examples.dsf.pda.service.PDABreakpointAttributeTranslator;
@ -75,7 +75,7 @@ public class PDAServicesInitSequence extends Sequence {
public void execute(final RequestMonitor requestMonitor) { public void execute(final RequestMonitor requestMonitor) {
// Create the breakpoint mediator and start tracking PDA breakpoints. // Create the breakpoint mediator and start tracking PDA breakpoints.
final BreakpointsMediator bpmService = new BreakpointsMediator( final BreakpointsMediator2 bpmService = new BreakpointsMediator2(
fSession, new PDABreakpointAttributeTranslator()); fSession, new PDABreakpointAttributeTranslator());
bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) { bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
@Override @Override

View file

@ -14,7 +14,7 @@ import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Sequence; import org.eclipse.cdt.dsf.concurrent.Sequence;
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator; import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2;
import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.dsf.service.IDsfService; import org.eclipse.cdt.dsf.service.IDsfService;
import org.eclipse.cdt.examples.dsf.pda.PDAPlugin; import org.eclipse.cdt.examples.dsf.pda.PDAPlugin;
@ -77,7 +77,7 @@ public class PDAServicesShutdownSequence extends Sequence {
new Step() { new Step() {
@Override @Override
public void execute(RequestMonitor requestMonitor) { public void execute(RequestMonitor requestMonitor) {
shutdownService(BreakpointsMediator.class, requestMonitor); shutdownService(BreakpointsMediator2.class, requestMonitor);
} }
}, new Step() { }, new Step() {
@Override @Override

View file

@ -15,9 +15,14 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator; import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
import org.eclipse.cdt.dsf.debug.service.IBreakpointAttributeTranslator; import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext; import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2.BreakpointEventType;
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2.ITargetBreakpointInfo;
import org.eclipse.cdt.dsf.debug.service.IBreakpointAttributeTranslator2;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
import org.eclipse.cdt.examples.dsf.pda.PDAPlugin; import org.eclipse.cdt.examples.dsf.pda.PDAPlugin;
import org.eclipse.cdt.examples.dsf.pda.breakpoints.PDALineBreakpoint; import org.eclipse.cdt.examples.dsf.pda.breakpoints.PDALineBreakpoint;
import org.eclipse.cdt.examples.dsf.pda.breakpoints.PDAWatchpoint; import org.eclipse.cdt.examples.dsf.pda.breakpoints.PDAWatchpoint;
@ -38,7 +43,7 @@ import org.eclipse.debug.core.model.IBreakpoint;
* functionality of synchronizing target side and IDE-side breakpoint objects. * functionality of synchronizing target side and IDE-side breakpoint objects.
* </p> * </p>
*/ */
public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTranslator { public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTranslator2 {
// Arrays of common attributes between the two breakpoint types. These // Arrays of common attributes between the two breakpoint types. These
// attributes can be copied directly without translation. // attributes can be copied directly without translation.
@ -56,14 +61,60 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
// PDA breakpoints translator doesn't keep any state and it doesn't // PDA breakpoints translator doesn't keep any state and it doesn't
// need to initialize or clean up. // need to initialize or clean up.
public void initialize(BreakpointsMediator mediator) { public void initialize(BreakpointsMediator2 mediator) {
} }
public void dispose() { public void dispose() {
} }
public List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled) private List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
throws CoreException throws CoreException
{
if (bp instanceof ICLineBreakpoint) {
return getCBreakpointAttributes((ICLineBreakpoint)bp, bpManagerEnabled);
} else {
return getPDABreakpointAttributes(bp, bpManagerEnabled);
}
}
private List<Map<String, Object>> getCBreakpointAttributes(ICLineBreakpoint bp, boolean bpManagerEnabled)
throws CoreException
{
Map<String, Object> attrs = new HashMap<String, Object>();
// Check that the marker exists and retrieve its attributes.
// Due to accepted race conditions, the breakpiont marker may become null
// while this method is being invoked. In this case throw an exception
// and let the caller handle it.
IMarker marker = bp.getMarker();
if (marker == null || !marker.exists()) {
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Breakpoint marker does not exist", null));
}
// Suppress cast warning: platform is still on Java 1.3
Map<String, Object> platformBpAttrs = marker.getAttributes();
// Copy breakpoint attributes.
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_LINE_BREAKPOINT);
attrs.put(PDABreakpoints.ATTR_PROGRAM_PATH, bp.getFileName());
copyAttributes(platformBpAttrs, attrs, fgPDALineBreakpointAttributes);
// If the breakpoint manager is disabled, override the enabled attribute.
if (!bpManagerEnabled) {
attrs.put(IBreakpoint.ENABLED, false);
}
// The breakpoint mediator allows for multiple target-side breakpoints
// to be created for each IDE breakpoint. Although in case of PDA this
// feature is never used, we still have to return a list of attributes.
List<Map<String, Object>> retVal = new ArrayList<Map<String, Object>>(1);
retVal.add(attrs);
return retVal;
}
private List<Map<String, Object>> getPDABreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
throws CoreException
{ {
Map<String, Object> attrs = new HashMap<String, Object>(); Map<String, Object> attrs = new HashMap<String, Object>();
@ -76,7 +127,6 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Breakpoint marker does not exist", null)); throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Breakpoint marker does not exist", null));
} }
// Suppress cast warning: platform is still on Java 1.3 // Suppress cast warning: platform is still on Java 1.3
@SuppressWarnings("unchecked")
Map<String, Object> platformBpAttrs = marker.getAttributes(); Map<String, Object> platformBpAttrs = marker.getAttributes();
// Copy breakpoint attributes. // Copy breakpoint attributes.
@ -112,11 +162,13 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
} }
} }
public boolean canUpdateAttributes(IBreakpointDMContext bp, Map<String, Object> delta) { public boolean canUpdateAttributes(IBreakpoint bp, IBreakpointsTargetDMContext context,
Map<String, Object> attributes)
{
// PDA debugger only allows updating of the action property of the watchpoint. // PDA debugger only allows updating of the action property of the watchpoint.
// All other breakpoint updates will require a re-installation. // All other breakpoint updates will require a re-installation.
if (bp instanceof PDAWatchpoint) { if (bp instanceof PDAWatchpoint) {
Map<String, Object> deltaCopy = new HashMap<String, Object>(delta); Map<String, Object> deltaCopy = new HashMap<String, Object>(attributes);
deltaCopy.remove(PDAWatchpoint.ACCESS); deltaCopy.remove(PDAWatchpoint.ACCESS);
deltaCopy.remove(PDAWatchpoint.MODIFICATION); deltaCopy.remove(PDAWatchpoint.MODIFICATION);
return !deltaCopy.isEmpty(); return !deltaCopy.isEmpty();
@ -125,11 +177,58 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
} }
public boolean supportsBreakpoint(IBreakpoint bp) { public boolean supportsBreakpoint(IBreakpoint bp) {
return bp.getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL); return bp.getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL) ||
bp instanceof ICLineBreakpoint;
} }
public void updateBreakpointStatus(IBreakpoint bp) { public void updateBreakpointsStatus(
// PDA breakpoints do not support status reporting Map<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>> bpsInfo,
BreakpointEventType eventType)
{
for (IBreakpoint bp : bpsInfo.keySet()) {
if (!(bp instanceof ICLineBreakpoint)) {
continue;
}
ICLineBreakpoint cbp = (ICLineBreakpoint)bp;
try {
if (eventType == BreakpointEventType.ADDED) {
cbp.incrementInstallCount();
// Testing for Bug 360280 - [breakpoints] Reposition breakpoints when planted on invalid line
// if (cbp instanceof ICLineBreakpoint2) {
// ICLineBreakpoint2 lbp2 = (ICLineBreakpoint2)cbp;
// lbp2.setInstalledLineNumber(lbp2.getRequestedLine() + 1);
// }
} else if (eventType == BreakpointEventType.REMOVED) {
cbp.decrementInstallCount();
}
} catch (CoreException e) {}
}
} }
public void resolveBreakpoint(IBreakpointsTargetDMContext context, IBreakpoint breakpoint,
Map<String, Object> bpAttributes, DataRequestMonitor<List<Map<String, Object>>> drm)
{
try {
drm.setData( getBreakpointAttributes(breakpoint, true) );
} catch (CoreException e) {
drm.setStatus(e.getStatus());
}
drm.done();
}
public Map<String, Object> getAllBreakpointAttributes(IBreakpoint platformBP, boolean bpManagerEnabled)
throws CoreException
{
IMarker marker = platformBP.getMarker();
if (marker == null) {
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, "Null marker for breakpoint: " + platformBP));
}
return marker.getAttributes();
}
public Map<String, Object> convertAttributes(Map<String, Object> platformBPAttr) {
return platformBPAttr;
}
} }