1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 15:25:49 +02:00

Bug 347245 - Add configurable defaults for Stop in main and for Non-stop mode. Use global preferences for Debug As command.

This commit is contained in:
Sergey Prigogin 2011-05-27 00:08:55 +00:00
parent 3a5209e6ff
commit 56b100f37c
4 changed files with 54 additions and 18 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 QNX Software Systems and others. * Copyright (c) 2005, 2011 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -195,7 +195,6 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 {
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName()); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
wc.setMappedResources(new IResource[] { bin.getResource().getProject() }); wc.setMappedResources(new IResource[] { bin.getResource().getProject() });
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID()); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2010 Ericsson and others. * Copyright (c) 2008, 2011 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
* Nokia - create and use backend service. * Nokia - create and use backend service.
* IBM Corporation * IBM Corporation
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.launching; package org.eclipse.cdt.dsf.gdb.launching;
@ -48,7 +49,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
public class FinalLaunchSequence extends ReflectionSequence { public class FinalLaunchSequence extends ReflectionSequence {
// The launchConfiguration attributes // The launchConfiguration attributes
private Map<String, Object> fAttributes; private Map<String, Object> fAttributes;
@ -256,7 +256,7 @@ public class FinalLaunchSequence extends ReflectionSequence {
boolean isNonStop = CDebugUtils.getAttribute( boolean isNonStop = CDebugUtils.getAttribute(
fAttributes, fAttributes,
IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT); LaunchUtils.getIsNonStopModeDefault());
// GDBs that don't support non-stop don't allow you to set it to false. // GDBs that don't support non-stop don't allow you to set it to false.
// We really should set it to false when GDB supports it though. // We really should set it to false when GDB supports it though.

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Ericsson - Initial API and implementation * Ericsson - Initial API and implementation
* Ericsson - Added support for Mac OS * Ericsson - Added support for Mac OS
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.launching; package org.eclipse.cdt.dsf.gdb.launching;
@ -57,6 +58,8 @@ import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
public class LaunchUtils { 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 * A prefix that we use to indicate that a GDB version is for MAC OS
* @since 3.0 * @since 3.0
@ -210,7 +213,7 @@ public class LaunchUtils {
} }
public static IPath getGDBPath(ILaunchConfiguration configuration) { public static IPath getGDBPath(ILaunchConfiguration configuration) {
String defaultGdbCommand = Platform.getPreferencesService().getString("org.eclipse.cdt.dsf.gdb.ui", //$NON-NLS-1$ String defaultGdbCommand = Platform.getPreferencesService().getString(GDB_UI_PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND, IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,
IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT, null); IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT, null);
@ -428,24 +431,56 @@ public class LaunchUtils {
} }
/** /**
* This methods return true if the launch is meant to be in Non-Stop mode. * Returns <code>true</code> if the launch is meant to be in Non-Stop mode.
* Returns false otherwise. * Returns <code>false</code> otherwise.
* *
* @since 4.0 * @since 4.0
*/ */
public static boolean getIsNonStopMode(ILaunchConfiguration config) { public static boolean getIsNonStopMode(ILaunchConfiguration config) {
try { try {
boolean nonStopMode = config.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP, return config.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT); getIsNonStopModeDefault());
return nonStopMode;
} catch (CoreException e) { } catch (CoreException e) {
} }
return false; return false;
} }
/** /**
* This methods return true if the launch is meant to be for post-mortem * Returns workspace-level default for the Non-Stop mode.
* tracing. Returns false otherwise. *
* @since 4.0
*/
public static boolean getIsNonStopModeDefault() {
return Platform.getPreferencesService().getBoolean(GDB_UI_PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP,
IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT, null);
}
/**
* Returns workspace-level default for the Stop in main option.
*
* @since 4.0
*/
public static boolean getStopInMainDefault() {
return Platform.getPreferencesService().getBoolean(GDB_UI_PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN,
ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT, null);
}
/**
* Returns workspace-level default for the Stop in main symbol.
*
* @since 4.0
*/
public static String getStopInMainSymbolDefault() {
return Platform.getPreferencesService().getString(GDB_UI_PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL,
ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT, null);
}
/**
* Returns <code>true</code> if the launch is meant to be for post-mortem
* tracing. Returns <code>false</code> otherwise.
* *
* @since 4.0 * @since 4.0
*/ */

View file

@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Ericsson - initial API and implementation * Ericsson - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service; package org.eclipse.cdt.dsf.gdb.service;
@ -30,6 +31,7 @@ import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants; import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.launching.InferiorRuntimeProcess; import org.eclipse.cdt.dsf.gdb.launching.InferiorRuntimeProcess;
import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils;
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.mi.service.IMICommandControl; import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
@ -104,7 +106,6 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence {
return fUserBreakpointIsOnMain; return fUserBreakpointIsOnMain;
} }
public StartOrRestartProcessSequence_7_0(DsfExecutor executor, IContainerDMContext containerDmc, public StartOrRestartProcessSequence_7_0(DsfExecutor executor, IContainerDMContext containerDmc,
Map<String, Object> attributes, boolean restart, DataRequestMonitor<IContainerDMContext> rm) { Map<String, Object> attributes, boolean restart, DataRequestMonitor<IContainerDMContext> rm) {
super(executor, rm); super(executor, rm);
@ -183,21 +184,22 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence {
} }
/** /**
* If the user requested a 'stopOnMain', let's set the temporary breakpoint * If the user requested a 'stopAtMain', let's set the temporary breakpoint
* where the user specified. * where the user specified.
*/ */
@Execute @Execute
public void stepInsertStopOnMainBreakpoint(final RequestMonitor rm) { public void stepInsertStopOnMainBreakpoint(final RequestMonitor rm) {
boolean userRequestedStop = CDebugUtils.getAttribute(fAttributes, boolean userRequestedStop = CDebugUtils.getAttribute(fAttributes,
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN,
false); LaunchUtils.getStopInMainDefault());
if (userRequestedStop) { if (userRequestedStop) {
String userStopSymbol = CDebugUtils.getAttribute(fAttributes, String userStopSymbol = CDebugUtils.getAttribute(fAttributes,
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL,
ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT); LaunchUtils.getStopInMainSymbolDefault());
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(getContainerContext(), IBreakpointsTargetDMContext.class); IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(getContainerContext(),
IBreakpointsTargetDMContext.class);
fCommandControl.queueCommand( fCommandControl.queueCommand(
fCommandFactory.createMIBreakInsert(bpTargetDmc, true, false, null, 0, userStopSymbol, 0), fCommandFactory.createMIBreakInsert(bpTargetDmc, true, false, null, 0, userStopSymbol, 0),