mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 241844
Adds the started and exited events when attaching and detaching from a process.
This commit is contained in:
parent
5c1533d934
commit
133ac134ee
5 changed files with 73 additions and 26 deletions
|
@ -100,15 +100,18 @@ public interface IProcesses extends IDMService {
|
|||
|
||||
/**
|
||||
* Checks whether it is possible to detach the debugger from the specified process.
|
||||
* @param procCtx The process from which we want to detach.
|
||||
* @param dmc The debugging context from which we want to detach. This context
|
||||
* should have IProcessDMContext as an ancestor.
|
||||
* @param rm Return if it is possible to detach.
|
||||
*/
|
||||
void canDetachDebuggerFromProcess(IProcessDMContext procCtx, DataRequestMonitor<Boolean> rm);
|
||||
void canDetachDebuggerFromProcess(IDMContext dmc, DataRequestMonitor<Boolean> rm);
|
||||
|
||||
/**
|
||||
* Detaches debugger from the given process.
|
||||
* @param dmc The debugging context from which we want to detach. This context
|
||||
* should have IProcessDMContext as an ancestor.
|
||||
*/
|
||||
void detachDebuggerFromProcess(IProcessDMContext procCtx, RequestMonitor requestMonitor);
|
||||
void detachDebuggerFromProcess(IDMContext dmc, RequestMonitor requestMonitor);
|
||||
|
||||
/**
|
||||
* Checks whether it is possible to run a new process.
|
||||
|
|
|
@ -83,7 +83,7 @@ public interface IRunControl extends IDMService
|
|||
}
|
||||
|
||||
/**
|
||||
* Indicates that a new execution context (thread) was started.
|
||||
* Indicates that a new execution context was started.
|
||||
*/
|
||||
public interface IStartedDMEvent extends IDMEvent<IExecutionDMContext> {}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
|||
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
|
||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||
import org.eclipse.dd.dsf.debug.ui.actions.DsfCommandRunnable;
|
||||
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
|
@ -45,10 +45,10 @@ public class GdbDisconnectCommand implements IDisconnectHandler {
|
|||
|
||||
fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) {
|
||||
@Override public void doExecute() {
|
||||
IProcessDMContext procDmc = DMContexts.getAncestorOfType(getContext(), IProcessDMContext.class);
|
||||
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(getContext(), IContainerDMContext.class);
|
||||
|
||||
getProcessService().canDetachDebuggerFromProcess(
|
||||
procDmc,
|
||||
containerDmc,
|
||||
new DataRequestMonitor<Boolean>(fExecutor, null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
|
@ -68,8 +68,8 @@ public class GdbDisconnectCommand implements IDisconnectHandler {
|
|||
|
||||
fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) {
|
||||
@Override public void doExecute() {
|
||||
IProcessDMContext procDmc = DMContexts.getAncestorOfType(getContext(), IProcessDMContext.class);
|
||||
getProcessService().detachDebuggerFromProcess(procDmc, new RequestMonitor(fExecutor, null));
|
||||
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(getContext(), IContainerDMContext.class);
|
||||
getProcessService().detachDebuggerFromProcess(containerDmc, new RequestMonitor(fExecutor, null));
|
||||
}
|
||||
});
|
||||
return false;
|
||||
|
|
|
@ -138,15 +138,15 @@ public class GDBProcesses extends MIProcesses {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void canDetachDebuggerFromProcess(IProcessDMContext procCtx, DataRequestMonitor<Boolean> rm) {
|
||||
public void canDetachDebuggerFromProcess(IDMContext dmc, DataRequestMonitor<Boolean> rm) {
|
||||
rm.setData(false); // don't turn on yet, as we need to generate events to use this properly
|
||||
rm.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachDebuggerFromProcess(IProcessDMContext procCtx, final RequestMonitor rm) {
|
||||
public void detachDebuggerFromProcess(IDMContext dmc, final RequestMonitor rm) {
|
||||
super.detachDebuggerFromProcess(
|
||||
procCtx,
|
||||
dmc,
|
||||
new RequestMonitor(getExecutor(), rm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
|
@ -159,7 +159,9 @@ public class GDBProcesses extends MIProcesses {
|
|||
@Override
|
||||
public void getProcessesBeingDebugged(IDMContext dmc, DataRequestMonitor<IDMContext[]> rm) {
|
||||
MIInferiorProcess inferiorProcess = fGdb.getInferiorProcess();
|
||||
if (inferiorProcess != null && inferiorProcess.getState() != MIInferiorProcess.State.TERMINATED) {
|
||||
if (fGdb.isConnected() &&
|
||||
inferiorProcess != null &&
|
||||
inferiorProcess.getState() != MIInferiorProcess.State.TERMINATED) {
|
||||
super.getProcessesBeingDebugged(dmc, rm);
|
||||
} else {
|
||||
rm.done();
|
||||
|
|
|
@ -16,11 +16,15 @@ import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
|||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
||||
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
|
||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IProcesses;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||
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.IResumedDMEvent;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IStartedDMEvent;
|
||||
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.command.CommandCache;
|
||||
|
@ -203,6 +207,30 @@ public class MIProcesses extends AbstractDsfService implements IProcesses {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event indicating that an execution group (debugged process) has started. This event
|
||||
* implements the {@link IStartedMDEvent} from the IRunControl service.
|
||||
*/
|
||||
public static class ExecutionGroupStartedDMEvent extends AbstractDMEvent<IExecutionDMContext>
|
||||
implements IStartedDMEvent
|
||||
{
|
||||
public ExecutionGroupStartedDMEvent(IMIExecutionGroupDMContext context) {
|
||||
super(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event indicating that an execution group is no longer being debugged. This event
|
||||
* implements the {@link IExitedMDEvent} from the IRunControl service.
|
||||
*/
|
||||
public static class ExecutionGroupExitedDMEvent extends AbstractDMEvent<IExecutionDMContext>
|
||||
implements IExitedDMEvent
|
||||
{
|
||||
public ExecutionGroupExitedDMEvent(IContainerDMContext context) {
|
||||
super(context);
|
||||
}
|
||||
}
|
||||
|
||||
private AbstractMIControl fCommandControl;
|
||||
private CommandCache fCommandCache;
|
||||
|
||||
|
@ -361,7 +389,7 @@ public class MIProcesses extends AbstractDsfService implements IProcesses {
|
|||
rm.done();
|
||||
}
|
||||
|
||||
public void attachDebuggerToProcess(IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> rm) {
|
||||
public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> rm) {
|
||||
if (procCtx instanceof IMIProcessDMContext) {
|
||||
MIControlDMContext controlDmc = DMContexts.getAncestorOfType(procCtx, MIControlDMContext.class);
|
||||
fCommandControl.queueCommand(
|
||||
|
@ -369,7 +397,10 @@ public class MIProcesses extends AbstractDsfService implements IProcesses {
|
|||
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
rm.setData(null);
|
||||
IMIExecutionGroupDMContext groupDmc = createExecutionGroupContext(procCtx, ""); //$NON-NLS-1$
|
||||
getSession().dispatchEvent(new ExecutionGroupStartedDMEvent(groupDmc),
|
||||
getProperties());
|
||||
rm.setData(groupDmc);
|
||||
rm.done();
|
||||
}
|
||||
});
|
||||
|
@ -380,21 +411,32 @@ public class MIProcesses extends AbstractDsfService implements IProcesses {
|
|||
}
|
||||
}
|
||||
|
||||
public void canDetachDebuggerFromProcess(IProcessDMContext procCtx, DataRequestMonitor<Boolean> rm) {
|
||||
public void canDetachDebuggerFromProcess(IDMContext dmc, DataRequestMonitor<Boolean> rm) {
|
||||
rm.setData(false);
|
||||
rm.done();
|
||||
}
|
||||
|
||||
public void detachDebuggerFromProcess(IProcessDMContext procCtx, final RequestMonitor rm) {
|
||||
if (procCtx instanceof MIProcessDMC) {
|
||||
MIControlDMContext controlDmc = DMContexts.getAncestorOfType(procCtx, MIControlDMContext.class);
|
||||
// This service version cannot use -target-detach because it didn't exist
|
||||
// in versions of GDB up to and including GDB 6.8
|
||||
fCommandControl.queueCommand(
|
||||
new CLIDetach(controlDmc),
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
|
||||
} else {
|
||||
rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$
|
||||
public void detachDebuggerFromProcess(final IDMContext dmc, final RequestMonitor rm) {
|
||||
MIControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, MIControlDMContext.class);
|
||||
|
||||
if (controlDmc != null) {
|
||||
// This service version cannot use -target-detach because it didn't exist
|
||||
// in versions of GDB up to and including GDB 6.8
|
||||
fCommandControl.queueCommand(
|
||||
new CLIDetach(controlDmc),
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IContainerDMContext.class);
|
||||
if (containerDmc != null) {
|
||||
getSession().dispatchEvent(new ExecutionGroupExitedDMEvent(containerDmc),
|
||||
getProperties());
|
||||
}
|
||||
rm.done();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid context.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue