Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2009-06-05 02:30:07 +0000
committerMarc Khouzam2009-06-05 02:30:07 +0000
commit685ff524d312e7194ff17a55acfa79f90e78e743 (patch)
tree35dc77569d69b5fb9fba7fba7107989cb90849be
parent2c8724af33ed987c19bb5b55a8a7232b5bfa2f9f (diff)
downloadorg.eclipse.cdt-685ff524d312e7194ff17a55acfa79f90e78e743.tar.gz
org.eclipse.cdt-685ff524d312e7194ff17a55acfa79f90e78e743.tar.xz
org.eclipse.cdt-685ff524d312e7194ff17a55acfa79f90e78e743.zip
[234468] Adding a new preference to decide if we should automatically terminate GDB when the inferior exists.
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java35
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java2
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/IGdbDebugPreferenceConstants.java2
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java2
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/messages.properties4
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsoleManager.java2
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java40
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java6
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java14
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java29
10 files changed, 120 insertions, 16 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java
index aa010eaa45b..8815912e79d 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences;
+import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
@@ -51,22 +52,38 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
layout.marginWidth= 0;
parent.setLayout(layout);
- Group tracesGroup= new Group(parent, SWT.NONE);
- tracesGroup.setText(MessagesForPreferences.GdbDebugPreferencePage_traces_label);
+ Group group= new Group(parent, SWT.NONE);
+ group.setText(MessagesForPreferences.GdbDebugPreferencePage_traces_label);
GridLayout groupLayout= new GridLayout(3, false);
- tracesGroup.setLayout(groupLayout);
- tracesGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ group.setLayout(groupLayout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- BooleanFieldEditor traces= new BooleanFieldEditor(
+ BooleanFieldEditor boolField= new BooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE,
MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label,
- tracesGroup);
+ group);
- traces.fillIntoGrid(tracesGroup, 3);
- addField(traces);
+ boolField.fillIntoGrid(group, 3);
+ addField(boolField);
+ // need to set layout again
+ group.setLayout(groupLayout);
+
+ group= new Group(parent, SWT.NONE);
+ group.setText(MessagesForPreferences.GdbDebugPreferencePage_termination_label);
+ groupLayout= new GridLayout(3, false);
+ group.setLayout(groupLayout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ boolField= new BooleanFieldEditor(
+ IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
+ MessagesForPreferences.GdbDebugPreferencePage_autoTerminateGdb_label,
+ group);
+
+ boolField.fillIntoGrid(group, 3);
+ addField(boolField);
// need to set layout again
- tracesGroup.setLayout(groupLayout);
+ group.setLayout(groupLayout);
+
}
@Override
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java
index 58de220cb82..547b15559bd 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences;
+import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -22,5 +23,6 @@ public class GdbPreferenceInitializer extends AbstractPreferenceInitializer {
public void initializeDefaultPreferences() {
IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore();
store.setDefault(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, true);
+ store.setDefault(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true);
}
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/IGdbDebugPreferenceConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/IGdbDebugPreferenceConstants.java
index 63115be4ad9..994c336b12e 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/IGdbDebugPreferenceConstants.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/IGdbDebugPreferenceConstants.java
@@ -16,7 +16,9 @@ import org.eclipse.debug.ui.IDebugUIConstants;
/**
* @noimplement This interface is not intended to be implemented by clients.
* @since 2.0
+ * @deprecated Has been replaced with org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants
*/
+@Deprecated
public interface IGdbDebugPreferenceConstants {
/**
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java
index 82b26058561..3c3c564f366 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java
@@ -21,6 +21,8 @@ class MessagesForPreferences extends NLS {
public static String GdbDebugPreferencePage_description;
public static String GdbDebugPreferencePage_traces_label;
public static String GdbDebugPreferencePage_enableTraces_label;
+ public static String GdbDebugPreferencePage_termination_label;
+ public static String GdbDebugPreferencePage_autoTerminateGdb_label;
static {
// initialize resource bundle
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/messages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/messages.properties
index 568d781c942..92220f7061d 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/messages.properties
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/messages.properties
@@ -10,5 +10,9 @@
###############################################################################
GdbDebugPreferencePage_description=General settings for GDB Debugging
+
GdbDebugPreferencePage_traces_label=Traces
GdbDebugPreferencePage_enableTraces_label=Enable GDB traces
+
+GdbDebugPreferencePage_termination_label=Termination
+GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsoleManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsoleManager.java
index ed2e3a25816..d08836d1992 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsoleManager.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsoleManager.java
@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.tracing;
+import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
-import org.eclipse.cdt.dsf.gdb.internal.ui.preferences.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.launching.ITracedLaunch;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java
new file mode 100644
index 00000000000..740ef713b65
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb;
+
+import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+
+
+
+/**
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 2.0
+ */
+public interface IGdbDebugPreferenceConstants {
+
+ /**
+ * Boolean preference whether to enable GDB traces. Default is <code>true</code>.
+ */
+ public static final String PREF_TRACES_ENABLE = "tracesEnable"; //$NON-NLS-1$
+
+ /**
+ * Boolean preference whether to automatically terminate GDB when the inferior exists. Default is <code>true</code>.
+ */
+ public static final String PREF_AUTO_TERMINATE_GDB = "autoTerminateGdb"; //$NON-NLS-1$
+
+ /**
+ * Help prefixes.
+ */
+ public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+
+ public static final String PREFERENCE_PAGE= PREFIX + "preference_page_context"; //$NON-NLS-1$
+}
+
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 bc3c4b788c0..29b0fafac21 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
@@ -850,9 +850,6 @@ 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();
@@ -863,9 +860,6 @@ 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();
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
index 005bf5983fd..ae8eae3d0f3 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
@@ -29,6 +29,7 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
+import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
@@ -37,6 +38,7 @@ import org.eclipse.cdt.dsf.mi.service.IMIBackend;
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
import org.eclipse.cdt.dsf.mi.service.IMIBackend.BackendStateChangedEvent;
+import org.eclipse.cdt.dsf.mi.service.MIProcesses.ContainerExitedDMEvent;
import org.eclipse.cdt.dsf.mi.service.MIProcesses.ContainerStartedDMEvent;
import org.eclipse.cdt.dsf.mi.service.command.AbstractCLIProcess;
import org.eclipse.cdt.dsf.mi.service.command.AbstractMIControl;
@@ -59,6 +61,7 @@ import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -404,6 +407,17 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
}
}
+ /** @since 2.0 */
+ @DsfServiceEventHandler
+ public void eventDispatched(ContainerExitedDMEvent e) {
+ if (Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
+ IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
+ true, null)) {
+ // If the inferior finishes, let's terminate GDB
+ terminate(new RequestMonitor(getExecutor(), null));
+ }
+ }
+
public static class InitializationShutdownStep extends Sequence.Step {
public enum Direction { INITIALIZING, SHUTTING_DOWN }
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
index 83170ec69c4..37152f3ec1e 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
@@ -30,12 +30,15 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
+import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.gdb.service.GDBRunControl_7_0;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
import org.eclipse.cdt.dsf.gdb.service.IReverseRunControl;
import org.eclipse.cdt.dsf.gdb.service.SessionType;
+import org.eclipse.cdt.dsf.gdb.service.GDBProcesses_7_0.ContainerExitedDMEvent;
+import org.eclipse.cdt.dsf.gdb.service.GDBProcesses_7_0.ContainerStartedDMEvent;
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
@@ -61,6 +64,7 @@ import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -542,6 +546,31 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
}
}
+ /** @since 2.0 */
+ @DsfServiceEventHandler
+ public void eventDispatched(ContainerStartedDMEvent e) {
+ setConnected(true);
+ }
+
+ /** @since 2.0 */
+ @DsfServiceEventHandler
+ public void eventDispatched(ContainerExitedDMEvent e) {
+ setConnected(false);
+
+ if (Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
+ IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
+ true, null)) {
+ if (!isConnected() &&
+ !(fMIBackend.getIsAttachSession() &&
+ fMIBackend.getSessionType() == SessionType.REMOTE)) {
+ // 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
+ terminate(new RequestMonitor(getExecutor(), null));
+ }
+ }
+ }
+
public static class InitializationShutdownStep extends Sequence.Step {
public enum Direction { INITIALIZING, SHUTTING_DOWN }

Back to the top