From e96dfd110ad5d722a6bc00e1656a47579720758b Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 2 Mar 2011 14:58:00 +0000 Subject: [PATCH] Bug 338319: Allow terminating individual processes --- .../cdt/dsf/gdb/service/GDBProcesses.java | 9 ++++++++- .../cdt/dsf/gdb/service/GDBProcesses_7_0.java | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java index e98d5d9e5ea..0c390fe0ad4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java @@ -356,7 +356,14 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses { @Override public void terminate(IThreadDMContext thread, final RequestMonitor rm) { - if (thread instanceof IMIProcessDMContext) { + // If we will terminate GDB as soon as the inferior terminates, then let's + // just terminate GDB itself. This is more robust since we actually monitor + // the success of terminating GDB. + if (Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$ + IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, + true, null)) { + fGdb.terminate(new RequestMonitor(ImmediateExecutor.getInstance(), null)); + } else if (thread instanceof IMIProcessDMContext) { getDebuggingContext( thread, new DataRequestMonitor(ImmediateExecutor.getInstance(), rm) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java index 818511fe8cc..1e987cd39a5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java @@ -1119,7 +1119,15 @@ public class GDBProcesses_7_0 extends AbstractDsfService } public void terminate(IThreadDMContext thread, final RequestMonitor rm) { - if (thread instanceof IMIProcessDMContext) { + // If we will terminate GDB as soon as the last inferior terminates, then let's + // just terminate GDB itself if this is the last inferior. + // This is more robust since we actually monitor the success of terminating GDB. + if (fNumConnected == 1 && + Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$ + IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, + true, null)) { + fCommandControl.terminate(new RequestMonitor(ImmediateExecutor.getInstance(), null)); + } else if (thread instanceof IMIProcessDMContext) { getDebuggingContext( thread, new DataRequestMonitor(ImmediateExecutor.getInstance(), rm) { @@ -1272,12 +1280,11 @@ public class GDBProcesses_7_0 extends AbstractDsfService if (Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$ IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true, null)) { - if (fNumConnected == 0 && - !(fBackend.getIsAttachSession() && - fBackend.getSessionType() == SessionType.REMOTE)) { + if (fNumConnected == 0) { // If the last process we are debugging finishes, let's terminate GDB - // but not for a remote attach session, since we could request to attach - // to another process + // We also do this for a remote attach session, since the 'auto terminate' preference + // is enabled. If users want to keep the session alive to attach to another process, + // they can simply disable that preference fCommandControl.terminate(new RequestMonitor(ImmediateExecutor.getInstance(), null)); } }