From 409994f93ae581e5737def9030cfea6ca29d9ea8 Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Fri, 2 May 2008 22:05:46 +0000 Subject: [PATCH] [214389] - [source lookup][debug view] After terminating a suspended process, the IP remains in editor. --- .../sourcelookup/DsfSourceDisplayAdapter.java | 5 +- .../ui/viewmodel/launch/ContainerVMNode.java | 10 +-- .../provisional/launching/GdbLaunch.java | 2 +- .../launching/GdbLaunchDelegate.java | 2 +- .../service/command/GDBControl.java | 27 ++++--- .../service/command/GDBInferiorProcess.java | 4 +- .../mi/service/command/MIInferiorProcess.java | 81 ++++++++++++++++++- 7 files changed, 109 insertions(+), 22 deletions(-) diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java index d8e66e186ad..9672c47e539 100644 --- a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java +++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java @@ -539,7 +539,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay @DsfServiceEventHandler public void eventDispatched(IRunControl.IExitedDMEvent e) { - startAnnotationClearingJob(e.getDMContext()); + startAnnotationClearingJob(e.getDMContext()); } @DsfServiceEventHandler @@ -549,6 +549,9 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay @DsfServiceEventHandler public void eventDispatched(IRunControl.ISuspendedDMEvent e) { + if (e.getReason() == StateChangeReason.STEP) { + startAnnotationClearingJob(e.getDMContext()); + } fPrevModelContext = null; } } diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java index f5de55bb1e4..9b8249d722b 100644 --- a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java +++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java @@ -31,7 +31,7 @@ import org.eclipse.dd.gdb.internal.provisional.service.GDBRunControl; import org.eclipse.dd.gdb.internal.provisional.service.GDBRunControl.GDBProcessData; import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl; import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControlDMContext; -import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.StartedEvent; +import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.GDBStartedEvent; import org.eclipse.dd.mi.service.command.AbstractMIControl; import org.eclipse.dd.mi.service.command.MIControlDMContext; import org.eclipse.dd.mi.service.command.events.MIInferiorExitEvent; @@ -121,13 +121,13 @@ public class ContainerVMNode extends AbstractDMVMNode e instanceof IRunControl.IContainerSuspendedDMEvent) { return IModelDelta.CONTENT; - } else if (e instanceof GDBControl.ExitedEvent || + } else if (e instanceof GDBControl.GDBExitedEvent || e instanceof MIInferiorExitEvent || e instanceof MIInferiorSignalExitEvent) { return IModelDelta.CONTENT; } - if (e instanceof StartedEvent) { + if (e instanceof GDBStartedEvent) { return IModelDelta.EXPAND | IModelDelta.SELECT; } return IModelDelta.NO_CHANGE; @@ -144,13 +144,13 @@ public class ContainerVMNode extends AbstractDMVMNode if (containerCtx != null) { parentDelta.addNode(createVMContext(containerCtx), IModelDelta.CONTENT); } - } else if (e instanceof GDBControl.ExitedEvent || + } else if (e instanceof GDBControl.GDBExitedEvent || e instanceof MIInferiorExitEvent || e instanceof MIInferiorSignalExitEvent) { parentDelta.addNode(createVMContext(((IDMEvent)e).getDMContext()), IModelDelta.CONTENT); } - if (e instanceof StartedEvent) { + if (e instanceof GDBStartedEvent) { parentDelta.addNode(createVMContext(((IDMEvent)e).getDMContext()), IModelDelta.EXPAND | IModelDelta.SELECT); } diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunch.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunch.java index e5e23be05c5..f424521c0e1 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunch.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunch.java @@ -174,7 +174,7 @@ public class GdbLaunch extends Launch /////////////////////////////////////////////////////////////////////////// // IServiceEventListener - @DsfServiceEventHandler public void eventDispatched(GDBControl.ExitedEvent event) { + @DsfServiceEventHandler public void eventDispatched(GDBControl.GDBExitedEvent event) { shutdownSession(new RequestMonitor(ImmediateExecutor.getInstance(), null)); } diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java index 19e62f5d6ef..a80d5da09ab 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java @@ -143,7 +143,7 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate // The initializeControl method should be called after the GdbControl class has // be initialized (in the ServicesLaunchSequence above.) This is because it is the - // GdbControl class that will trigger the launch cleanup through a GDBControl.ExitedEvent + // GdbControl class that will trigger the launch cleanup through a GDBControl.GDBExitedEvent launch.initializeControl(); // Add the CLI and "inferior" process objects to the launch. diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl.java index 650fb83207a..df28c728516 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl.java @@ -50,6 +50,7 @@ import org.eclipse.dd.mi.service.command.CLIEventProcessor; import org.eclipse.dd.mi.service.command.MIControlDMContext; import org.eclipse.dd.mi.service.command.MIInferiorProcess; import org.eclipse.dd.mi.service.command.MIRunControlEventProcessor; +import org.eclipse.dd.mi.service.command.MIInferiorProcess.InferiorStartedDMEvent; import org.eclipse.dd.mi.service.command.commands.MIBreakInsert; import org.eclipse.dd.mi.service.command.commands.MICommand; import org.eclipse.dd.mi.service.command.commands.MIExecContinue; @@ -73,18 +74,17 @@ public class GDBControl extends AbstractMIControl { /** * Event indicating that the back end process process has started. */ - public static class StartedEvent extends AbstractDMEvent { - public StartedEvent(GDBControlDMContext context) { + public static class GDBStartedEvent extends AbstractDMEvent { + public GDBStartedEvent(GDBControlDMContext context) { super(context); } } - /** * Event indicating that the back end process has terminated. */ - public static class ExitedEvent extends AbstractDMEvent { - public ExitedEvent(GDBControlDMContext context) { + public static class GDBExitedEvent extends AbstractDMEvent { + public GDBExitedEvent(GDBControlDMContext context) { super(context); } } @@ -351,7 +351,16 @@ public class GDBControl extends AbstractMIControl { @Override protected void handleSuccess() { // After the break-insert is done, execute the -exec-run or -exec-continue command. - queueCommand(execCommand, new DataRequestMonitor(getExecutor(), requestMonitor)); + queueCommand( + execCommand, + new DataRequestMonitor(getExecutor(), requestMonitor) { + @Override + protected void handleSuccess() { + getSession().dispatchEvent( + new InferiorStartedDMEvent(getGDBDMContext()), getProperties()); + super.handleSuccess(); + } + }); } }); } @@ -406,7 +415,7 @@ public class GDBControl extends AbstractMIControl { } @DsfServiceEventHandler - public void eventDispatched(ExitedEvent e) { + public void eventDispatched(GDBExitedEvent e) { // Handle our "GDB Exited" event and stop processing commands. stopCommandProcessing(); } @@ -433,7 +442,7 @@ public class GDBControl extends AbstractMIControl { Thread.interrupted(); } finally { fExited = true; - getSession().dispatchEvent(new ExitedEvent(fControlDmc) {}, getProperties()); + getSession().dispatchEvent(new GDBExitedEvent(fControlDmc) {}, getProperties()); } } } @@ -705,7 +714,7 @@ public class GDBControl extends AbstractMIControl { public void initialize(final RequestMonitor requestMonitor) { getSession().addServiceEventListener(GDBControl.this, null); register(new String[]{ ICommandControl.class.getName(), AbstractMIControl.class.getName() }, new Hashtable()); - getSession().dispatchEvent(new StartedEvent(getGDBDMContext()), getProperties()); + getSession().dispatchEvent(new GDBStartedEvent(getGDBDMContext()), getProperties()); requestMonitor.done(); } diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBInferiorProcess.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBInferiorProcess.java index c556a1dafee..907c134e1eb 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBInferiorProcess.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBInferiorProcess.java @@ -27,11 +27,11 @@ class GDBInferiorProcess extends MIInferiorProcess { public GDBInferiorProcess(GDBControl commandControl, PTY p) { - super(commandControl, p); + super(commandControl, commandControl.getGDBDMContext(), p); } public GDBInferiorProcess(GDBControl commandControl, OutputStream gdbOutputStream) { - super(commandControl, gdbOutputStream); + super(commandControl, commandControl.getGDBDMContext(), gdbOutputStream); } @Override diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/MIInferiorProcess.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/MIInferiorProcess.java index a25455ddbc5..893459db72a 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/MIInferiorProcess.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/MIInferiorProcess.java @@ -32,6 +32,10 @@ import org.eclipse.dd.dsf.concurrent.DsfRunnable; import org.eclipse.dd.dsf.concurrent.IDsfStatusConstants; import org.eclipse.dd.dsf.concurrent.ImmediateExecutor; import org.eclipse.dd.dsf.concurrent.Query; +import org.eclipse.dd.dsf.datamodel.AbstractDMEvent; +import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext; +import org.eclipse.dd.dsf.debug.service.IRunControl.IExitedDMEvent; +import org.eclipse.dd.dsf.debug.service.IRunControl.IStartedDMEvent; import org.eclipse.dd.dsf.debug.service.command.ICommandListener; import org.eclipse.dd.dsf.debug.service.command.ICommandResult; import org.eclipse.dd.dsf.debug.service.command.ICommandToken; @@ -62,6 +66,31 @@ import org.eclipse.dd.mi.service.command.output.MIValue; public class MIInferiorProcess extends Process implements IEventListener, ICommandListener { + + /** + * Event indicating that the GDB inferior process has started. This event + * implements the {@link IStartedMDEvent} from the IRunControl service. + */ + public static class InferiorStartedDMEvent extends AbstractDMEvent + implements IStartedDMEvent + { + public InferiorStartedDMEvent(IExecutionDMContext context) { + super(context); + } + } + + /** + * Event indicating that the GDB inferior process has exited. This event + * implements the {@link IExitedMDEvent} from the IRunControl service. + */ + public static class InferiorExitedDMEvent extends AbstractDMEvent + implements IExitedDMEvent + { + public InferiorExitedDMEvent(IExecutionDMContext context) { + super(context); + } + } + public enum State { RUNNING, STOPPED, TERMINATED } private final OutputStream fOutputStream; @@ -77,6 +106,8 @@ public class MIInferiorProcess extends Process private final AbstractMIControl fCommandControl; + private final IExecutionDMContext fExecutionDMContext; + @ConfinedToDsfExecutor("fSession#getExecutor") private boolean fDisposed = false; @@ -100,20 +131,59 @@ public class MIInferiorProcess extends Process int inferiorPID; + /** + * Creates an inferior process object which uses the given output stream + * to write the user standard input into. + * + * @param commandControl Command control that this inferior process belongs to. + * @param inferiorExecCtx The execution context controlling the execution + * state of the inferior process. + * @param gdbOutputStream The output stream to use to write user IO into. + */ @ConfinedToDsfExecutor("fSession#getExecutor") + public MIInferiorProcess(AbstractMIControl commandControl, IExecutionDMContext inferiorExecCtx, OutputStream gdbOutputStream) { + this(commandControl, inferiorExecCtx, gdbOutputStream, null); + } + + /** + * @deprecated {@link #MIInferiorProcess(AbstractMIControl, IExecutionDMContext, OutputStream)} + * should be used instead. + */ + @ConfinedToDsfExecutor("fSession#getExecutor") + @Deprecated public MIInferiorProcess(AbstractMIControl commandControl, OutputStream gdbOutputStream) { - this(commandControl, gdbOutputStream, null); + this(commandControl, null, gdbOutputStream, null); } + /** + * Creates an inferior process object which uses the given terminal + * to write the user standard input into. + * + * @param commandControl Command control that this inferior process belongs to. + * @param inferiorExecCtx The execution context controlling the execution + * state of the inferior process. + * @param p The terminal to use to write user IO into. + */ @ConfinedToDsfExecutor("fSession#getExecutor") + public MIInferiorProcess(AbstractMIControl commandControl, IExecutionDMContext inferiorExecCtx, PTY p) { + this(commandControl, inferiorExecCtx, null, p); + } + + /** + * @deprecated Should use {@link #MIInferiorProcess(AbstractMIControl, IExecutionDMContext, PTY)} + * instead. + */ + @ConfinedToDsfExecutor("fSession#getExecutor") + @Deprecated public MIInferiorProcess(AbstractMIControl commandControl, PTY p) { - this(commandControl, null, p); + this(commandControl, null, null, p); } @ConfinedToDsfExecutor("fSession#getExecutor") - private MIInferiorProcess(AbstractMIControl commandControl, final OutputStream gdbOutputStream, PTY p) { + private MIInferiorProcess(AbstractMIControl commandControl, IExecutionDMContext execCtx, final OutputStream gdbOutputStream, PTY p) { fCommandControl = commandControl; fSession = commandControl.getSession(); + fExecutionDMContext = execCtx; commandControl.addEventListener(this); commandControl.addCommandListener(this); @@ -327,6 +397,11 @@ public class MIInferiorProcess extends Process if (fState == State.TERMINATED) return; fState = state; if (fState == State.TERMINATED) { + if (fExecutionDMContext != null) { + getSession().dispatchEvent( + new InferiorExitedDMEvent(fExecutionDMContext), + fCommandControl.getProperties()); + } closeIO(); } notifyAll();