1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Bug 281970: No longer show the Debugger, Refresh and Source tabs for a Run Configuration. Also, make sure a Run configuration can be used for Debug and vice versa.

This commit is contained in:
Marc Khouzam 2010-05-14 01:50:46 +00:00
parent b3ddbdf187
commit fe3c6d028f
7 changed files with 182 additions and 16 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others. * Copyright (c) 2000, 2010 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
@ -41,6 +41,30 @@ public interface ICDTLaunchConfigurationConstants {
*/ */
public static final String ID_LAUNCH_C_POST_MORTEM = "org.eclipse.cdt.launch.postmortemLaunchType"; //$NON-NLS-1$ public static final String ID_LAUNCH_C_POST_MORTEM = "org.eclipse.cdt.launch.postmortemLaunchType"; //$NON-NLS-1$
/**
* Specifies the default launch delegate for a Local Debug session
* @since 7.0
*/
public static final String PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.localCLaunch"; //$NON-NLS-1$
/**
* Specifies the default launch delegate for an Attach Debug session
* @since 7.0
*/
public static final String PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.attachCLaunch"; //$NON-NLS-1$
/**
* Specifies the default launch delegate for a Post Mortem Debug session
* @since 7.0
*/
public static final String PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.coreCLaunch"; //$NON-NLS-1$
/**
* Specifies the default launch delegate for a Run mode session
* @since 7.0
*/
public static final String PREFERRED_RUN_LAUNCH_DELEGATE = "org.eclipse.cdt.cdi.launch.localCLaunch"; //$NON-NLS-1$
/** /**
* Identifier for the C/C++ program process type, which is annotated on processes created * Identifier for the C/C++ program process type, which is annotated on processes created
* by the C/C++ application launch delegate. * by the C/C++ application launch delegate.

View file

@ -32,6 +32,13 @@
type="org.eclipse.cdt.launch.applicationLaunchType" type="org.eclipse.cdt.launch.applicationLaunchType"
class="org.eclipse.cdt.debug.internal.ui.launch.PlaceHolderLaunchConfigurationTabGroup" class="org.eclipse.cdt.debug.internal.ui.launch.PlaceHolderLaunchConfigurationTabGroup"
id="org.eclipse.cdt.launch.applicationLaunchTabGroup"> id="org.eclipse.cdt.launch.applicationLaunchTabGroup">
<launchMode mode="debug"/>
</launchConfigurationTabGroup>
<launchConfigurationTabGroup
type="org.eclipse.cdt.launch.applicationLaunchType"
class="org.eclipse.cdt.debug.internal.ui.launch.PlaceHolderLaunchConfigurationTabGroup"
id="org.eclipse.cdt.launch.applicationRunLaunchTabGroup">
<launchMode mode="run"/>
</launchConfigurationTabGroup> </launchConfigurationTabGroup>
<launchConfigurationTabGroup <launchConfigurationTabGroup
type="org.eclipse.cdt.launch.attachLaunchType" type="org.eclipse.cdt.launch.attachLaunchType"

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2009 QNX Software Systems and others. * Copyright (c) 2005, 2010 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
@ -203,13 +203,24 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 {
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID()); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
// Workaround for bug 262840: select the standard CDT launcher by default. // Workaround for bug 262840
HashSet<String> set = new HashSet<String>(); try {
set.add(mode); HashSet<String> set = new HashSet<String>();
set.add(ILaunchManager.RUN_MODE);
ILaunchDelegate preferredDelegate = wc.getPreferredDelegate(set);
if (preferredDelegate == null) {
wc.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE);
}
} catch (CoreException e) {}
// We must also set the debug mode delegate because this configuration can be re-used
// in Debug mode.
try { try {
HashSet<String> set = new HashSet<String>();
set.add(ILaunchManager.DEBUG_MODE);
ILaunchDelegate preferredDelegate = wc.getPreferredDelegate(set); ILaunchDelegate preferredDelegate = wc.getPreferredDelegate(set);
if (preferredDelegate == null) { if (preferredDelegate == null) {
wc.setPreferredLaunchDelegate(set, "org.eclipse.cdt.dsf.gdb.launch.localCLaunch"); wc.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE);
} }
} catch (CoreException e) {} } catch (CoreException e) {}
// End workaround for bug 262840 // End workaround for bug 262840

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008 Wind River Systems and others. * Copyright (c) 2008, 2010 Wind River 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
@ -11,6 +11,9 @@
package org.eclipse.cdt.dsf.gdb.internal.ui.launching; package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
import org.eclipse.cdt.dsf.gdb.service.SessionType; import org.eclipse.cdt.dsf.gdb.service.SessionType;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
/** /**
* Debugger tab to use for a local application launch configuration. * Debugger tab to use for a local application launch configuration.
@ -19,7 +22,43 @@ import org.eclipse.cdt.dsf.gdb.service.SessionType;
*/ */
public class LocalApplicationCDebuggerTab extends CDebuggerTab { public class LocalApplicationCDebuggerTab extends CDebuggerTab {
/*
* When the launch configuration is created for Run mode,
* this Debugger tab is not created because it is not used
* for Run mode but only for Debug mode.
* When we then open the same configuration in Debug mode, the launch
* configuration already exists and initializeFrom() is called
* instead of setDefaults().
* We therefore call setDefaults() ourselves and update the configuration.
* If we don't then the user will be required to press Apply to get the
* default settings saved.
* Bug 281970
*/
private boolean fSetDefaultCalled;
public LocalApplicationCDebuggerTab() { public LocalApplicationCDebuggerTab() {
super(SessionType.LOCAL, false); super(SessionType.LOCAL, false);
} }
@Override
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
fSetDefaultCalled = true;
super.setDefaults(config);
}
@Override
public void initializeFrom(ILaunchConfiguration config) {
if (fSetDefaultCalled == false) {
try {
ILaunchConfigurationWorkingCopy wc;
wc = config.getWorkingCopy();
setDefaults(wc);
wc.doSave();
} catch (CoreException e) {
}
}
super.initializeFrom(config);
}
} }

View file

@ -187,6 +187,39 @@
<associatedDelegate delegate="org.eclipse.cdt.cdi.launch.coreFileCLaunch"/> <associatedDelegate delegate="org.eclipse.cdt.cdi.launch.coreFileCLaunch"/>
<placement after="org.eclipse.debug.ui.sourceLookupTab"/> <placement after="org.eclipse.debug.ui.sourceLookupTab"/>
</tab> </tab>
<!-- Run launch tabs-->
<tab
id="org.eclipse.cdt.cdi.launch.runApplicationLaunch.mainTab"
group="org.eclipse.cdt.launch.applicationRunLaunchTabGroup"
name="%MainLaunchTab.name"
class="org.eclipse.cdt.launch.ui.CMainTab">
<associatedDelegate delegate="org.eclipse.cdt.cdi.launch.localCLaunch"/>
</tab>
<tab
id="org.eclipse.cdt.cdi.launch.runApplicationLaunch.argumentsTab"
group="org.eclipse.cdt.launch.applicationRunLaunchTabGroup"
name="%ArgumentsLaunchTab.name"
class="org.eclipse.cdt.launch.ui.CArgumentsTab">
<associatedDelegate delegate="org.eclipse.cdt.cdi.launch.localCLaunch"/>
<placement after="org.eclipse.cdt.cdi.launch.mainTab"/>
</tab>
<tab
id="org.eclipse.cdt.cdi.launch.runApplicationLaunch.environmentTab"
group="org.eclipse.cdt.launch.applicationRunLaunchTabGroup"
name="%EnvironmentLaunchTab.name"
class="org.eclipse.debug.ui.EnvironmentTab">
<associatedDelegate delegate="org.eclipse.cdt.cdi.launch.localCLaunch"/>
<placement after="org.eclipse.cdt.cdi.launch.argumentsTab"/>
</tab>
<tab
id="org.eclipse.cdt.cdi.launch.runApplicationLaunch.commonTab"
group="org.eclipse.cdt.launch.applicationRunLaunchTabGroup"
name="%CommonLaunchTab.name"
class="org.eclipse.debug.ui.CommonTab">
<associatedDelegate delegate="org.eclipse.cdt.cdi.launch.localCLaunch"/>
<placement after="org.eclipse.debug.ui.environmentTab"/>
</tab>
</extension> </extension>
<extension <extension
point="org.eclipse.debug.core.statusHandlers"> point="org.eclipse.debug.core.statusHandlers">

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008 Wind River Systems and others. * Copyright (c) 2008, 2010 Wind River 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
@ -10,13 +10,53 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.launch.ui; package org.eclipse.cdt.launch.ui;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
/** /**
* CDebugger tab to use for an application launch configuration. * CDebugger tab to use for an application launch configuration.
* *
* @since 6.0 * @since 6.0
*/ */
public class ApplicationCDebuggerTab extends CDebuggerTab { public class ApplicationCDebuggerTab extends CDebuggerTab {
public ApplicationCDebuggerTab() { /*
* When the launch configuration is created for Run mode,
* this Debugger tab is not created because it is not used
* for Run mode but only for Debug mode.
* When we then open the same configuration in Debug mode, the launch
* configuration already exists and initializeFrom() is called
* instead of setDefaults().
* We therefore call setDefaults() ourselves and update the configuration.
* If we don't then the user will be required to press Apply to get the
* default settings saved.
* Bug 281970
*/
private boolean fSetDefaultCalled;
public ApplicationCDebuggerTab() {
super (false); super (false);
} }
@Override
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
fSetDefaultCalled = true;
super.setDefaults(config);
}
@Override
public void initializeFrom(ILaunchConfiguration config) {
if (fSetDefaultCalled == false) {
try {
ILaunchConfigurationWorkingCopy wc;
wc = config.getWorkingCopy();
setDefaults(wc);
wc.doSave();
} catch (CoreException e) {
}
}
super.initializeFrom(config);
}
} }

View file

@ -35,6 +35,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchDelegate; import org.eclipse.debug.core.ILaunchDelegate;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
@ -534,19 +535,30 @@ public class CMainTab extends CAbstractMainTab {
*/ */
public void setDefaults(ILaunchConfigurationWorkingCopy config) { public void setDefaults(ILaunchConfigurationWorkingCopy config) {
// Workaround for bug 262840: select the standard CDT launcher by default. // Workaround for bug 262840
HashSet<String> set = new HashSet<String>();
set.add(getLaunchConfigurationDialog().getMode());
try { try {
HashSet<String> set = new HashSet<String>();
set.add(ILaunchManager.DEBUG_MODE);
ILaunchDelegate preferredDelegate = config.getPreferredDelegate(set); ILaunchDelegate preferredDelegate = config.getPreferredDelegate(set);
if (preferredDelegate == null) { if (preferredDelegate == null) {
if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP)) { if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP)) {
config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.dsf.gdb.launch.localCLaunch"); //$NON-NLS-1$ config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE);
} else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH)) { } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH)) {
config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.dsf.gdb.launch.attachCLaunch"); //$NON-NLS-1$ config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE);
} else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM)) { } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM)) {
config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.dsf.gdb.launch.coreCLaunch"); //$NON-NLS-1$ config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE);
} }
}
} catch (CoreException e) {}
// We must also set the preferred delegate for Run mode, because this configuration
// can be used in Run mode.
try {
HashSet<String> set = new HashSet<String>();
set.add(ILaunchManager.RUN_MODE);
ILaunchDelegate preferredDelegate = config.getPreferredDelegate(set);
if (preferredDelegate == null) {
config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE);
} }
} catch (CoreException e) {} } catch (CoreException e) {}