1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

[265181] Cleanup in the case a resume or step command fails to execute.

This commit is contained in:
Marc Khouzam 2009-02-17 16:34:28 +00:00
parent 0465eb3d20
commit 022068033d
2 changed files with 72 additions and 59 deletions

View file

@ -195,13 +195,8 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
}
/** @since 2.0 */
public void reverseResume(IExecutionDMContext context, final RequestMonitor rm) {
public void reverseResume(final IExecutionDMContext context, final RequestMonitor rm) {
if (fReverseModeEnabled && doCanResume(context)) {
setResumePending(true);
// Cygwin GDB will accept commands and execute them after the step
// which is not what we want, so mark the target as unavailable
// as soon as we send a resume command.
getCache().setContextAvailable(context, false);
MIExecReverseContinue cmd = null;
if (context instanceof IContainerDMContext) {
cmd = new MIExecReverseContinue(context);
@ -214,20 +209,31 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
}
cmd = new MIExecReverseContinue(dmc);
}
// getConnection().queueCommand(cmd, new DataRequestMonitor<MIInfo>(getExecutor(), rm));
setResumePending(true);
// Cygwin GDB will accept commands and execute them after the step
// which is not what we want, so mark the target as unavailable
// as soon as we send a resume command.
getCache().setContextAvailable(context, false);
// temporary
final MIExecReverseContinue finalcmd = cmd;
final IExecutionDMContext finaldmc = context;
getConnection().queueCommand(
new RawCommand(finaldmc, "set exec-direction reverse"),
new RawCommand(finaldmc, "set exec-direction reverse"), //$NON-NLS-1$
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
public void handleSuccess() {
getConnection().queueCommand(finalcmd, new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
public void handleCompleted() {
if (!isSuccess()) {
setResumePending(false);
getCache().setContextAvailable(context, true);
}
getConnection().queueCommand(
new RawCommand(finaldmc, "set exec-direction forward"),
new RawCommand(finaldmc, "set exec-direction forward"), //$NON-NLS-1$
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
}
});
@ -242,7 +248,7 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
}
/** @since 2.0 */
public void reverseStep(IExecutionDMContext context, StepType stepType, final RequestMonitor rm) {
public void reverseStep(final IExecutionDMContext context, StepType stepType, final RequestMonitor rm) {
assert context != null;
IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
@ -258,9 +264,6 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
return;
}
setResumePending(true);
fReverseStepping = true;
getCache().setContextAvailable(context, false);
MICommand<MIInfo> cmd = null;
switch(stepType) {
case STEP_INTO:
@ -295,21 +298,31 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
default:
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Given step type not supported", null)); //$NON-NLS-1$
rm.done();
return;
}
setResumePending(true);
fReverseStepping = true;
getCache().setContextAvailable(context, false);
// temporary
final MICommand<MIInfo> finalcmd = cmd;
final IExecutionDMContext finaldmc = context;
getConnection().queueCommand(
new RawCommand(finaldmc, "set exec-direction reverse"),
new RawCommand(finaldmc, "set exec-direction reverse"), //$NON-NLS-1$
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
public void handleSuccess() {
getConnection().queueCommand(finalcmd, new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
public void handleCompleted() {
if (!isSuccess()) {
setResumePending(false);
fReverseStepping = false;
getCache().setContextAvailable(context, true);
}
getConnection().queueCommand(
new RawCommand(finaldmc, "set exec-direction forward"),
new RawCommand(finaldmc, "set exec-direction forward"), //$NON-NLS-1$
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
}
});

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.dsf.debug.service.command.CommandCache;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecContinue;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecFinish;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecInterrupt;
@ -506,33 +507,38 @@ public class MIRunControl extends AbstractDsfService implements IRunControl, ICa
return !fTerminated && fStepping;
}
public void resume(IExecutionDMContext context, final RequestMonitor rm) {
public void resume(final IExecutionDMContext context, final RequestMonitor rm) {
assert context != null;
if (doCanResume(context)) {
fResumePending = true;
// Cygwin GDB will accept commands and execute them after the step
// which is not what we want, so mark the target as unavailable
// as soon as we send a resume command.
fMICommandCache.setContextAvailable(context, false);
MIExecContinue cmd = null;
if(context instanceof IContainerDMContext)
if(context instanceof IContainerDMContext) {
cmd = new MIExecContinue(context);
else{
} else {
IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
if (dmc == null){
if (dmc == null) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE, "Given context: " + context + " is not an execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$
rm.done();
return;
}
cmd = new MIExecContinue(dmc);//, new String[0]);
}
fResumePending = true;
// Cygwin GDB will accept commands and execute them after the step
// which is not what we want, so mark the target as unavailable
// as soon as we send a resume command.
fMICommandCache.setContextAvailable(context, false);
fConnection.queueCommand(
cmd,
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
rm.done();
protected void handleFailure() {
fResumePending = false;
fMICommandCache.setContextAvailable(context, true);
super.handleFailure();
}
}
);
@ -559,15 +565,7 @@ public class MIRunControl extends AbstractDsfService implements IRunControl, ICa
}
cmd = new MIExecInterrupt(dmc);
}
fConnection.queueCommand(
cmd,
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
rm.done();
}
}
);
fConnection.queueCommand(cmd, new DataRequestMonitor<MIInfo>(getExecutor(), rm));
} else {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Given context: " + context + ", is already suspended.", null)); //$NON-NLS-1$ //$NON-NLS-2$
rm.done();
@ -583,7 +581,7 @@ public class MIRunControl extends AbstractDsfService implements IRunControl, ICa
canResume(context, rm);
}
public void step(IExecutionDMContext context, StepType stepType, final RequestMonitor rm) {
public void step(final IExecutionDMContext context, StepType stepType, final RequestMonitor rm) {
assert context != null;
IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
@ -599,18 +597,13 @@ public class MIRunControl extends AbstractDsfService implements IRunControl, ICa
return;
}
fResumePending = true;
fStepping = true;
fMICommandCache.setContextAvailable(context, false);
MICommand<MIInfo> cmd = null;
switch(stepType) {
case STEP_INTO:
fConnection.queueCommand(
new MIExecStep(dmc, 1), new DataRequestMonitor<MIInfo>(getExecutor(), rm) {}
);
cmd = new MIExecStep(dmc, 1);
break;
case STEP_OVER:
fConnection.queueCommand(
new MIExecNext(dmc), new DataRequestMonitor<MIInfo>(getExecutor(), rm) {});
cmd = new MIExecNext(dmc);
break;
case STEP_RETURN:
// The -exec-finish command operates on the selected stack frame, but here we always
@ -622,27 +615,40 @@ public class MIRunControl extends AbstractDsfService implements IRunControl, ICa
MIStack stackService = getServicesTracker().getService(MIStack.class);
if (stackService != null) {
IFrameDMContext topFrameDmc = stackService.createFrameDMContext(dmc, 0);
fConnection.queueCommand(
new MIExecFinish(topFrameDmc), new DataRequestMonitor<MIInfo>(getExecutor(), rm) {});
cmd = new MIExecFinish(topFrameDmc);
} else {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Cannot create context for command, stack service not available.", null)); //$NON-NLS-1$
rm.done();
return;
}
break;
case INSTRUCTION_STEP_INTO:
fConnection.queueCommand(
new MIExecStepInstruction(dmc, 1), new DataRequestMonitor<MIInfo>(getExecutor(), rm) {}
);
cmd = new MIExecStepInstruction(dmc, 1);
break;
case INSTRUCTION_STEP_OVER:
fConnection.queueCommand(
new MIExecNextInstruction(dmc, 1), new DataRequestMonitor<MIInfo>(getExecutor(), rm) {}
);
cmd = new MIExecNextInstruction(dmc, 1);
break;
default:
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Given step type not supported", null)); //$NON-NLS-1$
rm.done();
return;
}
fResumePending = true;
fStepping = true;
fMICommandCache.setContextAvailable(context, false);
fConnection.queueCommand(cmd, new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
public void handleFailure() {
fResumePending = false;
fStepping = false;
fMICommandCache.setContextAvailable(context, true);
super.handleFailure();
}
});
}
public void getExecutionContexts(final IContainerDMContext containerDmc, final DataRequestMonitor<IExecutionDMContext[]> rm) {
@ -707,13 +713,7 @@ public class MIRunControl extends AbstractDsfService implements IRunControl, ICa
fResumePending = true;
fMICommandCache.setContextAvailable(context, false);
fConnection.queueCommand(new MIExecUntil(dmc, fileName + ":" + lineNo), //$NON-NLS-1$
new DataRequestMonitor<MIInfo>(
getExecutor(), rm) {
@Override
protected void handleSuccess() {
rm.done();
}
});
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
} else {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED,
"Cannot resume given DMC.", null)); //$NON-NLS-1$