mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Committed patch adding initial implementation of multi-threading (bug 160038).
This commit is contained in:
parent
9ea8fb6e7e
commit
651bb074fb
4 changed files with 69 additions and 31 deletions
|
@ -71,7 +71,7 @@ public class DsfTerminateCommand implements ITerminateHandler {
|
||||||
} else {
|
} else {
|
||||||
// Check the teriminate.
|
// Check the teriminate.
|
||||||
processes.canTerminate(
|
processes.canTerminate(
|
||||||
processes.getThreadForExecutionContext(dmc),
|
processes.getProcessForDebugContext(dmc),
|
||||||
new DataRequestMonitor<Boolean>(fExecutor, null) {
|
new DataRequestMonitor<Boolean>(fExecutor, null) {
|
||||||
@Override
|
@Override
|
||||||
public void handleCompleted() {
|
public void handleCompleted() {
|
||||||
|
@ -93,7 +93,7 @@ public class DsfTerminateCommand implements ITerminateHandler {
|
||||||
fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) {
|
fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) {
|
||||||
@Override public void doExecute() {
|
@Override public void doExecute() {
|
||||||
getProcesses().terminate(
|
getProcesses().terminate(
|
||||||
getProcesses().getThreadForExecutionContext(getContext()), new RequestMonitor(fExecutor, null));
|
getProcesses().getProcessForDebugContext(getContext()), new RequestMonitor(fExecutor, null));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -19,7 +19,10 @@ import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack;
|
import org.eclipse.dd.dsf.debug.service.IStack;
|
||||||
import org.eclipse.dd.dsf.debug.service.IStepQueueManager;
|
import org.eclipse.dd.dsf.debug.service.IStepQueueManager;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerSuspendedDMEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
|
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMData;
|
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMData;
|
||||||
|
@ -91,7 +94,8 @@ public class StackFramesLayoutNode extends AbstractDMVMLayoutNode<IStack.IFrameD
|
||||||
}
|
}
|
||||||
// Store the VMC element array, in case we need to use it when
|
// Store the VMC element array, in case we need to use it when
|
||||||
fCachedOldFrameVMCs = dmcs2vmcs(getData());
|
fCachedOldFrameVMCs = dmcs2vmcs(getData());
|
||||||
for (int i = 0; i < fCachedOldFrameVMCs.length; i++) update.setChild(fCachedOldFrameVMCs[i], i);
|
for (int i = 0; i < fCachedOldFrameVMCs.length; i++)
|
||||||
|
update.setChild(fCachedOldFrameVMCs[i], i);
|
||||||
update.done();
|
update.done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -127,7 +131,8 @@ public class StackFramesLayoutNode extends AbstractDMVMLayoutNode<IStack.IFrameD
|
||||||
// an array of VMCs with just the top frame.
|
// an array of VMCs with just the top frame.
|
||||||
if (fCachedOldFrameVMCs != null && fCachedOldFrameVMCs.length >= 1) {
|
if (fCachedOldFrameVMCs != null && fCachedOldFrameVMCs.length >= 1) {
|
||||||
fCachedOldFrameVMCs[0] = topFrameVmc;
|
fCachedOldFrameVMCs[0] = topFrameVmc;
|
||||||
for (int i = 0; i < fCachedOldFrameVMCs.length; i++) update.setChild(fCachedOldFrameVMCs[i], i);
|
for (int i = 0; i < fCachedOldFrameVMCs.length; i++)
|
||||||
|
update.setChild(fCachedOldFrameVMCs[i], i);
|
||||||
} else {
|
} else {
|
||||||
update.setChild(topFrameVmc, 0);
|
update.setChild(topFrameVmc, 0);
|
||||||
}
|
}
|
||||||
|
@ -209,10 +214,10 @@ public class StackFramesLayoutNode extends AbstractDMVMLayoutNode<IStack.IFrameD
|
||||||
protected int getNodeDeltaFlagsForDMEvent(org.eclipse.dd.dsf.datamodel.IDMEvent<?> e) {
|
protected int getNodeDeltaFlagsForDMEvent(org.eclipse.dd.dsf.datamodel.IDMEvent<?> e) {
|
||||||
// This node generates delta if the timers have changed, or if the
|
// This node generates delta if the timers have changed, or if the
|
||||||
// label has changed.
|
// label has changed.
|
||||||
if (e instanceof IRunControl.ISuspendedDMEvent) {
|
if (e instanceof ISuspendedDMEvent) {
|
||||||
return IModelDelta.CONTENT | IModelDelta.EXPAND | IModelDelta.SELECT;
|
return IModelDelta.CONTENT | IModelDelta.EXPAND | IModelDelta.SELECT;
|
||||||
} else if (e instanceof IRunControl.IResumedDMEvent) {
|
} else if (e instanceof IResumedDMEvent) {
|
||||||
if (((IRunControl.IResumedDMEvent)e).getReason() == StateChangeReason.STEP) {
|
if (((IResumedDMEvent)e).getReason() == StateChangeReason.STEP) {
|
||||||
return IModelDelta.STATE;
|
return IModelDelta.STATE;
|
||||||
} else {
|
} else {
|
||||||
return IModelDelta.CONTENT;
|
return IModelDelta.CONTENT;
|
||||||
|
@ -225,10 +230,12 @@ public class StackFramesLayoutNode extends AbstractDMVMLayoutNode<IStack.IFrameD
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildDeltaForDMEvent(final IDMEvent<?> e, final VMDelta parent, final int nodeOffset, final RequestMonitor rm) {
|
protected void buildDeltaForDMEvent(final IDMEvent<?> e, final VMDelta parent, final int nodeOffset, final RequestMonitor rm) {
|
||||||
if (e instanceof IRunControl.ISuspendedDMEvent) {
|
if (e instanceof IContainerSuspendedDMEvent) {
|
||||||
buildDeltaForSuspendedEvent((IRunControl.ISuspendedDMEvent)e, parent, nodeOffset, rm);
|
buildDeltaForSuspendedEvent((ISuspendedDMEvent)e, ((IContainerSuspendedDMEvent)e).getTriggeringContext(), parent, nodeOffset, rm);
|
||||||
} else if (e instanceof IRunControl.IResumedDMEvent) {
|
} else if (e instanceof ISuspendedDMEvent) {
|
||||||
buildDeltaForResumedEvent((IRunControl.IResumedDMEvent)e, parent, nodeOffset, rm);
|
buildDeltaForSuspendedEvent((ISuspendedDMEvent)e, ((ISuspendedDMEvent)e).getDMContext(), parent, nodeOffset, rm);
|
||||||
|
} else if (e instanceof IResumedDMEvent) {
|
||||||
|
buildDeltaForResumedEvent((IResumedDMEvent)e, parent, nodeOffset, rm);
|
||||||
} else if (e instanceof IStepQueueManager.ISteppingTimedOutEvent) {
|
} else if (e instanceof IStepQueueManager.ISteppingTimedOutEvent) {
|
||||||
buildDeltaForSteppingTimedOutEvent((IStepQueueManager.ISteppingTimedOutEvent)e, parent, nodeOffset, rm);
|
buildDeltaForSteppingTimedOutEvent((IStepQueueManager.ISteppingTimedOutEvent)e, parent, nodeOffset, rm);
|
||||||
} else {
|
} else {
|
||||||
|
@ -237,7 +244,7 @@ public class StackFramesLayoutNode extends AbstractDMVMLayoutNode<IStack.IFrameD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildDeltaForSuspendedEvent(final IRunControl.ISuspendedDMEvent e, final VMDelta parent, final int nodeOffset, final RequestMonitor rm) {
|
private void buildDeltaForSuspendedEvent(final ISuspendedDMEvent e, final IExecutionDMContext execCtx, final VMDelta parent, final int nodeOffset, final RequestMonitor rm) {
|
||||||
IRunControl runControlService = getServicesTracker().getService(IRunControl.class);
|
IRunControl runControlService = getServicesTracker().getService(IRunControl.class);
|
||||||
IStack stackService = getServicesTracker().getService(IStack.class);
|
IStack stackService = getServicesTracker().getService(IStack.class);
|
||||||
if (stackService == null || runControlService == null) {
|
if (stackService == null || runControlService == null) {
|
||||||
|
@ -249,7 +256,7 @@ public class StackFramesLayoutNode extends AbstractDMVMLayoutNode<IStack.IFrameD
|
||||||
// Refresh the whole list of stack frames unless the target is already stepping the next command. In
|
// Refresh the whole list of stack frames unless the target is already stepping the next command. In
|
||||||
// which case, the refresh will occur when the stepping sequence slows down or stops. Trying to
|
// which case, the refresh will occur when the stepping sequence slows down or stops. Trying to
|
||||||
// refresh the whole stack trace with every step would slow down stepping too much.
|
// refresh the whole stack trace with every step would slow down stepping too much.
|
||||||
if (!runControlService.isStepping(e.getDMContext())) {
|
if (!runControlService.isStepping(execCtx)) {
|
||||||
parent.addFlags(IModelDelta.CONTENT);
|
parent.addFlags(IModelDelta.CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +285,7 @@ public class StackFramesLayoutNode extends AbstractDMVMLayoutNode<IStack.IFrameD
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildDeltaForResumedEvent(final IRunControl.IResumedDMEvent e, final VMDelta parent, final int nodeOffset, final RequestMonitor rm) {
|
private void buildDeltaForResumedEvent(final IResumedDMEvent e, final VMDelta parent, final int nodeOffset, final RequestMonitor rm) {
|
||||||
IStack stackService = getServicesTracker().getService(IStack.class);
|
IStack stackService = getServicesTracker().getService(IStack.class);
|
||||||
if (stackService == null) {
|
if (stackService == null) {
|
||||||
// Required services have not initialized yet. Ignore the event.
|
// Required services have not initialized yet. Ignore the event.
|
||||||
|
@ -286,7 +293,7 @@ public class StackFramesLayoutNode extends AbstractDMVMLayoutNode<IStack.IFrameD
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRunControl.IResumedDMEvent resumedEvent = e;
|
IResumedDMEvent resumedEvent = e;
|
||||||
if (resumedEvent.getReason() != StateChangeReason.STEP) {
|
if (resumedEvent.getReason() != StateChangeReason.STEP) {
|
||||||
// Refresh the list of stack frames only if the run operation is not a step. Also, clear the list
|
// Refresh the list of stack frames only if the run operation is not a step. Also, clear the list
|
||||||
// of cached frames.
|
// of cached frames.
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMData;
|
import org.eclipse.dd.dsf.datamodel.IDMData;
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMService;
|
import org.eclipse.dd.dsf.datamodel.IDMService;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface provides access to the native OS's process
|
* This interface provides access to the native OS's process
|
||||||
|
@ -28,27 +27,56 @@ import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
public interface INativeProcesses extends IDMService {
|
public interface INativeProcesses extends IDMService {
|
||||||
|
|
||||||
public interface IThreadDMContext extends IDMContext<IThreadDMData> {}
|
public interface IThreadDMContext extends IDMContext<IThreadDMData> {}
|
||||||
public interface IProcessDMContext extends IThreadDMContext {}
|
public interface IProcessDMContext extends IDMContext<IProcessDMData> {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for thread and process object data. This data provides a link
|
* Interface for thread and process object data.
|
||||||
* to the lower level debugger services, in form of symbol, memory, and
|
|
||||||
* execution contexts.
|
|
||||||
*/
|
*/
|
||||||
public interface IThreadDMData extends IDMData {
|
public interface IThreadDMData extends IDMData {
|
||||||
String getName();
|
String getName();
|
||||||
String getId();
|
String getId();
|
||||||
boolean isDebuggerAttached();
|
boolean isDebuggerAttached();
|
||||||
IDMContext<?> getDebuggingContext();
|
IDMContext<?> getDebugContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for thread and process object data.
|
||||||
|
*/
|
||||||
|
public interface IProcessDMData extends IDMData {
|
||||||
|
String getName();
|
||||||
|
String getId();
|
||||||
|
boolean isDebuggerAttached();
|
||||||
|
IDMContext<?> getDebugContext();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event indicating that process data has changed.
|
* Event indicating that process data has changed.
|
||||||
*/
|
*/
|
||||||
public interface ProcessChangedDMEvent extends IDMEvent<IProcessDMContext> {}
|
public interface IProcessChangedDMEvent extends IDMEvent<IProcessDMContext> {}
|
||||||
|
|
||||||
public IThreadDMContext getThreadForExecutionContext(IExecutionDMContext execCtx);
|
|
||||||
|
|
||||||
|
public interface IProcessStartedEvent extends IDMEvent<IDMContext<INativeProcesses>> {
|
||||||
|
IProcessDMContext getProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IProcessExitedEvent extends IDMEvent<IDMContext<INativeProcesses>> {
|
||||||
|
IProcessDMContext getProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a thread for the corresponding context. <code>null</code> if no corresponding
|
||||||
|
* thread exists.
|
||||||
|
* @param execCtx
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IThreadDMContext getThreadForDebugContext(IDMContext<?> execCtx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a process context corresponding to the given context. <code>null</code> if no
|
||||||
|
* corresponding process exists.
|
||||||
|
*/
|
||||||
|
public IProcessDMContext getProcessForDebugContext(IDMContext<?> execCtx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the current list of processes running on target.
|
* Retrieves the current list of processes running on target.
|
||||||
* @param rm Request completion monitor, to be filled in with array of process contexts.
|
* @param rm Request completion monitor, to be filled in with array of process contexts.
|
||||||
|
@ -86,12 +114,13 @@ public interface INativeProcesses extends IDMService {
|
||||||
* @param thread Thread or process to terminate.
|
* @param thread Thread or process to terminate.
|
||||||
* @param rm Return token.
|
* @param rm Return token.
|
||||||
*/
|
*/
|
||||||
void canTerminate(IThreadDMContext thread, DataRequestMonitor<Boolean> rm);
|
void canTerminate(IDMContext<?> ctx, DataRequestMonitor<Boolean> rm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminates the selected process or thread.
|
* Terminates the selected process or thread.
|
||||||
* @param thread Thread or process to terminate.
|
* @param thread Thread or process to terminate.
|
||||||
* @param rm Request completion monitor, indicates success or failure.
|
* @param rm Request completion monitor, indicates success or failure.
|
||||||
*/
|
*/
|
||||||
void terminate(IThreadDMContext thread, RequestMonitor requestMonitor);
|
void terminate(IDMContext<?> ctx, RequestMonitor requestMonitor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ public interface IRunControl extends IDMService
|
||||||
* for execution cotnexts, which by itself can perform run-control
|
* for execution cotnexts, which by itself can perform run-control
|
||||||
* operations.
|
* operations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface IContainerDMContext extends IExecutionDMContext {}
|
public interface IContainerDMContext extends IExecutionDMContext {}
|
||||||
|
|
||||||
/** Flag indicating reason context state change. */
|
/** Flag indicating reason context state change. */
|
||||||
|
@ -50,16 +51,17 @@ public interface IRunControl extends IDMService
|
||||||
public interface ISuspendedDMEvent extends IDMEvent<IExecutionDMContext> {
|
public interface ISuspendedDMEvent extends IDMEvent<IExecutionDMContext> {
|
||||||
StateChangeReason getReason();
|
StateChangeReason getReason();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IResumedDMEvent extends IDMEvent<IExecutionDMContext> {
|
public interface IResumedDMEvent extends IDMEvent<IExecutionDMContext> {
|
||||||
StateChangeReason getReason();
|
StateChangeReason getReason();
|
||||||
}
|
}
|
||||||
public interface IContainerSuspendedDMEvent extends IDMEvent<IExecutionDMContext> {
|
|
||||||
StateChangeReason getReason();
|
public interface IContainerSuspendedDMEvent extends ISuspendedDMEvent {
|
||||||
|
IExecutionDMContext getTriggeringContext();
|
||||||
}
|
}
|
||||||
public interface IContainerResumedDMEvent extends IDMEvent<IExecutionDMContext> {
|
|
||||||
StateChangeReason getReason();
|
public interface IContainerResumedDMEvent extends IResumedDMEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that a new execution context (thread) was started. The DMC
|
* Indicates that a new execution context (thread) was started. The DMC
|
||||||
* for the event is the container of the new exec context.
|
* for the event is the container of the new exec context.
|
||||||
|
|
Loading…
Add table
Reference in a new issue