diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl.java index bb850260199..26f666b03c5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl.java @@ -41,6 +41,7 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MIEvent; import org.eclipse.cdt.dsf.mi.service.command.events.MIInferiorExitEvent; import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; import org.eclipse.cdt.dsf.mi.service.command.events.MIThreadExitEvent; +import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfSession; @@ -259,6 +260,55 @@ public class GDBRunControl extends MIRunControl { canResume(context, rm); } + /** @since 3.0 */ + @Override + public void runToLocation(IExecutionDMContext context, final String location, final boolean skipBreakpoints, final RequestMonitor rm){ + assert context != null; + + final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); + if (dmc == null){ + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Given context: " + context + " is not an execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$ + rm.done(); + return; + } + + if (doCanResume(dmc)) { + IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class); + getConnection().queueCommand( + fCommandFactory.createMIBreakInsert(bpDmc, true, false, null, 0, + location, dmc.getThreadId()), + new DataRequestMonitor(getExecutor(), rm) { + @Override + public void handleSuccess() { + // We must set are RunToLineActiveOperation *before* we do the resume + // or else we may get the stopped event, before we have set this variable. + int bpId = getData().getMIBreakpoints()[0].getNumber(); + String addr = getData().getMIBreakpoints()[0].getAddress(); + fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, location, addr, skipBreakpoints); + + resume(dmc, new RequestMonitor(getExecutor(), rm) { + @Override + public void handleFailure() { + IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(fRunToLineActiveOperation.getThreadContext(), + IBreakpointsTargetDMContext.class); + int bpId = fRunToLineActiveOperation.getBreakointId(); + + getConnection().queueCommand(fCommandFactory.createMIBreakDelete(bpDmc, new int[] {bpId}), + new DataRequestMonitor(getExecutor(), null)); + fRunToLineActiveOperation = null; + + super.handleFailure(); + } + }); + } + }); + } else { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, + "Cannot resume given DMC.", null)); //$NON-NLS-1$ + rm.done(); + } + } + /** * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0.java index a9580f53fb7..772d28ac953 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0.java @@ -41,6 +41,7 @@ import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; import org.eclipse.cdt.dsf.mi.service.command.events.MIBreakpointHitEvent; import org.eclipse.cdt.dsf.mi.service.command.events.MIInferiorExitEvent; import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; +import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfSession; @@ -431,6 +432,89 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro }); } + /** @since 3.0 */ + @Override + public void runToLocation(final IExecutionDMContext context, final String location, final boolean skipBreakpoints, final RequestMonitor rm){ + + assert context != null; + + final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); + if (dmc == null){ + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Given context: " + context + " is not an execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$ + rm.done(); + return; + } + + if (doCanResume(dmc)) { + IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class); + getConnection().queueCommand( + fCommandFactory.createMIBreakInsert(bpDmc, true, false, null, 0, + location, dmc.getThreadId()), + new DataRequestMonitor(getExecutor(), rm) { + @Override + public void handleSuccess() { + // We must set are RunToLineActiveOperation *before* we do the resume + // or else we may get the stopped event, before we have set this variable. + int bpId = getData().getMIBreakpoints()[0].getNumber(); + String addr = getData().getMIBreakpoints()[0].getAddress(); + fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, location, addr, skipBreakpoints); + + resume(dmc, new RequestMonitor(getExecutor(), rm) { + @Override + public void handleFailure() { + IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(fRunToLineActiveOperation.getThreadContext(), + IBreakpointsTargetDMContext.class); + int bpId = fRunToLineActiveOperation.getBreakointId(); + + getConnection().queueCommand(fCommandFactory.createMIBreakDelete(bpDmc, new int[] {bpId}), + new DataRequestMonitor(getExecutor(), null)); + fRunToLineActiveOperation = null; + + super.handleFailure(); + } + }); + } + }); + } else { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, + "Cannot resume given DMC.", null)); //$NON-NLS-1$ + rm.done(); + } + } + + /** @since 3.0 */ + @Override + public void resumeAtLocation(IExecutionDMContext context, String location, RequestMonitor rm) { + assert context != null; + + final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); + if (dmc == null){ + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Given context: " + context + " is not an thread execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$ + rm.done(); + return; + } + + if (doCanResume(dmc)) { + setResumePending(true); + getCache().setContextAvailable(dmc, false); + getConnection().queueCommand( + fCommandFactory.createMIExecJump(dmc, location), + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleFailure() { + setResumePending(false); + getCache().setContextAvailable(dmc, true); + + super.handleFailure(); + } + }); + } else { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, + "Cannot resume given DMC.", null)); //$NON-NLS-1$ + rm.done(); + } + } + /** * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java index 840ba87770b..ae7d0bbd3e4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java @@ -726,7 +726,8 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I rm.done(); } - private void runToLocation(IExecutionDMContext context, String location, boolean skipBreakpoints, final RequestMonitor rm){ + /** @since 3.0 */ + protected void runToLocation(IExecutionDMContext context, String location, boolean skipBreakpoints, final RequestMonitor rm){ // skipBreakpoints is not used at the moment. Implement later assert context != null; @@ -750,7 +751,8 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I } } - private void resumeAtLocation(IExecutionDMContext context, String location, RequestMonitor rm) { + /** @since 3.0 */ + protected void resumeAtLocation(IExecutionDMContext context, String location, RequestMonitor rm) { assert context != null; final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); @@ -1004,21 +1006,22 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I rm.done(); } else - { - // Create the breakpoint attributes - Map attr = new HashMap(); - attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); - attr.put(MIBreakpoints.FILE_NAME, sourceFile); - attr.put(MIBreakpoints.LINE_NUMBER, lineNumber); - attr.put(MIBreakpointDMData.IS_TEMPORARY, true); - attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); - - // Now do the operation + { String location = sourceFile + ":" + lineNumber; //$NON-NLS-1$ if (resume) resumeAtLocation(context, location, rm); - else + else { + // Create the breakpoint attributes + Map attr = new HashMap(); + attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); + attr.put(MIBreakpoints.FILE_NAME, sourceFile); + attr.put(MIBreakpoints.LINE_NUMBER, lineNumber); + attr.put(MIBreakpointDMData.IS_TEMPORARY, true); + attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); + + // Now do the operation moveToLocation(context, location, attr, rm); + } } } @@ -1048,19 +1051,20 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I } else { - // Create the breakpoint attributes - Map attr = new HashMap(); - attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); - attr.put(MIBreakpoints.ADDRESS, "0x" + address.toString(16)); //$NON-NLS-1$ - attr.put(MIBreakpointDMData.IS_TEMPORARY, true); - attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); - - // Now do the operation String location = "*0x" + address.toString(16); //$NON-NLS-1$ if (resume) resumeAtLocation(context, location, rm); - else + else { + // Create the breakpoint attributes + Map attr = new HashMap(); + attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); + attr.put(MIBreakpoints.ADDRESS, "0x" + address.toString(16)); //$NON-NLS-1$ + attr.put(MIBreakpointDMData.IS_TEMPORARY, true); + attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); + + // Now do the operation moveToLocation(context, location, attr, rm); + } } } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/ResumeAtLine.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/ResumeAtLine.java index 7e42df3c305..3d7fa080556 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/ResumeAtLine.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/ResumeAtLine.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.debug.core.model.IResumeAtAddress; import org.eclipse.cdt.debug.core.model.IResumeAtLine; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.Query; import org.eclipse.cdt.dsf.debug.service.IRunControl2; import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext; @@ -95,8 +94,7 @@ public class ResumeAtLine implements IResumeAtLine, IResumeAtAddress { IRunControl2 runControl = tracker.getService(IRunControl2.class); if (runControl != null) { runControl.moveToLine( - fContext, fileName, lineNumber, true, - new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + fContext, fileName, lineNumber, true, rm); } else { rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ rm.done(); @@ -114,7 +112,7 @@ public class ResumeAtLine implements IResumeAtLine, IResumeAtAddress { exception = e; } if (exception != null) { - throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing move to line", exception)); //$NON-NLS-1$ + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Failed executing move to line", exception)); //$NON-NLS-1$ } } else { throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ @@ -165,8 +163,7 @@ public class ResumeAtLine implements IResumeAtLine, IResumeAtAddress { IRunControl2 runControl = tracker.getService(IRunControl2.class); if (runControl != null) { runControl.moveToAddress( - fContext, address, true, - new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + fContext, address, true, rm); } else { rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ rm.done(); @@ -184,7 +181,7 @@ public class ResumeAtLine implements IResumeAtLine, IResumeAtAddress { exception = e; } if (exception != null) { - throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing move to line", exception)); //$NON-NLS-1$ + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Failed executing move to line", exception)); //$NON-NLS-1$ } } else { throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RunToLine.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RunToLine.java index 314bbbb1dac..e9fec4b7112 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RunToLine.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RunToLine.java @@ -19,7 +19,6 @@ import org.eclipse.cdt.debug.core.model.IRunToAddress; import org.eclipse.cdt.debug.core.model.IRunToLine; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.Query; import org.eclipse.cdt.dsf.debug.service.IRunControl2; import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext; @@ -98,8 +97,7 @@ public class RunToLine implements IRunToLine, IRunToAddress { IRunControl2 runControl = tracker.getService(IRunControl2.class); if (runControl != null) { runControl.runToLine( - fContext, fileName, lineNumber, skipBreakpoints, - new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + fContext, fileName, lineNumber, skipBreakpoints, rm); } else { rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ rm.done(); @@ -117,7 +115,7 @@ public class RunToLine implements IRunToLine, IRunToAddress { exception = e; } if (exception != null) { - throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing run to line", exception)); //$NON-NLS-1$ + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Failed executing run to line", exception)); //$NON-NLS-1$ } } else { throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ @@ -167,8 +165,7 @@ public class RunToLine implements IRunToLine, IRunToAddress { IRunControl2 runControl = tracker.getService(IRunControl2.class); if (runControl != null) { - runControl.runToAddress(fContext, address, skipBreakpoints, - new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + runControl.runToAddress(fContext, address, skipBreakpoints, rm); } else { rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ rm.done(); @@ -186,7 +183,7 @@ public class RunToLine implements IRunToLine, IRunToAddress { exception = e; } if (exception != null) { - throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing run to line", exception)); //$NON-NLS-1$ + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Failed executing run to line", exception)); //$NON-NLS-1$ } } else { throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$