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) {
|
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
fCommandControl.setConnected(true);
|
|
||||||
|
|
||||||
IMIContainerDMContext containerDmc = createContainerContext(procCtx,
|
IMIContainerDMContext containerDmc = createContainerContext(procCtx,
|
||||||
((IMIProcessDMContext)procCtx).getProcId());
|
((IMIProcessDMContext)procCtx).getProcId());
|
||||||
rm.setData(containerDmc);
|
rm.setData(containerDmc);
|
||||||
|
@ -584,14 +582,7 @@ public class GDBProcesses_7_0 extends AbstractDsfService
|
||||||
if (controlDmc != null && procDmc != null) {
|
if (controlDmc != null && procDmc != null) {
|
||||||
fCommandControl.queueCommand(
|
fCommandControl.queueCommand(
|
||||||
new MITargetDetach(controlDmc, procDmc.getProcId()),
|
new MITargetDetach(controlDmc, procDmc.getProcId()),
|
||||||
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
|
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
|
||||||
@Override
|
|
||||||
protected void handleSuccess() {
|
|
||||||
// only if it is the last detach
|
|
||||||
fCommandControl.setConnected(false);
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid context.", null)); //$NON-NLS-1$
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid context.", null)); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
|
@ -785,6 +776,9 @@ public class GDBProcesses_7_0 extends AbstractDsfService
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(IStartedDMEvent e) {
|
public void eventDispatched(IStartedDMEvent e) {
|
||||||
if (e instanceof ContainerStartedDMEvent) {
|
if (e instanceof ContainerStartedDMEvent) {
|
||||||
|
// This will increment the connect count
|
||||||
|
fCommandControl.setConnected(true);
|
||||||
|
|
||||||
fContainerCommandCache.reset();
|
fContainerCommandCache.reset();
|
||||||
} else {
|
} else {
|
||||||
fThreadCommandCache.reset();
|
fThreadCommandCache.reset();
|
||||||
|
@ -795,6 +789,9 @@ public class GDBProcesses_7_0 extends AbstractDsfService
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(IExitedDMEvent e) {
|
public void eventDispatched(IExitedDMEvent e) {
|
||||||
if (e instanceof ContainerExitedDMEvent) {
|
if (e instanceof ContainerExitedDMEvent) {
|
||||||
|
// This will decrement the connect count
|
||||||
|
fCommandControl.setConnected(false);
|
||||||
|
|
||||||
fContainerCommandCache.reset();
|
fContainerCommandCache.reset();
|
||||||
} else {
|
} else {
|
||||||
fThreadCommandCache.reset();
|
fThreadCommandCache.reset();
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
||||||
|
|
||||||
private IGDBBackend fMIBackend;
|
private IGDBBackend fMIBackend;
|
||||||
|
|
||||||
private boolean fConnected = true;
|
private int fConnected = 0;
|
||||||
|
|
||||||
private MIRunControlEventProcessor_7_0 fMIEventProcessor;
|
private MIRunControlEventProcessor_7_0 fMIEventProcessor;
|
||||||
private CLIEventProcessor_7_0 fCLICommandProcessor;
|
private CLIEventProcessor_7_0 fCLICommandProcessor;
|
||||||
|
@ -347,12 +347,16 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return fInferiorProcess.getState() != MIInferiorProcess.State.TERMINATED && fConnected;
|
return fInferiorProcess.getState() != MIInferiorProcess.State.TERMINATED && fConnected > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConnected(boolean connected) {
|
public void setConnected(boolean connected) {
|
||||||
fConnected = connected;
|
if (connected) {
|
||||||
}
|
fConnected++;
|
||||||
|
} else {
|
||||||
|
if (fConnected > 0) fConnected--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public AbstractCLIProcess getCLIProcess() {
|
public AbstractCLIProcess getCLIProcess() {
|
||||||
return fCLIProcess;
|
return fCLIProcess;
|
||||||
|
|
Loading…
Add table
Reference in a new issue