diff options
author | Pawel Piech | 2012-01-31 05:49:01 +0000 |
---|---|---|
committer | Pawel Piech | 2012-02-08 19:53:55 +0000 |
commit | 1dbaf3c1baad7a1fd713b8b2c211f13d442eda7a (patch) | |
tree | 493564c60f145d67c57e123b7d30ff8b91da64fb /dsf/org.eclipse.cdt.examples.dsf.pda | |
parent | b9255e88a54c84de5af5774cecb4bdad0373e5fa (diff) | |
download | org.eclipse.cdt-1dbaf3c1baad7a1fd713b8b2c211f13d442eda7a.tar.gz org.eclipse.cdt-1dbaf3c1baad7a1fd713b8b2c211f13d442eda7a.tar.xz org.eclipse.cdt-1dbaf3c1baad7a1fd713b8b2c211f13d442eda7a.zip |
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)
Diffstat (limited to 'dsf/org.eclipse.cdt.examples.dsf.pda')
4 files changed, 117 insertions, 17 deletions
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; } + } |