From f91e2530ac5077ba527a9add28ff62c27184c587 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 17 Feb 2009 21:17:44 +0000 Subject: [PATCH] [258284] Don't allow a reverse-finish when in main() since GDB will reject it. --- .../dsf/gdb/service/GDBRunControl_7_0.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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 a270222f19f..c357ca0f6c7 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 @@ -179,13 +179,43 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro } /** @since 2.0 */ - public void canReverseStep(IExecutionDMContext context, StepType stepType, DataRequestMonitor rm) { + public void canReverseStep(final IExecutionDMContext context, StepType stepType, final DataRequestMonitor rm) { if (context instanceof IContainerDMContext) { rm.setData(false); rm.done(); return; } + if (stepType == StepType.STEP_RETURN) { + // A step return will always be done in the top stack frame. + // If the top stack frame is the only stack frame, it does not make sense + // to do a step return since GDB will reject it. + + // Until bug 256798 is fixed, the service tracker could be null + if (getServicesTracker() == null) { + // service is shutdown + rm.setData(false); + rm.done(); + return; + } + MIStack stackService = getServicesTracker().getService(MIStack.class); + if (stackService != null) { + // Check that the stack is at least two deep. + stackService.getStackDepth(context, 2, new DataRequestMonitor(getExecutor(), rm) { + @Override + public void handleCompleted() { + if (isSuccess() && getData() == 1) { + rm.setData(false); + rm.done(); + } else { + canReverseResume(context, rm); + } + } + }); + return; + } + } + canReverseResume(context, rm); }