diff options
5 files changed, 150 insertions, 39 deletions
diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/BreakpointsMediator2.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/BreakpointsMediator2.java index d77e185869b..035a41991eb 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/BreakpointsMediator2.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/BreakpointsMediator2.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.dsf.debug.service; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -181,8 +182,8 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo * - Modified on breakpointChanged() * - Diminished on breakpointRemoved() */ - private Map<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>> fPlatformBPs = - new HashMap<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>>(); + private Map<IBreakpointsTargetDMContext, Map<IBreakpoint, List<ITargetBreakpointInfo>>> fPlatformBPs = + new HashMap<IBreakpointsTargetDMContext, Map<IBreakpoint, List<ITargetBreakpointInfo>>>(); /** * 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 // 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) { rm.setStatus(new Status(IStatus.ERROR, getPluginID(), INTERNAL_ERROR, "Context already initialized", null)); //$NON-NLS-1$ 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 // 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. // 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 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) { rm.setStatus(new Status(IStatus.INFO /* NOT error */, getPluginID(), INTERNAL_ERROR, "Breakpoints not installed for given context", null)); //$NON-NLS-1$ rm.done(); @@ -449,11 +450,11 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo public ITargetBreakpointInfo[] getTargetBreakpoints(IBreakpointsTargetDMContext dmc, IBreakpoint platformBp) { assert getExecutor().isInExecutorThread(); - Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc); + Map<IBreakpoint, List<ITargetBreakpointInfo>> platformBPs = fPlatformBPs.get(dmc); if (platformBPs != null) { - List<TargetBP> bpInfo = platformBPs.get(platformBp); + List<ITargetBreakpointInfo> bpInfo = platformBPs.get(platformBp); if (bpInfo != null) { return bpInfo.toArray(new ITargetBreakpointInfo[bpInfo.size()]); } @@ -475,14 +476,14 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo if (dmc != null && !dmc.equals(bpContext)) continue; - Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(bpContext); + Map<IBreakpoint, List<ITargetBreakpointInfo>> platformBPs = fPlatformBPs.get(bpContext); 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 - for (TargetBP tbp : e.getValue()) + for (ITargetBreakpointInfo tbp : e.getValue()) if(tbp.getTargetBreakpoint().equals(bp)) 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) { // 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; // 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))); } - 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 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. */ private void uninstallBreakpoint(final IBreakpointsTargetDMContext dmc, final IBreakpoint breakpoint, - final DataRequestMonitor<List<TargetBP>> drm) + final DataRequestMonitor<List<ITargetBreakpointInfo>> drm) { // 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) { drm.setStatus(new Status(IStatus.ERROR, getPluginID(), INVALID_HANDLE, "Invalid breakpoint", null)); //$NON-NLS-1$ drm.done(); return; } - final List<TargetBP> bpList = platformBPs.get(breakpoint); + final List<ITargetBreakpointInfo> bpList = platformBPs.get(breakpoint); assert bpList != null; // Only try to remove those targetBPs that are successfully installed. @@ -604,7 +605,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo int count = 0; for (int i = 0; i < bpList.size(); i++) { - final TargetBP bp = bpList.get(i); + final ITargetBreakpointInfo bp = bpList.get(i); if (bp.getTargetBreakpoint() != null) { fBreakpointsService.removeBreakpoint( bp.getTargetBreakpoint(), @@ -612,16 +613,16 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo @Override protected void handleCompleted() { // Remember result of the removal, success or failure. - bp.setStatus(getStatus()); + ((TargetBP)bp).setStatus(getStatus()); if (isSuccess()) { - bp.setTargetBreakpoint(null); + ((TargetBP)bp).setTargetBreakpoint(null); } countingRm.done(); } }); count++; } else { - bp.setStatus(Status.OK_STATUS); + ((TargetBP)bp).setStatus(Status.OK_STATUS); } } countingRm.setDoneCount(count); @@ -712,6 +713,11 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo @Override protected void handleCompleted() { 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); if (rm != null) // 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); for (IBreakpointsTargetDMContext context : updateContexts) { - List<TargetBP> targetBPs = fPlatformBPs.get(context).get(bp); + List<ITargetBreakpointInfo> targetBPs = fPlatformBPs.get(context).get(bp); if (targetBPs != null) { - for (TargetBP tbp : targetBPs) { + for (ITargetBreakpointInfo tbp : targetBPs) { // this must be an installed breakpoint. assert (tbp.getTargetBreakpoint() != null); @@ -1016,6 +1022,11 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo protected void handleCompleted() { processPendingRequests(); 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) // don't call this if "rm" is null as this will // log errors if any and pack Eclipse error @@ -1063,7 +1074,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo uninstallBreakpoint( dmc, breakpoint, - new DataRequestMonitor<List<TargetBP>>(getExecutor(), bpTargetsCountingRM) { + new DataRequestMonitor<List<ITargetBreakpointInfo>>(getExecutor(), bpTargetsCountingRM) { @Override protected void handleSuccess() { targetBPs.put(dmc, getData().toArray(new ITargetBreakpointInfo[getData().size()])); diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda/META-INF/MANIFEST.MF b/dsf/org.eclipse.cdt.examples.dsf.pda/META-INF/MANIFEST.MF index 2b3f03a1738..556e410a81e 100644 --- a/dsf/org.eclipse.cdt.examples.dsf.pda/META-INF/MANIFEST.MF +++ b/dsf/org.eclipse.cdt.examples.dsf.pda/META-INF/MANIFEST.MF @@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.variables, org.eclipse.debug.core, 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 Export-Package: org.eclipse.cdt.examples.dsf.pda, org.eclipse.cdt.examples.dsf.pda.breakpoints, diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDAServicesInitSequence.java b/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDAServicesInitSequence.java index 450de109ba6..5fa3d499afc 100644 --- a/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDAServicesInitSequence.java +++ b/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDAServicesInitSequence.java @@ -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.Sequence; 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.examples.dsf.pda.service.PDABackend; import org.eclipse.cdt.examples.dsf.pda.service.PDABreakpointAttributeTranslator; @@ -75,7 +75,7 @@ public class PDAServicesInitSequence extends Sequence { public void execute(final RequestMonitor requestMonitor) { // Create the breakpoint mediator and start tracking PDA breakpoints. - final BreakpointsMediator bpmService = new BreakpointsMediator( + final BreakpointsMediator2 bpmService = new BreakpointsMediator2( fSession, new PDABreakpointAttributeTranslator()); bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) { @Override diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDAServicesShutdownSequence.java b/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDAServicesShutdownSequence.java index 37873d6048c..ac6e81d48bb 100644 --- a/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDAServicesShutdownSequence.java +++ b/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDAServicesShutdownSequence.java @@ -14,7 +14,7 @@ import org.eclipse.cdt.dsf.concurrent.DsfExecutor; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; 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.IDsfService; import org.eclipse.cdt.examples.dsf.pda.PDAPlugin; @@ -77,7 +77,7 @@ public class PDAServicesShutdownSequence extends Sequence { new Step() { @Override public void execute(RequestMonitor requestMonitor) { - shutdownService(BreakpointsMediator.class, requestMonitor); + shutdownService(BreakpointsMediator2.class, requestMonitor); } }, new Step() { @Override diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDABreakpointAttributeTranslator.java b/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDABreakpointAttributeTranslator.java index c404806cfb8..1a082761534 100644 --- a/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDABreakpointAttributeTranslator.java +++ b/dsf/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDABreakpointAttributeTranslator.java @@ -15,9 +15,14 @@ import java.util.HashMap; import java.util.List; 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.IBreakpointAttributeTranslator; -import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext; +import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2; +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.breakpoints.PDALineBreakpoint; 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. * </p> */ -public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTranslator { +public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTranslator2 { // Arrays of common attributes between the two breakpoint types. These // 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 // need to initialize or clean up. - public void initialize(BreakpointsMediator mediator) { + public void initialize(BreakpointsMediator2 mediator) { } + public void dispose() { } - public List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled) - throws CoreException + private List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled) + 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>(); @@ -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)); } // Suppress cast warning: platform is still on Java 1.3 - @SuppressWarnings("unchecked") Map<String, Object> platformBpAttrs = marker.getAttributes(); // 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. // All other breakpoint updates will require a re-installation. 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.MODIFICATION); return !deltaCopy.isEmpty(); @@ -125,11 +177,58 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra } 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 updateBreakpointsStatus( + 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 void updateBreakpointStatus(IBreakpoint bp) { - // PDA breakpoints do not support status reporting + public Map<String, Object> convertAttributes(Map<String, Object> platformBPAttr) { + return platformBPAttr; } + } |