From 7d74b57d781b396af852bda720cf73a2e68b5bcb Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 7 Jul 2009 19:33:02 +0000 Subject: [PATCH] [280327] Send a ContainerStartedDMEvent when getting a ^connect. This is important for post mortem sessions. --- .../dsf/gdb/service/command/GDBControl.java | 7 +++++- .../command/MIRunControlEventProcessor.java | 24 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java index ae8eae3d0f3..233a821fdc9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java @@ -327,7 +327,12 @@ public class GDBControl extends AbstractMIControl implements IGDBControl { final DataRequestMonitor execMonitor = new DataRequestMonitor(getExecutor(), requestMonitor) { @Override protected void handleSuccess() { - getSession().dispatchEvent(new ContainerStartedDMEvent(containerDmc), getProperties()); + if (fMIBackend.getSessionType() != SessionType.REMOTE) { + // Don't send the ContainerStarted event for a remote session because + // it has already been done by MIRunControlEventProcessor when receiving + // the ^connect + getSession().dispatchEvent(new ContainerStartedDMEvent(containerDmc), getProperties()); + } super.handleSuccess(); } }; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor.java index b4f3f0703d5..302913650d3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor.java @@ -25,8 +25,10 @@ import org.eclipse.cdt.dsf.debug.service.command.ICommandToken; import org.eclipse.cdt.dsf.debug.service.command.IEventListener; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; import org.eclipse.cdt.dsf.mi.service.IMIProcesses; import org.eclipse.cdt.dsf.mi.service.MIProcesses; +import org.eclipse.cdt.dsf.mi.service.MIProcesses.ContainerStartedDMEvent; 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.MIExecNext; @@ -258,6 +260,28 @@ public class MIRunControlEventProcessor // No need to do anything, terminate() will. // Send exited? } else if ("connected".equals(state)) { //$NON-NLS-1$ + // This will happen for a CORE or REMOTE session. + // For a CORE session this is the only indication + // that the inferior has 'started'. So we use + // it to trigger the ContainerStarted event. + // In the case of a REMOTE session, it is a proper + // indicator as well but not if it is a remote attach. + // For an attach session, it only indicates + // that we are connected to a remote node but we still + // need to wait until we are attached to the process before + // sending the event, which will happen in the attaching code. + IGDBBackend backendService = fServicesTracker.getService(IGDBBackend.class); + if (backendService != null && backendService.getIsAttachSession() == false) { + IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class); + if (procService != null) { + String groupId = MIProcesses.UNIQUE_GROUP_ID; + IProcessDMContext procDmc = procService.createProcessContext(fControlDmc, groupId); + IContainerDMContext processContainerDmc = procService.createContainerContext(procDmc, groupId); + + fCommandControl.getSession().dispatchEvent( + new ContainerStartedDMEvent(processContainerDmc), fCommandControl.getProperties()); + } + } } else if ("error".equals(state)) { //$NON-NLS-1$ } }