From 2552eacead5bb11a525dd9c92c18012479241327 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 15 Sep 2008 17:48:40 +0000 Subject: [PATCH] Bug 247161 According to a GDB maintainer, GDB will not send an ^error after a ^done. Therefore we can remove this case and cleanup. --- .../ui/actions/GdbRestartCommand.java | 1 - .../service/command/GDBControl.java | 6 +-- .../service/command/GDBControl_7_0.java | 6 +-- .../service/command/IGDBControl.java | 2 - .../mi/service/command/CLIEventProcessor.java | 38 ++++------------ .../command/CLIEventProcessor_7_0.java | 43 ++----------------- 6 files changed, 15 insertions(+), 81 deletions(-) diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/GdbRestartCommand.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/GdbRestartCommand.java index bc5a65f2004..7aad59a4d8e 100644 --- a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/GdbRestartCommand.java +++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/GdbRestartCommand.java @@ -82,7 +82,6 @@ public class GdbRestartCommand implements IRestart { @Override protected void handleSuccess() { gdbControl.createInferiorProcess(); - gdbControl.resetInferior(gdbControl.getInferiorProcess()); gdbControl.restart(fLaunch, rm); } }); 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 3a91c05ded5..3d43e6b655d 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 @@ -418,10 +418,6 @@ public class GDBControl extends AbstractMIControl implements IGDBControl { return fInferiorProcess; } - public void resetInferior(MIInferiorProcess inferior) { - fCLICommandProcessor.resetInferior(inferior); - } - public boolean isGDBExited() { return fMonitorJob != null && fMonitorJob.fExited; } @@ -709,7 +705,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl { createInferiorProcess(); - fCLICommandProcessor = new CLIEventProcessor(GDBControl.this, fControlDmc, fInferiorProcess); + fCLICommandProcessor = new CLIEventProcessor(GDBControl.this, fControlDmc); fMIEventProcessor = new MIRunControlEventProcessor(GDBControl.this, fControlDmc); requestMonitor.done(); diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl_7_0.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl_7_0.java index f3f061e190b..fa235da6b3b 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl_7_0.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl_7_0.java @@ -419,10 +419,6 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { return fInferiorProcess; } - public void resetInferior(MIInferiorProcess inferior) { - fCLICommandProcessor.resetInferior(inferior); - } - public boolean isGDBExited() { return fMonitorJob != null && fMonitorJob.fExited; } @@ -710,7 +706,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { createInferiorProcess(); - fCLICommandProcessor = new CLIEventProcessor_7_0(GDBControl_7_0.this, fControlDmc, fInferiorProcess); + fCLICommandProcessor = new CLIEventProcessor_7_0(GDBControl_7_0.this, fControlDmc); fMIEventProcessor = new MIRunControlEventProcessor_7_0(GDBControl_7_0.this, fControlDmc); requestMonitor.done(); diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/IGDBControl.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/IGDBControl.java index a95e3b94eb7..a0434116746 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/IGDBControl.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/IGDBControl.java @@ -47,8 +47,6 @@ public interface IGDBControl extends ICommandControlService { MIInferiorProcess getInferiorProcess(); - public void resetInferior(MIInferiorProcess inferior); - boolean isGDBExited(); int getGDBExitCode(); diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/CLIEventProcessor.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/CLIEventProcessor.java index 75beb229b4e..0d259a1c48f 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/CLIEventProcessor.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/CLIEventProcessor.java @@ -36,7 +36,6 @@ import org.eclipse.dd.mi.service.command.commands.CLICommand; import org.eclipse.dd.mi.service.command.commands.MIInterpreterExecConsole; import org.eclipse.dd.mi.service.command.events.MIBreakpointChangedEvent; import org.eclipse.dd.mi.service.command.events.MIDetachedEvent; -import org.eclipse.dd.mi.service.command.events.MIErrorEvent; import org.eclipse.dd.mi.service.command.events.MIEvent; import org.eclipse.dd.mi.service.command.events.MIRunningEvent; import org.eclipse.dd.mi.service.command.events.MISignalChangedEvent; @@ -44,7 +43,6 @@ import org.eclipse.dd.mi.service.command.events.MIThreadCreatedEvent; import org.eclipse.dd.mi.service.command.output.MIConsoleStreamOutput; import org.eclipse.dd.mi.service.command.output.MIOOBRecord; import org.eclipse.dd.mi.service.command.output.MIOutput; -import org.eclipse.dd.mi.service.command.output.MIResultRecord; /** * GDB debugger output listener. @@ -54,18 +52,16 @@ public class CLIEventProcessor implements ICommandListener, IEventListener { private final ICommandControlService fCommandControl; - private MIInferiorProcess fInferior; private final ICommandControlDMContext fControlDmc; // Last Thread ID created private static int fLastThreadId; private final DsfServicesTracker fServicesTracker; - - public CLIEventProcessor(ICommandControlService connection, IContainerDMContext containerDmc, MIInferiorProcess inferior) { + + public CLIEventProcessor(ICommandControlService connection, ICommandControlDMContext controlDmc) { fCommandControl = connection; - fInferior = inferior; - fControlDmc = DMContexts.getAncestorOfType(containerDmc, ICommandControlDMContext.class); + fControlDmc = controlDmc; fServicesTracker = new DsfServicesTracker(MIPlugin.getBundleContext(), fCommandControl.getSession().getId()); connection.addCommandListener(this); connection.addEventListener(this); @@ -73,14 +69,19 @@ public class CLIEventProcessor fLastThreadId = 0; } + @Deprecated + public CLIEventProcessor(ICommandControlService connection, IContainerDMContext containerDmc, MIInferiorProcess inferior) { + this(connection, DMContexts.getAncestorOfType(containerDmc, ICommandControlDMContext.class)); + } + public void dispose() { fCommandControl.removeCommandListener(this); fCommandControl.removeEventListener(this); fServicesTracker.dispose(); } + @Deprecated public void resetInferior(MIInferiorProcess inferior) { - fInferior = inferior; } public void commandSent(ICommandToken token) { @@ -136,27 +137,6 @@ public class CLIEventProcessor // they completely exit the system. } } - - // GDB can send an error result following sending an OK result. - // In this case the error is routed as an event. - MIResultRecord rr = ((MIOutput)output).getMIResultRecord(); - if (rr != null) { - // Check if the state changed. - String state = rr.getResultClass(); - if (fInferior != null && "error".equals(state)) { //$NON-NLS-1$ - if (fInferior.getState() == MIInferiorProcess.State.RUNNING) { - fInferior.setState(MIInferiorProcess.State.STOPPED); - IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class); - String groupId = procService.getExecutionGroupIdFromThread(null); - - IProcessDMContext procDmc = procService.createProcessContext(fControlDmc, groupId); - IContainerDMContext processContainerDmc = procService.createExecutionGroupContext(procDmc, groupId); - fCommandControl.getSession().dispatchEvent( - MIErrorEvent.parse(processContainerDmc, rr.getToken(), rr.getMIResults(), null), - fCommandControl.getProperties()); - } - } - } } diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/CLIEventProcessor_7_0.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/CLIEventProcessor_7_0.java index 45b9f000c71..7192698b35f 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/CLIEventProcessor_7_0.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/CLIEventProcessor_7_0.java @@ -18,8 +18,6 @@ import org.eclipse.dd.dsf.concurrent.ConfinedToDsfExecutor; import org.eclipse.dd.dsf.datamodel.DMContexts; import org.eclipse.dd.dsf.datamodel.IDMContext; import org.eclipse.dd.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; -import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext; -import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.dd.dsf.debug.service.ISignals.ISignalsDMContext; import org.eclipse.dd.dsf.debug.service.command.ICommandControlService; import org.eclipse.dd.dsf.debug.service.command.ICommandListener; @@ -29,17 +27,13 @@ import org.eclipse.dd.dsf.debug.service.command.IEventListener; import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; import org.eclipse.dd.dsf.service.DsfServicesTracker; import org.eclipse.dd.mi.internal.MIPlugin; -import org.eclipse.dd.mi.service.IMIProcesses; import org.eclipse.dd.mi.service.command.commands.CLICommand; import org.eclipse.dd.mi.service.command.commands.MIInterpreterExecConsole; import org.eclipse.dd.mi.service.command.events.MIBreakpointChangedEvent; import org.eclipse.dd.mi.service.command.events.MIDetachedEvent; -import org.eclipse.dd.mi.service.command.events.MIErrorEvent; import org.eclipse.dd.mi.service.command.events.MIEvent; import org.eclipse.dd.mi.service.command.events.MIRunningEvent; import org.eclipse.dd.mi.service.command.events.MISignalChangedEvent; -import org.eclipse.dd.mi.service.command.output.MIOutput; -import org.eclipse.dd.mi.service.command.output.MIResultRecord; /** * GDB debugger output listener. @@ -49,18 +43,16 @@ public class CLIEventProcessor_7_0 implements ICommandListener, IEventListener { private final ICommandControlService fCommandControl; - private MIInferiorProcess fInferior; private final ICommandControlDMContext fControlDmc; private final DsfServicesTracker fServicesTracker; - public CLIEventProcessor_7_0(ICommandControlService connection, IContainerDMContext containerDmc, MIInferiorProcess inferior) { + public CLIEventProcessor_7_0(ICommandControlService connection, ICommandControlDMContext controlDmc) { fCommandControl = connection; - fInferior = inferior; - fControlDmc = DMContexts.getAncestorOfType(containerDmc, ICommandControlDMContext.class); + fControlDmc = controlDmc; fServicesTracker = new DsfServicesTracker(MIPlugin.getBundleContext(), fCommandControl.getSession().getId()); - connection.addCommandListener(this); - connection.addEventListener(this); + fCommandControl.addCommandListener(this); + fCommandControl.addEventListener(this); } public void dispose() { @@ -68,10 +60,6 @@ public class CLIEventProcessor_7_0 fCommandControl.removeEventListener(this); fServicesTracker.dispose(); } - - public void resetInferior(MIInferiorProcess inferior) { - fInferior = inferior; - } public void commandSent(ICommandToken token) { if (token.getCommand() instanceof CLICommand) { @@ -100,29 +88,6 @@ public class CLIEventProcessor_7_0 } public void eventReceived(Object output) { - // GDB can send an error result following sending an OK result. - // In this case the error is routed as an event. - MIResultRecord rr = ((MIOutput)output).getMIResultRecord(); - if (rr != null) { - // Check if the state changed. - String state = rr.getResultClass(); - - // This is not handled properly yet - // see bug 247161 - if (fInferior != null && "error".equals(state)) { //$NON-NLS-1$ - if (fInferior.getState() == MIInferiorProcess.State.RUNNING) { - fInferior.setState(MIInferiorProcess.State.STOPPED); - IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class); - String groupId = procService.getExecutionGroupIdFromThread(null); - - IProcessDMContext procDmc = procService.createProcessContext(fControlDmc, groupId); - IContainerDMContext processContainerDmc = procService.createExecutionGroupContext(procDmc, groupId); - fCommandControl.getSession().dispatchEvent( - MIErrorEvent.parse(processContainerDmc, rr.getToken(), rr.getMIResults(), null), - fCommandControl.getProperties()); - } - } - } }