mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
[256663] Instead of having a boolean variable track if we are connected to a process, we now have an integer so we can deal with multi-process connections. Whenever an MI event indicating a process was attached/detached to by GDB is received, we increment/decrement the count. This solves both the problem of tracking auto-attach, and multi-attach. Note that this change is only for versions of the services for GDB 7_0 since multi-process is only available in the next release of GDB
This commit is contained in:
parent
8d815b790d
commit
29d9ee28c1
2 changed files with 15 additions and 14 deletions
|
@ -556,8 +556,6 @@ public class GDBProcesses_7_0 extends AbstractDsfService
|
|||
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
fCommandControl.setConnected(true);
|
||||
|
||||
IMIContainerDMContext containerDmc = createContainerContext(procCtx,
|
||||
((IMIProcessDMContext)procCtx).getProcId());
|
||||
rm.setData(containerDmc);
|
||||
|
@ -584,14 +582,7 @@ public class GDBProcesses_7_0 extends AbstractDsfService
|
|||
if (controlDmc != null && procDmc != null) {
|
||||
fCommandControl.queueCommand(
|
||||
new MITargetDetach(controlDmc, procDmc.getProcId()),
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
// only if it is the last detach
|
||||
fCommandControl.setConnected(false);
|
||||
rm.done();
|
||||
}
|
||||
});
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
|
||||
} else {
|
||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid context.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
|
@ -785,6 +776,9 @@ public class GDBProcesses_7_0 extends AbstractDsfService
|
|||
@DsfServiceEventHandler
|
||||
public void eventDispatched(IStartedDMEvent e) {
|
||||
if (e instanceof ContainerStartedDMEvent) {
|
||||
// This will increment the connect count
|
||||
fCommandControl.setConnected(true);
|
||||
|
||||
fContainerCommandCache.reset();
|
||||
} else {
|
||||
fThreadCommandCache.reset();
|
||||
|
@ -795,6 +789,9 @@ public class GDBProcesses_7_0 extends AbstractDsfService
|
|||
@DsfServiceEventHandler
|
||||
public void eventDispatched(IExitedDMEvent e) {
|
||||
if (e instanceof ContainerExitedDMEvent) {
|
||||
// This will decrement the connect count
|
||||
fCommandControl.setConnected(false);
|
||||
|
||||
fContainerCommandCache.reset();
|
||||
} else {
|
||||
fThreadCommandCache.reset();
|
||||
|
|
|
@ -97,7 +97,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
|
||||
private IGDBBackend fMIBackend;
|
||||
|
||||
private boolean fConnected = true;
|
||||
private int fConnected = 0;
|
||||
|
||||
private MIRunControlEventProcessor_7_0 fMIEventProcessor;
|
||||
private CLIEventProcessor_7_0 fCLICommandProcessor;
|
||||
|
@ -347,11 +347,15 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return fInferiorProcess.getState() != MIInferiorProcess.State.TERMINATED && fConnected;
|
||||
return fInferiorProcess.getState() != MIInferiorProcess.State.TERMINATED && fConnected > 0;
|
||||
}
|
||||
|
||||
public void setConnected(boolean connected) {
|
||||
fConnected = connected;
|
||||
if (connected) {
|
||||
fConnected++;
|
||||
} else {
|
||||
if (fConnected > 0) fConnected--;
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractCLIProcess getCLIProcess() {
|
||||
|
|
Loading…
Add table
Reference in a new issue