1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Bug 120162 - Allow to specify the default version of gdb. Patch by Marc-Andre Laperle.

This commit is contained in:
Sergey Prigogin 2010-11-21 18:25:40 +00:00
parent 61a30ea7ad
commit 0a51630f81
7 changed files with 112 additions and 22 deletions

View file

@ -16,10 +16,13 @@ import java.util.Observer;
import org.eclipse.cdt.debug.ui.AbstractCDebuggerPage;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@ -63,10 +66,11 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore();
String defaultGdbCommand = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND);
String defaultGdbInit = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, defaultGdbInit);
if (fSolibBlock != null)
fSolibBlock.setDefaults(configuration);
@ -88,18 +92,20 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ
public void initializeFrom(ILaunchConfiguration configuration) {
setInitializing(true);
String gdbCommand = IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT;
String gdbInit = IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT;
IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore();
String defaultGdbCommand = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND);
String defaultGdbInit = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT);
String gdbCommand = defaultGdbCommand;
String gdbInit = defaultGdbInit;
try {
gdbCommand = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
gdbCommand = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand);
}
catch(CoreException e) {
}
try {
gdbInit = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
gdbInit = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, defaultGdbInit);
}
catch(CoreException e) {
}

View file

@ -17,11 +17,13 @@ import java.util.Observer;
import org.eclipse.cdt.debug.ui.AbstractCDebuggerPage;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@ -66,10 +68,11 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer {
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore();
String defaultGdbCommand = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND);
String defaultGdbInit = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, defaultGdbInit);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE,
@ -116,10 +119,11 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer {
public void initializeFrom(ILaunchConfiguration configuration) {
setInitializing(true);
String gdbCommand = getStringAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
String gdbInit = getStringAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore();
String defaultGdbCommand = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND);
String defaultGdbInit = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT);
String gdbCommand = getStringAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand);
String gdbInit = getStringAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, defaultGdbInit);
boolean nonStopMode = getBooleanAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
boolean reverseEnabled = getBooleanAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE,

View file

@ -11,12 +11,16 @@
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences;
import java.io.File;
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@ -24,6 +28,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@ -77,9 +82,51 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
layout.marginWidth= 0;
parent.setLayout(layout);
Group group= new Group(parent, SWT.NONE);
Group group = new Group(parent, SWT.NONE);
group.setText(MessagesForPreferences.GdbDebugPreferencePage_defaults_label);
GridLayout groupLayout = new GridLayout(3, false);
group.setLayout(groupLayout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final StringFieldEditor stringFieldEditorCommand = new StringFieldEditor(
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,
LaunchUIMessages.getString("GDBDebuggerPage.gdb_debugger"), //$NON-NLS-1$
group);
stringFieldEditorCommand.fillIntoGrid(group, 2);
addField(stringFieldEditorCommand);
Button browsebutton = new Button(group, SWT.PUSH);
browsebutton.setText(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse")); //$NON-NLS-1$
browsebutton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleBrowseButtonSelected(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse_dlg_title"), //$NON-NLS-1$
stringFieldEditorCommand);
}
});
final StringFieldEditor stringFieldEditorGdbInit = new StringFieldEditor(
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT,
LaunchUIMessages.getString("GDBDebuggerPage.gdb_command_file"), //$NON-NLS-1$
group);
stringFieldEditorGdbInit.fillIntoGrid(group, 2);
addField(stringFieldEditorGdbInit);
browsebutton = new Button(group, SWT.PUSH);
browsebutton.setText(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse")); //$NON-NLS-1$
browsebutton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleBrowseButtonSelected(LaunchUIMessages.getString("GDBDebuggerPage.gdb_cmdfile_dlg_title"), //$NON-NLS-1$
stringFieldEditorGdbInit);
}
});
group.setLayout(groupLayout);
group= new Group(parent, SWT.NONE);
group.setText(MessagesForPreferences.GdbDebugPreferencePage_traces_label);
GridLayout groupLayout= new GridLayout(3, false);
groupLayout= new GridLayout(3, false);
group.setLayout(groupLayout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@ -175,6 +222,21 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
indentHelper.setLayout(helperLayout);
group.setLayout(groupLayout);
}
private void handleBrowseButtonSelected(final String dialogTitle, final StringFieldEditor stringFieldEditor) {
FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
dialog.setText(dialogTitle);
String gdbCommand = stringFieldEditor.getStringValue().trim();
int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
dialog.setFilterPath(gdbCommand.substring(0, lastSeparatorIndex));
}
String res = dialog.open();
if (res == null) {
return;
}
stringFieldEditor.setStringValue(res);
}
@Override
protected void adjustGridLayout() {

View file

@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
@ -28,5 +29,7 @@ public class GdbPreferenceInitializer extends AbstractPreferenceInitializer {
store.setDefault(IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER, true);
store.setDefault(IGdbDebugPreferenceConstants.PREF_ENABLE_PRETTY_PRINTING, true);
store.setDefault(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, 100);
store.setDefault(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND, IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
store.setDefault(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT, IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
}
}

View file

@ -32,7 +32,8 @@ class MessagesForPreferences extends NLS {
public static String GdbDebugPreferencePage_enablePrettyPrinting_label2;
/** @since 3.0 */
public static String GdbDebugPreferencePage_initialChildCountLimitForCollections_label;
/** @since 3.0 */
public static String GdbDebugPreferencePage_defaults_label;
static {
// initialize resource bundle
NLS.initializeMessages(MessagesForPreferences.class.getName(), MessagesForPreferences.class);

View file

@ -25,3 +25,5 @@ GdbDebugPreferencePage_prettyPrinting_label=Pretty Printing
GdbDebugPreferencePage_enablePrettyPrinting_label1=Enable pretty printers in variable/expression tree
GdbDebugPreferencePage_enablePrettyPrinting_label2=(requires python-enabled GDB)
GdbDebugPreferencePage_initialChildCountLimitForCollections_label=For collections, initially limit child count to
GdbDebugPreferencePage_defaults_label=Debug Configurations Defaults

View file

@ -50,6 +50,18 @@ public interface IGdbDebugPreferenceConstants {
* @since 4.0
*/
public static final String PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS = "initialChildCountLimitForCollections"; //$NON-NLS-1$
/**
* The default command for gdb
* @since 4.0
*/
public static final String PREF_DEFAULT_GDB_COMMAND = "defaultGdbCommand"; //$NON-NLS-1$
/**
* The default command file for gdb
* @since 4.0
*/
public static final String PREF_DEFAULT_GDB_INIT = "defaultGdbInit"; //$NON-NLS-1$
/**
* Help prefixes.