1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

[234468] Adding a new preference to decide if we should automatically terminate GDB when the inferior exists.

This commit is contained in:
Marc Khouzam 2009-06-05 02:30:07 +00:00
parent 2c8724af33
commit 685ff524d3
10 changed files with 121 additions and 17 deletions

View file

@ -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);
traces.fillIntoGrid(tracesGroup, 3);
addField(traces);
group);
boolField.fillIntoGrid(group, 3);
addField(boolField);
// need to set layout again
tracesGroup.setLayout(groupLayout);
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
group.setLayout(groupLayout);
}
@Override

View file

@ -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);
}
}

View file

@ -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 {
/**

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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$
}

View file

@ -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();

View file

@ -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 }

View file

@ -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 }