1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 353423: Need a way to refresh the thread list and state in the run control service

This commit is contained in:
Marc Khouzam 2011-08-01 11:20:36 -04:00
parent ff55434173
commit d2e7a581bc
2 changed files with 73 additions and 14 deletions

View file

@ -222,20 +222,22 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
} }
public StateChangeReason getReason() { public StateChangeReason getReason() {
switch(getMIEvent().getType()) { if (getMIEvent() != null) {
case MIRunningEvent.CONTINUE: switch(getMIEvent().getType()) {
return StateChangeReason.USER_REQUEST; case MIRunningEvent.CONTINUE:
case MIRunningEvent.NEXT: return StateChangeReason.USER_REQUEST;
case MIRunningEvent.NEXTI: case MIRunningEvent.NEXT:
return StateChangeReason.STEP; case MIRunningEvent.NEXTI:
case MIRunningEvent.STEP: return StateChangeReason.STEP;
case MIRunningEvent.STEPI: case MIRunningEvent.STEP:
return StateChangeReason.STEP; case MIRunningEvent.STEPI:
case MIRunningEvent.FINISH: return StateChangeReason.STEP;
return StateChangeReason.STEP; case MIRunningEvent.FINISH:
case MIRunningEvent.UNTIL: return StateChangeReason.STEP;
case MIRunningEvent.RETURN: case MIRunningEvent.UNTIL:
break; case MIRunningEvent.RETURN:
break;
}
} }
return StateChangeReason.UNKNOWN; return StateChangeReason.UNKNOWN;
} }

View file

@ -17,6 +17,9 @@ import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl; import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IRunControl2; import org.eclipse.cdt.dsf.debug.service.IRunControl2;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
@ -27,6 +30,8 @@ import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIRunControl; import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIThread;
import org.eclipse.cdt.dsf.mi.service.command.output.MIThreadInfoInfo;
import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
@ -41,6 +46,7 @@ public class GDBRunControl_7_2_NS extends GDBRunControl_7_0_NS
private ICommandControlService fConnection; private ICommandControlService fConnection;
private CommandFactory fCommandFactory; private CommandFactory fCommandFactory;
private IGDBProcesses fProcService;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Initialization and shutdown // Initialization and shutdown
@ -70,6 +76,7 @@ public class GDBRunControl_7_2_NS extends GDBRunControl_7_0_NS
new Hashtable<String,String>()); new Hashtable<String,String>());
fConnection = getServicesTracker().getService(ICommandControlService.class); fConnection = getServicesTracker().getService(ICommandControlService.class);
fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory(); fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
fProcService = getServicesTracker().getService(IGDBProcesses.class);
getSession().addServiceEventListener(this, null); getSession().addServiceEventListener(this, null);
rm.done(); rm.done();
} }
@ -169,4 +176,54 @@ public class GDBRunControl_7_2_NS extends GDBRunControl_7_0_NS
private void doResumeContainer(IMIContainerDMContext context, final RequestMonitor rm) { private void doResumeContainer(IMIContainerDMContext context, final RequestMonitor rm) {
fConnection.queueCommand(fCommandFactory.createMIExecContinue(context), new DataRequestMonitor<MIInfo>(getExecutor(), rm)); fConnection.queueCommand(fCommandFactory.createMIExecContinue(context), new DataRequestMonitor<MIInfo>(getExecutor(), rm));
} }
private void refreshThreads() {
fConnection.queueCommand(
fCommandFactory.createMIThreadInfo(fConnection.getContext()),
new DataRequestMonitor<MIThreadInfoInfo>(getExecutor(), null) {
@Override
protected void handleSuccess() {
MIThread[] threadList = getData().getThreadList();
for (MIThread thread : threadList) {
String threadId = thread.getThreadId();
IMIContainerDMContext containerDmc =
fProcService.createContainerContextFromThreadId(fConnection.getContext(), threadId);
IProcessDMContext processDmc = DMContexts.getAncestorOfType(containerDmc, IProcessDMContext.class);
IThreadDMContext threadDmc =
fProcService.createThreadContext(processDmc, threadId);
IMIExecutionDMContext execDmc = fProcService.createExecutionContext(containerDmc, threadDmc, threadId);
MIThreadRunState threadState = fThreadRunStates.get(execDmc);
if (threadState != null) {
// We may not know this thread. This can happen when dealing with a remote
// where thread events are not reported immediately.
// However, the -list-thread-groups command we just sent will make
// GDB send those events. Therefore, we can just ignore threads we don't
// know about, and wait for those events.
if ("running".equals(thread.getState())) { //$NON-NLS-1$
if (threadState.fSuspended == true) {
// We missed a resumed event! Send it now.
IResumedDMEvent resumedEvent = new ResumedEvent(execDmc, null);
fConnection.getSession().dispatchEvent(resumedEvent, getProperties());
}
} else if ("stopped".equals(thread.getState())) { //$NON-NLS-1$
if (threadState.fSuspended == false) {
// We missed a suspend event! Send it now.
ISuspendedDMEvent suspendedEvent = new SuspendedEvent(execDmc, null);
fConnection.getSession().dispatchEvent(suspendedEvent, getProperties());
}
} else {
assert false : "Invalid thread state: " + thread.getState(); //$NON-NLS-1$
}
}
}
}
});
}
@Override
public void flushCache(IDMContext context) {
super.flushCache(context);
refreshThreads();
}
} }