1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

Bug 179755 - Introduced mechanism to allow debuggers to specify a regex pattern specifying supported build configurations. This is used to set the defaults in the CDebuggerTab as well as the CApplicationLauchShortcut. A new debugger MinGW is introduced to take advantage of this and set the appropriate paths to the MinGW debugger.

This commit is contained in:
Doug Schaefer 2007-04-30 00:28:45 +00:00
parent cbf44a76fc
commit 021e897699
4 changed files with 73 additions and 70 deletions

View file

@ -19,13 +19,18 @@ import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.ICDebuggerPage;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
@ -106,23 +111,31 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
// user to choose one. // user to choose one.
int candidateCount = candidateConfigs.size(); int candidateCount = candidateConfigs.size();
if (candidateCount < 1) { if (candidateCount < 1) {
String programCPU = bin.getCPU(); // Set the default debugger based on the active toolchain on the project (if possible)
// Try default debugger first
ICDebugConfiguration defaultConfig = CDebugCorePlugin.getDefault().getDefaultDebugConfiguration();
String os = Platform.getOS();
ICDebugConfiguration debugConfig = null; ICDebugConfiguration debugConfig = null;
if ( defaultConfig != null ) { IProject project = bin.getResource().getProject();
String platform = defaultConfig.getPlatform(); ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
if (defaultConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) { ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
if (platform.equals("*") || platform.equals(os)) { //$NON-NLS-1$ String configId = configDesc.getId();
if (defaultConfig.supportsCPU(programCPU)) ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
debugConfig = defaultConfig; outer: for (int i = 0; i < debugConfigs.length; ++i) {
} ICDebugConfiguration dc = debugConfigs[i];
} String[] patterns = dc.getSupportedBuildConfigPatterns();
if (patterns != null) {
for (int j = 0; j < patterns.length; ++j) {
if (configId.matches(patterns[j])) {
debugConfig = dc;
break outer;
}
}
}
} }
if ( debugConfig == null ) { if ( debugConfig == null ) {
// Prompt the user if more then 1 debugger. // Prompt the user if more then 1 debugger.
ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations(); String programCPU = bin.getCPU();
String os = Platform.getOS();
debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
List debugList = new ArrayList(debugConfigs.length); List debugList = new ArrayList(debugConfigs.length);
for (int i = 0; i < debugConfigs.length; i++) { for (int i = 0; i < debugConfigs.length; i++) {
String platform = debugConfigs[i].getPlatform(); String platform = debugConfigs[i].getPlatform();
@ -140,6 +153,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
debugConfig = chooseDebugConfig(debugConfigs, mode); debugConfig = chooseDebugConfig(debugConfigs, mode);
} }
} }
if (debugConfig != null) { if (debugConfig != null) {
configuration = createConfiguration(bin, debugConfig); configuration = createConfiguration(bin, debugConfig);
} }
@ -168,13 +182,19 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName())); configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName()));
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName()); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
wc.setMappedResources(new IResource[] {bin.getCProject().getProject()}); wc.setMappedResources(new IResource[] {bin.getResource()});
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_STOP_AT_MAIN, true);
wc.setAttribute( wc.setAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, 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());
// Load up the debugger page to set the defaults. There should probably be a separate
// extension point for this.
ICDebuggerPage page = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID());
page.setDefaults(wc);
config = wc.doSave(); config = wc.doSave();
} catch (CoreException ce) { } catch (CoreException ce) {
LaunchUIPlugin.log(ce); LaunchUIPlugin.log(ce);

View file

@ -15,6 +15,7 @@ import org.eclipse.cdt.launch.ui.CDebuggerTab;
import org.eclipse.cdt.launch.ui.CMainTab; import org.eclipse.cdt.launch.ui.CMainTab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab; import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.EnvironmentTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
@ -28,7 +29,7 @@ public class LocalRunLaunchConfigurationTabGroup extends AbstractLaunchConfigura
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
new CMainTab(true), new CMainTab(true),
new CArgumentsTab(), new CArgumentsTab(),
new MigratingCEnvironmentTab(), new EnvironmentTab(),
new CDebuggerTab(false), new CDebuggerTab(false),
new SourceLookupTab(), new SourceLookupTab(),
new CommonTab() new CommonTab()

View file

@ -1,52 +0,0 @@
/*******************************************************************************
* Copyright (c) 2005 QNX Software Systems 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:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
/*
* Created on Oct 21, 2004
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package org.eclipse.cdt.launch.internal.ui;
import java.util.Map;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.EnvironmentTab;
/**
* @deprecated - temporary class for while configs are migrated to new EnvironmentTab
*/
public class MigratingCEnvironmentTab extends EnvironmentTab {
/* (non-Javadoc)
* @see org.eclipse.cdt.launch.ui.CEnvironmentTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
*/
public void initializeFrom(ILaunchConfiguration config) {
if (config instanceof ILaunchConfigurationWorkingCopy) {
ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) config;
try {
Map map = wc.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
if (map != null) {
wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
}
} catch (CoreException e) {
}
}
super.initializeFrom(config);
}
}

View file

@ -24,6 +24,9 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
@ -223,10 +226,41 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
} }
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false);
ICDebugConfiguration dc = CDebugCorePlugin.getDefault().getDefaultDebugConfiguration();
if (dc != null) { // Set the default debugger based on the active toolchain on the project (if possible)
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, dc.getID()); String defaultDebugger = null;
try {
String projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
if (projectName.length() > 0) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
String configId = configDesc.getId();
ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
outer: for (int i = 0; i < debugConfigs.length; ++i) {
ICDebugConfiguration debugConfig = debugConfigs[i];
String[] patterns = debugConfig.getSupportedBuildConfigPatterns();
if (patterns != null) {
for (int j = 0; j < patterns.length; ++j) {
if (configId.matches(patterns[j])) {
defaultDebugger = debugConfig.getID();
break outer;
}
}
}
}
}
} catch (CoreException e) {
} }
if (defaultDebugger == null) {
ICDebugConfiguration dc = CDebugCorePlugin.getDefault().getDefaultDebugConfiguration();
if (dc != null) {
defaultDebugger = dc.getID();
}
}
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, defaultDebugger);
} }
public void initializeFrom(ILaunchConfiguration config) { public void initializeFrom(ILaunchConfiguration config) {