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

Bug 348159: Move DSF-GDB preference store to the core plugin.

This commit is contained in:
Marc Khouzam 2011-06-27 16:23:53 -04:00
parent 9b697ac5a0
commit 5343d22eea
14 changed files with 90 additions and 78 deletions

View file

@ -291,12 +291,6 @@
name="%gdbPreferencePage.name">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.eclipse.cdt.dsf.gdb.internal.ui.preferences.GdbPreferenceInitializer">
</initializer>
</extension>
<extension
point="org.eclipse.debug.ui.contextViewBindings">

View file

@ -11,18 +11,22 @@
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.internal.ui.console.TracingConsoleManager;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext;
/**
@ -39,6 +43,9 @@ public class GdbUIPlugin extends AbstractUIPlugin {
private static BundleContext fgBundleContext;
private static TracingConsoleManager fTracingConsoleManager;
private static IPreferenceStore fCorePreferenceStore;
/**
* The constructor
*/
@ -97,6 +104,18 @@ public class GdbUIPlugin extends AbstractUIPlugin {
return fgBundleContext;
}
/**
* Returns the preference store for this UI plug-in.
* It actually uses the preference store of the core plug-in.
*/
@Override
public IPreferenceStore getPreferenceStore() {
if (fCorePreferenceStore == null) {
fCorePreferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, GdbPlugin.PLUGIN_ID);
}
return fCorePreferenceStore;
}
/**
* copied from org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
*/

View file

@ -251,9 +251,8 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
childCountLimitField.setValidRange(1, 10000);
childCountLimitField.fillIntoGrid(indentHelper, 3);
IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore();
boolean prettyPrintingEnabled =
store.getBoolean(IGdbDebugPreferenceConstants.PREF_ENABLE_PRETTY_PRINTING);
getPreferenceStore().getBoolean(IGdbDebugPreferenceConstants.PREF_ENABLE_PRETTY_PRINTING);
childCountLimitField.setEnabled(prettyPrintingEnabled, indentHelper);
addField(childCountLimitField);

View file

@ -1,41 +0,0 @@
/*******************************************************************************
* Copyright (c) 2009, 2011 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 API and implementation
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
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;
import org.eclipse.jface.preference.IPreferenceStore;
/**
* Initialize the GDB preferences.
*/
public class GdbPreferenceInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore();
store.setDefault(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, true);
store.setDefault(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, 500000);
store.setDefault(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true);
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);
store.setDefault(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT);
store.setDefault(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
store.setDefault(IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
}
}

View file

@ -19,7 +19,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.cdt.dsf.gdb,
org.eclipse.cdt.dsf.gdb.actions,
org.eclipse.cdt.dsf.gdb.breakpoints,
org.eclipse.cdt.dsf.gdb.internal;x-internal:=true,
org.eclipse.cdt.dsf.gdb.internal;x-friends:="org.eclipse.cdt.dsf.gdb.ui,org.eclipse.cdt.debug.gdbjtag.ui",
org.eclipse.cdt.dsf.gdb.internal.commands;x-internal:=true,
org.eclipse.cdt.dsf.gdb.internal.memory;x-internal:=true,
org.eclipse.cdt.dsf.gdb.internal.service.command.events;x-internal:=true,

View file

@ -61,5 +61,10 @@
contextId="org.eclipse.cdt.debug.ui.debugging"
debugModelId="org.eclipse.cdt.dsf.gdb"/>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.eclipse.cdt.dsf.gdb.internal.GdbPreferenceInitializer">
</initializer>
</extension>
</plugin>

View file

@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2009, 2011 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 API and implementation
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
* Sergey Prigogin (Google)
* Marc Khouzam (Ericsson) - Move to org.eclipse.cdt.dsf.gdb from UI plugin (bug 348159)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
/**
* Initialize the GDB preferences.
*/
public class GdbPreferenceInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
IEclipsePreferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, true);
node.putInt(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, 500000);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER, true);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_ENABLE_PRETTY_PRINTING, true);
node.putInt(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, 100);
node.put(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND, IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
node.put(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT, IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT);
node.put(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
}
}

View file

@ -197,7 +197,7 @@ public class FinalLaunchSequence extends ReflectionSequence {
*/
@Execute
public void stepEnablePrettyPrinting(final RequestMonitor requestMonitor) {
if (Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
if (Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_ENABLE_PRETTY_PRINTING,
false, null)) {

View file

@ -58,8 +58,6 @@ import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunchConfiguration;
public class LaunchUtils {
private static final String GDB_UI_PLUGIN_ID = "org.eclipse.cdt.dsf.gdb.ui"; //$NON-NLS-1$
/**
* A prefix that we use to indicate that a GDB version is for MAC OS
* @since 3.0
@ -213,7 +211,7 @@ public class LaunchUtils {
}
public static IPath getGDBPath(ILaunchConfiguration configuration) {
String defaultGdbCommand = Platform.getPreferencesService().getString(GDB_UI_PLUGIN_ID,
String defaultGdbCommand = Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,
IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT, null);
@ -439,13 +437,7 @@ public class LaunchUtils {
public static boolean getIsNonStopMode(ILaunchConfiguration config) {
try {
return config.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
// This call causes a race condition with the TraceControlManager
// Don't use it for now, until we find a fix.
// Consequence is that a Debug As->C/C++ application shortcut will not follow
// the preference for non-stop. This is not as bad as not have the gdb traces
// Bug 348159
IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
// getIsNonStopModeDefault());
getIsNonStopModeDefault());
} catch (CoreException e) {
}
return false;
@ -457,7 +449,7 @@ public class LaunchUtils {
* @since 4.0
*/
public static boolean getIsNonStopModeDefault() {
return Platform.getPreferencesService().getBoolean(GDB_UI_PLUGIN_ID,
return Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP,
IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT, null);
}
@ -468,7 +460,7 @@ public class LaunchUtils {
* @since 4.0
*/
public static boolean getStopAtMainDefault() {
return Platform.getPreferencesService().getBoolean(GDB_UI_PLUGIN_ID,
return Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN,
ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT, null);
}
@ -479,7 +471,7 @@ public class LaunchUtils {
* @since 4.0
*/
public static String getStopAtMainSymbolDefault() {
return Platform.getPreferencesService().getString(GDB_UI_PLUGIN_ID,
return Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL,
ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT, null);
}

View file

@ -201,7 +201,7 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
public String getGDBInitFile() throws CoreException {
if (fGDBInitFile == null) {
String defaultGdbInit = Platform.getPreferencesService().getString("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
String defaultGdbInit = Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT,
IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT, null);

View file

@ -362,7 +362,7 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses {
// Also, for a core session, there is no concept of killing the inferior,
// so lets kill GDB
if (fBackend.getSessionType() == SessionType.CORE ||
Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
true, null)) {
fGdb.terminate(rm);
@ -635,7 +635,7 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses {
if (e.getDMContext() instanceof IContainerDMContext) {
fConnected = false;
if (Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
if (Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
true, null)) {
// If the inferior finishes, let's terminate GDB

View file

@ -1189,7 +1189,7 @@ public class GDBProcesses_7_0 extends AbstractDsfService
// so lets kill GDB
if (fBackend.getSessionType() == SessionType.CORE ||
(fNumConnected == 1 &&
Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
true, null))) {
fCommandControl.terminate(rm);
@ -1405,7 +1405,7 @@ public class GDBProcesses_7_0 extends AbstractDsfService
assert fNumConnected > 0;
fNumConnected--;
if (Platform.getPreferencesService().getBoolean("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
if (Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
true, null)) {
if (fNumConnected == 0 && !fProcRestarting) {

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExitedDMEvent;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses;
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
@ -109,7 +110,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test
public void restartWhileTargetRunningKillGDB() throws Throwable {
// First set the preference to kill GDB (although it should not happen in this test)
Preferences node = DefaultScope.INSTANCE.getNode("org.eclipse.cdt.dsf.gdb.ui");
Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true);
// The target is currently stopped. We resume to get it running
@ -132,7 +133,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test
public void restartWhileTargetRunningGDBAlive() throws Throwable {
// First set the preference not to kill gdb
Preferences node = DefaultScope.INSTANCE.getNode("org.eclipse.cdt.dsf.gdb.ui");
Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, false);
// The target is currently stopped. We resume to get it running
@ -155,7 +156,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test
public void terminateWhileTargetRunningKillGDB() throws Throwable {
// First set the preference to kill GDB
Preferences node = DefaultScope.INSTANCE.getNode("org.eclipse.cdt.dsf.gdb.ui");
Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true);
// The target is currently stopped. We resume to get it running
@ -192,7 +193,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test
public void terminateWhileTargetRunningKeepGDBAlive() throws Throwable {
// First set the preference not to kill gdb
Preferences node = DefaultScope.INSTANCE.getNode("org.eclipse.cdt.dsf.gdb.ui");
Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, false);
// The target is currently stopped. We resume to get it running
@ -244,7 +245,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test
public void detachWhileTargetRunningKillGDB() throws Throwable {
// First set the preference to kill GDB
Preferences node = DefaultScope.INSTANCE.getNode("org.eclipse.cdt.dsf.gdb.ui");
Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true);
// The target is currently stopped. We resume to get it running
@ -280,7 +281,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test
public void detachWhileTargetRunningGDBAlive() throws Throwable {
// First set the preference not to kill gdb
Preferences node = DefaultScope.INSTANCE.getNode("org.eclipse.cdt.dsf.gdb.ui");
Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, false);
// The target is currently stopped. We resume to get it running

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.debug.mi.core.command.factories.CommandFactoryDescriptor;
import org.eclipse.cdt.debug.mi.core.command.factories.CommandFactoryManager;
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.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration;
@ -362,7 +363,7 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
public void initializeFrom(ILaunchConfiguration configuration) {
try {
String defaultGdbCommand = Platform.getPreferencesService().getString("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
String defaultGdbCommand = Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,"", null); //$NON-NLS-1$
String gdbCommandAttr = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand);
gdbCommand.setText(gdbCommandAttr);
@ -453,7 +454,7 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
String defaultGdbCommand = Platform.getPreferencesService().getString("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$
String defaultGdbCommand = Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND, "", null); //$NON-NLS-1$
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand);