mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 345751: Inferior console does not get removed after a restart with GDB 7.0 and 7.1
This commit is contained in:
parent
f0be94ea01
commit
48182ee891
1 changed files with 34 additions and 8 deletions
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.dsf.gdb.launching.InferiorRuntimeProcess;
|
||||||
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
|
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
|
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
|
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
|
||||||
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.MIInferiorProcess;
|
import org.eclipse.cdt.dsf.mi.service.command.MIInferiorProcess;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
|
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
|
||||||
|
@ -303,7 +304,11 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence {
|
||||||
|
|
||||||
final Process inferior = inferiorProcess;
|
final Process inferior = inferiorProcess;
|
||||||
final ILaunch launch = (ILaunch)getContainerContext().getAdapter(ILaunch.class);
|
final ILaunch launch = (ILaunch)getContainerContext().getAdapter(ILaunch.class);
|
||||||
final String groupId = ((IMIContainerDMContext)getContainerContext()).getGroupId();
|
|
||||||
|
// This is the groupId of the current process.
|
||||||
|
// In the case of a restart for GDB 7.0 or 7.1, this groupId will _not_ be the one
|
||||||
|
// of the new process, since the pid is used for groupId.
|
||||||
|
final String currentGroupId = ((IMIContainerDMContext)getContainerContext()).getGroupId();
|
||||||
|
|
||||||
// For multi-process, we cannot simply use the name given by the backend service
|
// For multi-process, we cannot simply use the name given by the backend service
|
||||||
// because we may not be starting that process, but another one.
|
// because we may not be starting that process, but another one.
|
||||||
|
@ -326,17 +331,38 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence {
|
||||||
DebugPlugin.getDefault().asyncExec(new Runnable() {
|
DebugPlugin.getDefault().asyncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
String label = pathLabel;
|
String label = pathLabel;
|
||||||
|
String groupId = currentGroupId;
|
||||||
|
|
||||||
if (fRestart) {
|
if (fRestart) {
|
||||||
// For a restart, remove the old inferior
|
// For a restart, remove the old inferior
|
||||||
IProcess[] launchProcesses = launch.getProcesses();
|
IProcess[] launchProcesses = launch.getProcesses();
|
||||||
for (IProcess process : launchProcesses) {
|
for (IProcess process : launchProcesses) {
|
||||||
String groupAttribute = process.getAttribute(IGdbDebugConstants.INFERIOR_GROUPID_ATTR);
|
if (process instanceof InferiorRuntimeProcess) {
|
||||||
if (groupId.equals(groupAttribute)) {
|
String groupAttribute = process.getAttribute(IGdbDebugConstants.INFERIOR_GROUPID_ATTR);
|
||||||
launch.removeProcess(process);
|
|
||||||
// Use the exact same label as before
|
// if the groupAttribute is not set in the process we know we are dealing
|
||||||
label = process.getLabel();
|
// with single process debugging so the one process is the one we want.
|
||||||
break;
|
// If the groupAttribute is set, then we must make sure it is the proper inferior
|
||||||
}
|
if (groupAttribute == null || groupAttribute.equals(MIProcesses.UNIQUE_GROUP_ID) ||
|
||||||
|
groupAttribute.equals(groupId)) {
|
||||||
|
|
||||||
|
// For GDB 7.0 and 7.1, the groupId of the new process will not be the same as
|
||||||
|
// the groupId of the old process, after the restart; we cannot know the new
|
||||||
|
// groupId yet since it will be the process pid, so we should use
|
||||||
|
// MIProcesses.UNIQUE_GROUP_ID. Starting with GDB 7.2, the groupId stays
|
||||||
|
// the same after a restart. We can use the groupId that was stored with
|
||||||
|
// the previous inferior to make sure we have the proper value.
|
||||||
|
// Note that in the case of an attach, where the groupId is already set
|
||||||
|
// even for GDB 7.0 and 7.1, but won't stay the same, we don't have an inferior
|
||||||
|
// at all, so we don't need to worry about that case.
|
||||||
|
groupId = groupAttribute;
|
||||||
|
|
||||||
|
launch.removeProcess(process);
|
||||||
|
// Use the exact same label as before
|
||||||
|
label = process.getLabel();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue