1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

removed runtime.compatablity dependency

build on launch should now be scoped to referenced projects only.
update launch tab interaction to use new 3.0 methods
This commit is contained in:
David Inglis 2004-05-18 16:43:58 +00:00
parent b458ecd917
commit aa2dc61d05
11 changed files with 485 additions and 235 deletions

View file

@ -24,7 +24,7 @@
<import plugin="org.eclipse.cdt.debug.core"/>
<import plugin="org.eclipse.cdt.debug.ui"/>
<import plugin="org.eclipse.core.boot"/>
<import plugin="org.eclipse.core.runtime.compatibility"/>
<import plugin="org.eclipse.core.runtime"/>
</requires>

View file

@ -1,6 +1,5 @@
/*
* (c) Copyright QNX Software System Ltd. 2002.
* All Rights Reserved.
* (c) Copyright QNX Software System Ltd. 2002. All Rights Reserved.
*/
package org.eclipse.cdt.launch;
@ -9,14 +8,18 @@ import java.io.FileNotFoundException;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
@ -26,8 +29,11 @@ import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@ -40,25 +46,34 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import org.eclipse.debug.core.model.IPersistableSourceLocator;
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDelegate {
abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegate {
abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException;
protected static final IStatus complileErrorPromptStatus = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 202, "", null); //$NON-NLS-1$ //$NON-NLS-2$
/**
* Return the save environment variables in the configuration.
* The array does not include the default environment of the target.
* array[n] : name=value
* The project containing the programs file being launched
*/
private IProject project;
/**
* A list of prequisite projects ordered by their build order.
*/
private List orderedProjects;
abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException;
/**
* Return the save environment variables in the configuration. The array does not include the default environment of the target.
* array[n] : name=value
*/
protected String[] getEnvironmentArray(ILaunchConfiguration config) {
Map env = null;
try {
env = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
}
catch (CoreException e) {
} catch (CoreException e) {
}
if (env == null) {
return new String[0];
@ -74,8 +89,8 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
}
/**
* Return the save environment variables of this configuration.
* The array does not include the default environment of the target.
* Return the save environment variables of this configuration. The array does not include the default environment of the
* target.
*/
protected Properties getEnvironmentProperty(ILaunchConfiguration config) {
Properties prop = new Properties();
@ -103,20 +118,16 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
}
/**
* Expand the variable with the format ${key}. example:
* HOME=/foobar
* NEWHOME = ${HOME}/project
* The environement NEWHOME will be /foobar/project.
* Expand the variable with the format ${key}. example: HOME=/foobar NEWHOME = ${HOME}/project The environement NEWHOME will be
* /foobar/project.
*/
protected Properties expandEnvironment(ILaunchConfiguration config ) {
protected Properties expandEnvironment(ILaunchConfiguration config) {
return expandEnvironment(getEnvironmentProperty(config));
}
/**
* Expand the variable with the format ${key}. example:
* HOME=/foobar
* NEWHOME = ${HOME}/project
* The environement NEWHOME will be /foobar/project.
* Expand the variable with the format ${key}. example: HOME=/foobar NEWHOME = ${HOME}/project The environement NEWHOME will be
* /foobar/project.
*/
protected Properties expandEnvironment(Properties props) {
Enumeration names = props.propertyNames();
@ -135,11 +146,11 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
for (int i = 0; i < value.length(); i++) {
ch = value.charAt(i);
switch (ch) {
case '\'':
case '\'' :
if (prev != '\\') {
inSingleQuote = !inSingleQuote;
}
break;
break;
case '$' :
if (!inSingleQuote && prev != '\\') {
@ -153,15 +164,15 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
}
}
}
break;
break;
case '}' :
if (inMacro) {
inMacro = false;
String v = null;
String p = param.toString();
/* Search in the current property only
* if it is not the same name.
/*
* Search in the current property only if it is not the same name.
*/
if (!p.equals(key)) {
v = props.getProperty(p);
@ -181,7 +192,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
prev = ch;
continue;
}
break;
break;
} /* switch */
if (!inMacro) {
@ -202,27 +213,27 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
}
/**
* Returns the working directory specified by
* the given launch configuration, or <code>null</code> if none.
* Returns the working directory specified by the given launch configuration, or <code>null</code> if none.
*
* @deprecated Should use getWorkingDirectory()
* @param configuration launch configuration
* @return the working directory specified by the given
* launch configuration, or <code>null</code> if none
* @exception CoreException if unable to retrieve the attribute
* @param configuration
* launch configuration
* @return the working directory specified by the given launch configuration, or <code>null</code> if none
* @exception CoreException
* if unable to retrieve the attribute
*/
public File getWorkingDir(ILaunchConfiguration configuration) throws CoreException {
return getWorkingDirectory(configuration);
}
/**
* Returns the working directory specified by
* the given launch configuration, or <code>null</code> if none.
* Returns the working directory specified by the given launch configuration, or <code>null</code> if none.
*
* @param configuration launch configuration
* @return the working directory specified by the given
* launch configuration, or <code>null</code> if none
* @exception CoreException if unable to retrieve the attribute
* @param configuration
* launch configuration
* @return the working directory specified by the given launch configuration, or <code>null</code> if none
* @exception CoreException
* if unable to retrieve the attribute
*/
public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
return verifyWorkingDirectory(configuration);
@ -237,17 +248,19 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
}
/**
* Throws a core exception with an error status object built from
* the given message, lower level exception, and error code.
* Throws a core exception with an error status object built from the given message, lower level exception, and error code.
*
* @param message the status message
* @param exception lower level exception associated with the
* error, or <code>null</code> if none
* @param code error code
* @param message
* the status message
* @param exception
* lower level exception associated with the error, or <code>null</code> if none
* @param code
* error code
*/
protected void abort(String message, Throwable exception, int code) throws CoreException {
MultiStatus status = new MultiStatus(getPluginID(),code, message,exception);
status.add(new Status(IStatus.ERROR,getPluginID(),code, exception == null ? "" : exception.getLocalizedMessage(),exception)); //$NON-NLS-1$
MultiStatus status = new MultiStatus(getPluginID(), code, message, exception);
status.add(new Status(IStatus.ERROR, getPluginID(), code, exception == null ? "" : exception.getLocalizedMessage(), //$NON-NLS-1$
exception));
throw new CoreException(status);
}
@ -284,9 +297,12 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
* Assigns a default source locator to the given launch if a source locator has not yet been assigned to it, and the associated
* launch configuration does not specify a source locator.
*
* @param launch launch object
* @param configuration configuration being launched
* @exception CoreException if unable to set the source locator
* @param launch
* launch object
* @param configuration
* configuration being launched
* @exception CoreException
* if unable to set the source locator
*/
protected void setSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException {
// set default source locator if none specified
@ -296,13 +312,14 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
if (id == null) {
ICProject cProject = getCProject(configuration);
if (cProject == null) {
abort(LaunchUIPlugin.getResourceString("Launch.common.Project_does_not_exist"), null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); //$NON-NLS-1$
abort(LaunchUIPlugin.getResourceString("Launch.common.Project_does_not_exist"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
}
sourceLocator = CDebugUIPlugin.createDefaultSourceLocator();
sourceLocator.initializeDefaults(configuration);
} else {
sourceLocator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(id);
String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String) null);
if (memento == null) {
sourceLocator.initializeDefaults(configuration);
} else {
@ -343,15 +360,10 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
protected ICDebugConfiguration getDebugConfig(ILaunchConfiguration config) throws CoreException {
ICDebugConfiguration dbgCfg = null;
try {
dbgCfg =
CDebugCorePlugin.getDefault().getDebugConfiguration(
dbgCfg = CDebugCorePlugin.getDefault().getDebugConfiguration(
config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "")); //$NON-NLS-1$
}
catch (CoreException e) {
IStatus status =
new Status(
IStatus.ERROR,
LaunchUIPlugin.getUniqueIdentifier(),
} catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED,
LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Debugger_not_installed"), //$NON-NLS-1$
e);
@ -371,30 +383,33 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
protected String renderTargetLabel(ICDebugConfiguration debugConfig) {
String format = "{0} ({1})"; //$NON-NLS-1$
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
return MessageFormat.format(format, new String[] { debugConfig.getName(), timestamp });
return MessageFormat.format(format, new String[]{debugConfig.getName(), timestamp});
}
protected String renderProcessLabel(String commandLine) {
String format = "{0} ({1})"; //$NON-NLS-1$
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
return MessageFormat.format(format, new String[] { commandLine, timestamp });
return MessageFormat.format(format, new String[]{commandLine, timestamp});
}
protected ICProject verifyCProject(ILaunchConfiguration config) throws CoreException {
String name = getProjectName(config);
if (name == null) {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.C_Project_not_specified"), null, ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT); //$NON-NLS-1$
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.C_Project_not_specified"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT);
}
ICProject cproject = getCProject(config);
if (cproject == null) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if (!project.exists()) {
abort( LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); //$NON-NLS-1$
abort(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
} else if (!project.isOpen()) {
abort(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
}
else if (!project.isOpen()) {
abort( LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); //$NON-NLS-1$
}
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); //$NON-NLS-1$
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
}
return cproject;
}
@ -403,12 +418,16 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
ICProject cproject = verifyCProject(config);
String fileName = getProgramName(config);
if (fileName == null) {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_not_specified"), null, ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM); //$NON-NLS-1$
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
}
IFile programPath = ((IProject) cproject.getResource()).getFile(fileName);
if (programPath == null || !programPath.exists() || !programPath.getLocation().toFile().exists()) {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_does_not_exist"), new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.getLocation().toOSString())), ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST); //$NON-NLS-1$ //$NON-NLS-2$
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.getLocation().toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
}
return programPath;
}
@ -418,14 +437,14 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
}
/**
* Verifies the working directory specified by the given
* launch configuration exists, and returns the working
* directory, or <code>null</code> if none is specified.
* Verifies the working directory specified by the given launch configuration exists, and returns the working directory, or
* <code>null</code> if none is specified.
*
* @param configuration launch configuration
* @return the working directory specified by the given
* launch configuration, or <code>null</code> if none
* @exception CoreException if unable to retrieve the attribute
* @param configuration
* launch configuration
* @return the working directory specified by the given launch configuration, or <code>null</code> if none
* @exception CoreException
* if unable to retrieve the attribute
*/
public File verifyWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
IPath path = getWorkingDirectoryPath(configuration);
@ -436,30 +455,26 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
IProject p = cp.getProject();
return p.getLocation().toFile();
}
}
else {
} else {
if (path.isAbsolute()) {
File dir = new File(path.toOSString());
if (dir.isDirectory()) {
return dir;
} else {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
else {
abort(
LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException( LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.PROGRAM_PATH_not_found", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
}
else {
} else {
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
if (res instanceof IContainer && res.exists()) {
return res.getLocation().toFile();
}
else {
abort(
LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException( LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
} else {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
"AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
}
}
@ -467,6 +482,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
}
private static class ArgumentParser {
private String fArgs;
private int fIndex = 0;
private int ch = -1;
@ -485,8 +501,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
if (ch == '"') {
v.add(parseString());
}
else {
} else {
v.add(parseToken());
}
}
@ -535,15 +550,12 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
}
buf.append((char) ch);
ch = getNext();
}
else if (ch == -1) { // Don't lose a trailing backslash
} else if (ch == -1) { // Don't lose a trailing backslash
buf.append('\\');
}
}
else if (ch == '"') {
} else if (ch == '"') {
buf.append(parseString());
}
else {
} else {
buf.append((char) ch);
ch = getNext();
}
@ -551,4 +563,195 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
return buf.toString();
}
}
/**
* Recursively creates a set of projects referenced by the current project
*
* @param project
* The current project
* @param referencedProjSet
* A set of referenced projects
* @throws CoreException
* if an error occurs while getting referenced projects from the current project
*/
private void getReferencedProjectSet(IProject project, HashSet referencedProjSet) throws CoreException {
IProject[] projects = project.getReferencedProjects();
for (int i = 0; i < projects.length; i++) {
IProject refProject = projects[i];
if (refProject.exists() && !referencedProjSet.contains(refProject)) {
referencedProjSet.add(refProject);
getReferencedProjectSet(refProject, referencedProjSet);
}
}
}
/**
* creates a list of project ordered by their build order from an unordered list of projects.
*
* @param resourceCollection
* The list of projects to sort.
* @return A new list of projects, ordered by build order.
*/
private List getBuildOrder(List resourceCollection) {
String[] orderedNames = ResourcesPlugin.getWorkspace().getDescription().getBuildOrder();
if (orderedNames != null) {
List orderedProjects = new ArrayList(resourceCollection.size());
//Projects may not be in the build order but should be built if selected
List unorderedProjects = new ArrayList(resourceCollection.size());
unorderedProjects.addAll(resourceCollection);
for (int i = 0; i < orderedNames.length; i++) {
String projectName = orderedNames[i];
for (int j = 0; j < resourceCollection.size(); j++) {
IProject project = (IProject) resourceCollection.get(j);
if (project.getName().equals(projectName)) {
orderedProjects.add(project);
unorderedProjects.remove(project);
break;
}
}
}
//Add anything not specified before we return
orderedProjects.addAll(unorderedProjects);
return orderedProjects;
}
// Try the project prerequisite order then
IProject[] projects = new IProject[resourceCollection.size()];
projects = (IProject[]) resourceCollection.toArray(projects);
IWorkspace.ProjectOrder po = ResourcesPlugin.getWorkspace().computeProjectOrder(projects);
ArrayList orderedProjects = new ArrayList();
orderedProjects.addAll(Arrays.asList(po.projects));
return orderedProjects;
}
/**
* Builds the current project and all of it's prerequisite projects if necessary. Respects specified build order if any exists.
*
* @param configuration
* the configuration being launched
* @param mode
* the mode the configuration is being launched in
* @param monitor
* progress monitor
* @return whether the debug platform should perform an incremental workspace build before the launch
* @throws CoreException
* if an exception occurrs while building
*/
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
if (orderedProjects != null) {
monitor.beginTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.building_projects"), //$NON-NLS-1$
orderedProjects.size() + 1);
for (Iterator i = orderedProjects.iterator(); i.hasNext();) {
IProject proj = (IProject) i.next();
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.building") + proj.getName()); //$NON-NLS-1$
proj.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
}
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractLaunchConfigurationDelegate.building") + project.getName()); //$NON-NLS-1$
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
}
monitor.done();
return false; //don't build. I already did it or I threw an exception.
}
/**
* Searches for compile errors in the current project and any of its prerequisite projects. If any compile errors, give the user
* a chance to abort the launch and correct the errors.
*
* @param configuration
* @param mode
* @param monitor
* @return whether the launch should proceed
* @throws CoreException
* if an exception occurs while checking for compile errors.
*/
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
try {
boolean continueLaunch = true;
if (orderedProjects != null) {
monitor.beginTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors"), //$NON-NLS-1$
orderedProjects.size() + 1);
boolean compileErrorsInProjs = false;
//check prerequisite projects for compile errors.
for (Iterator i = orderedProjects.iterator(); i.hasNext();) {
IProject proj = (IProject) i.next();
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors_in") //$NON-NLS-1$
+ proj.getName());
compileErrorsInProjs = existsErrors(proj);
if (compileErrorsInProjs) {
break;
}
}
//check current project, if prerequite projects were ok
if (!compileErrorsInProjs) {
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors_in") //$NON-NLS-1$
+ project.getName());
compileErrorsInProjs = existsErrors(project);
}
//if compile errors exist, ask the user before continuing.
if (compileErrorsInProjs) {
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
if (prompter != null) {
continueLaunch = ((Boolean) prompter.handleStatus(complileErrorPromptStatus, null)).booleanValue();
}
}
}
return continueLaunch;
} finally {
monitor.done();
}
}
/**
* Searches for compile errors in the specified project
*
* @param proj
* The project to search
* @return true if compile errors exist, otherwise false
*/
private boolean existsErrors(IProject proj) throws CoreException {
IMarker[] markers = proj.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
if (markers.length > 0) {
for (int j = 0; j < markers.length; j++) {
if (((Integer) markers[j].getAttribute(IMarker.SEVERITY)).intValue() == IMarker.SEVERITY_ERROR) {
return true;
}
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration,
* java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
// build project list
if (monitor != null) {
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.20")); //$NON-NLS-1$
}
orderedProjects = null;
ICProject cProject = getCProject(configuration);
if (cProject != null) {
project = cProject.getProject();
HashSet projectSet = new HashSet();
getReferencedProjectSet(project, projectSet);
orderedProjects = getBuildOrder(new ArrayList(projectSet));
}
// do generic launch checks
return super.preLaunchCheck(configuration, mode, monitor);
}
}

View file

@ -16,11 +16,11 @@ import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
@ -113,7 +113,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
ICDebugConfiguration debugConfig = null;
ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
List debugList = new ArrayList(debugConfigs.length);
String os = BootLoader.getOS();
String os = Platform.getOS();
for (int i = 0; i < debugConfigs.length; i++) {
String platform = debugConfigs[i].getPlatform();
if (platform == null || platform.equals(ICDebugConfiguration.PLATFORM_NATIVE) || platform.equals(os)) {

View file

@ -160,6 +160,14 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
abstract protected ICDebugConfiguration getConfigForCurrentDebugger();
abstract public void createControl(Composite parent);
public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
ILaunchConfigurationTab dynamicTab = getDynamicTab();
if (dynamicTab != null) {
dynamicTab.activated(workingCopy);
}
}
public void initializeFrom(ILaunchConfiguration config) {
setLaunchConfiguration(config);
ILaunchConfigurationTab dynamicTab = getDynamicTab();

View file

@ -4,6 +4,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
@ -22,11 +23,7 @@ public class LaunchImages {
// Subdirectory (under the package containing this class) where 16 color images are
private static URL fgIconBaseURL;
static {
try {
fgIconBaseURL= new URL(LaunchUIPlugin.getDefault().getDescriptor().getInstallURL(), "icons/" ); //$NON-NLS-1$
} catch (MalformedURLException e) {
//LaunchUIPlugin.getDefault().log(e);
}
fgIconBaseURL= Platform.getBundle(LaunchUIPlugin.getUniqueIdentifier()).getEntry("/icons/"); //$NON-NLS-1$
}
private static final String T_TABS = "tabs/"; //$NON-NLS-1$

View file

@ -1,10 +1,13 @@
package org.eclipse.cdt.launch.internal.ui;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
@ -16,20 +19,15 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.text.MessageFormat;
import org.osgi.framework.BundleContext;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
*/
public class LaunchUIPlugin extends AbstractUIPlugin
implements IDebugEventSetListener {
public static final String PLUGIN_ID = LaunchUIPlugin.getUniqueIdentifier();
implements
IDebugEventSetListener {
public static final String PLUGIN_ID = "org.eclipse.cdt.launch"; //$NON-NLS-1$
private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.internal.ui.LaunchUIPluginResources";//$NON-NLS-1$
private static ResourceBundle resourceBundle = null;
@ -37,7 +35,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin
// -------- static methods --------
static {
if ( resourceBundle == null ) {
if (resourceBundle == null) {
// Acquire a reference to the .properties file for this plug-in
try {
resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
@ -55,17 +53,19 @@ public class LaunchUIPlugin extends AbstractUIPlugin
/**
* Constructor for LaunchUIPlugin.
*
* @param descriptor
*/
public LaunchUIPlugin(IPluginDescriptor descriptor) {
super(descriptor);
public LaunchUIPlugin() {
super();
setDefault(this);
}
/**
* Sets the Java Debug UI plug-in instance
*
* @param plugin the plugin instance
* @param plugin
* the plugin instance
*/
private static void setDefault(LaunchUIPlugin plugin) {
fgPlugin = plugin;
@ -84,12 +84,13 @@ public class LaunchUIPlugin extends AbstractUIPlugin
if (getActiveWorkbenchShell() != null) {
return getActiveWorkbenchShell();
} else {
if ( debugDialogShell != null ) {
if (!debugDialogShell.isDisposed() )
if (debugDialogShell != null) {
if (!debugDialogShell.isDisposed())
return debugDialogShell;
debugDialogShell = null;
}
IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows();
IWorkbenchWindow[] windows = getDefault().getWorkbench()
.getWorkbenchWindows();
return windows[0].getShell();
}
}
@ -106,15 +107,16 @@ public class LaunchUIPlugin extends AbstractUIPlugin
// If the default instance is not yet initialized,
// return a static identifier. This identifier must
// match the plugin id defined in plugin.xml
return "org.eclipse.cdt.launch"; //$NON-NLS-1$
return PLUGIN_ID;
}
return getDefault().getDescriptor().getUniqueIdentifier();
return getDefault().getBundle().getSymbolicName();
}
/**
* Logs the specified status with this plug-in's log.
*
* @param status status to log
* @param status
* status to log
*/
public static void log(IStatus status) {
getDefault().getLog().log(status);
@ -122,19 +124,23 @@ public class LaunchUIPlugin extends AbstractUIPlugin
/**
* Logs an internal error with the specified message.
*
* @param message the error message to log
* @param message
* the error message to log
*/
public static void logErrorMessage(String message) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null));
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR,
message, null));
}
/**
* Logs an internal error with the specified throwable
*
* @param e the exception to be logged
* @param e
* the exception to be logged
*/
public static void log(Throwable e) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e)); //$NON-NLS-1$
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e
.getMessage(), e)); //$NON-NLS-1$
}
/**
@ -167,11 +173,15 @@ public class LaunchUIPlugin extends AbstractUIPlugin
return null;
}
public static void errorDialog( String message, IStatus status ) {
public static void errorDialog(String message, IStatus status) {
log(status);
Shell shell = getActiveWorkbenchShell();
if (shell != null) {
ErrorDialog.openError(shell, LaunchUIPlugin.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
ErrorDialog
.openError(
shell,
LaunchUIPlugin
.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
}
}
@ -179,47 +189,60 @@ public class LaunchUIPlugin extends AbstractUIPlugin
log(t);
Shell shell = getActiveWorkbenchShell();
if (shell != null) {
IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), 1, t.getMessage(), null); //$NON-NLS-1$
ErrorDialog.openError(shell, LaunchUIPlugin.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(),
1, t.getMessage(), null); //$NON-NLS-1$
ErrorDialog
.openError(
shell,
LaunchUIPlugin
.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
}
}
/**
* @see org.eclipse.core.runtime.Plugin#shutdown()
*/
public void shutdown() throws CoreException {
DebugPlugin.getDefault().removeDebugEventListener(this);
super.shutdown();
}
/**
* @see org.eclipse.core.runtime.Plugin#startup()
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void startup() throws CoreException {
super.startup();
public void start(BundleContext context) throws Exception {
super.start(context);
DebugPlugin.getDefault().addDebugEventListener(this);
}
/**
* Notifies this listener of the given debug events.
* All of the events in the given event collection occurred
* at the same location the program be run or debugged.
/*
* (non-Javadoc)
*
* @param events the debug events
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
DebugPlugin.getDefault().removeDebugEventListener(this);
super.stop(context);
}
/**
* Notifies this listener of the given debug events. All of the events in
* the given event collection occurred at the same location the program be
* run or debugged.
*
* @param events
* the debug events
*/
public void handleDebugEvents(DebugEvent[] events) {
for (int i = 0; i < events.length; i++) {
if (events[i].getKind() == DebugEvent.TERMINATE) {
Object o = events[i].getSource();
if (o instanceof IProcess) {
IProcess proc = (IProcess)o;
IProcess proc = (IProcess) o;
ICProject cproject = null;
try {
cproject = AbstractCLaunchDelegate.getCProject(proc.getLaunch().getLaunchConfiguration());
cproject = AbstractCLaunchDelegate.getCProject(proc
.getLaunch().getLaunchConfiguration());
} catch (CoreException e) {
}
if (cproject != null) {
try {
cproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
cproject.getProject().refreshLocal(
IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
}
}
@ -239,15 +262,14 @@ public class LaunchUIPlugin extends AbstractUIPlugin
ResourceBundle bundle = LaunchUIPlugin.getDefault().getResourceBundle();
// No point trying if bundle is null as exceptions are costly
if ( bundle != null )
{
if (bundle != null) {
try {
return bundle.getString(key);
} catch (MissingResourceException e) {
return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
} catch (NullPointerException e) {
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
}
} catch (NullPointerException e) {
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
// If we get here, then bundle is null.
@ -255,7 +277,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin
}
public static String getFormattedResourceString(String key, String arg) {
return MessageFormat.format(getResourceString(key), new String[] { arg });
return MessageFormat.format(getResourceString(key), new String[]{arg});
}
public static String getFormattedResourceString(String key, String[] args) {

View file

@ -9,6 +9,10 @@ AbstractCLaunchDelegate.Project_NAME_does_not_exist=Project {0} does not exist
AbstractCLaunchDelegate.Project_NAME_is_closed=Project {0} is closed
AbstractCLaunchDelegate.PROGRAM_PATH_not_found={0} not found
AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist={0} Does not exist.
AbstractCLaunchConfigurationDelegate.building_projects=Building prerequisite project list
AbstractCLaunchConfigurationDelegate.building=Building
AbstractCLaunchConfigurationDelegate.searching_for_errors=Searching for compile errors
AbstractCLaunchConfigurationDelegate.searching_for_errors_in=Searching for compile errors in
LocalCLaunchConfigurationDelegate.Launching_Local_C_Application=Launching Local C Application
LocalCLaunchConfigurationDelegate.No_Process_ID_selected=No Process ID selected

View file

@ -1,6 +1,5 @@
/*
* (c) Copyright QNX Software System Ltd. 2002.
* All Rights Reserved.
* (c) Copyright QNX Software System Ltd. 2002. All Rights Reserved.
*/
package org.eclipse.cdt.launch.ui;
@ -14,8 +13,8 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.swt.SWT;
@ -32,7 +31,6 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.help.WorkbenchHelp;
public class CDebuggerTab extends AbstractCDebuggerTab {
protected Combo fDCombo;
@ -61,6 +59,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
dlabel.setText(LaunchUIPlugin.getResourceString("Launch.common.DebuggerColon")); //$NON-NLS-1$
fDCombo = new Combo(comboComp, SWT.DROP_DOWN | SWT.READ_ONLY);
fDCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
updateComboFromSelection();
}
@ -73,6 +72,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
radioComp.setLayout(radioLayout);
fRunButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Run_program_in_debugger")); //$NON-NLS-1$
fRunButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (fRunButton.getSelection() == true) {
fStopInMain.setEnabled(true);
@ -84,12 +84,12 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
});
fAttachButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Attach_to_running_process")); //$NON-NLS-1$
fAttachButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog();
}
});
Composite optionComp = new Composite(comp, SWT.NONE);
layout = new GridLayout(2, false);
optionComp.setLayout(layout);
@ -100,6 +100,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
fStopInMain = new Button(optionComp, SWT.CHECK);
fStopInMain.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Stop_at_main_on_startup")); //$NON-NLS-1$
fStopInMain.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog();
}
@ -108,6 +109,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
fVarBookKeeping = new Button(optionComp, SWT.CHECK);
fVarBookKeeping.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Automatically_track_values_of_variables")); //$NON-NLS-1$
fVarBookKeeping.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog();
}
@ -138,6 +140,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
fDCombo.removeAll();
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
Arrays.sort(debugConfigs, new Comparator() {
public int compare(Object o1, Object o2) {
ICDebugConfiguration ic1 = (ICDebugConfiguration) o1;
ICDebugConfiguration ic2 = (ICDebugConfiguration) o2;
@ -148,17 +151,17 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
int selndx = -1;
for (int i = 0; i < debugConfigs.length; i++) {
if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)
|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
String debuggerPlatform = debugConfigs[i].getPlatform();
boolean isNative = configPlatform.equals(BootLoader.getOS());
boolean isNative = configPlatform.equals(Platform.getOS());
if (debuggerPlatform.equalsIgnoreCase(configPlatform)
|| (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
|| (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
if (debugConfigs[i].supportsCPU(programCPU)) {
fDCombo.add(debugConfigs[i].getName());
fDCombo.setData(Integer.toString(x), debugConfigs[i]);
// select first exact matching debugger for platform or requested selection
if ((selndx == -1 && debuggerPlatform.equalsIgnoreCase(configPlatform))
|| selection.equals(debugConfigs[i].getID())) {
|| selection.equals(debugConfigs[i].getID())) {
selndx = x;
}
x++;
@ -185,9 +188,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
fAttachButton.setSelection(false);
try {
String mode =
getLaunchConfiguration().getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
String mode = getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN) && fRunButton.isEnabled()) {
fRunButton.setSelection(true);
@ -209,21 +210,27 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.setDefaults(config);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, DEFAULT_STOP_AT_MAIN);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false);
config.setAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
}
public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
super.activated(workingCopy);
try {
String id = workingCopy.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
if (getDebugConfig() == null || !getDebugConfig().getID().equals(id) || !validateDebuggerConfig(workingCopy)) {
loadDebuggerComboBox(workingCopy, id);
}
} catch (CoreException e) {
}
}
public void initializeFrom(ILaunchConfiguration config) {
super.initializeFrom(config);
try {
String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
if (getDebugConfig() == null || !getDebugConfig().getID().equals(id)) {
loadDebuggerComboBox(config, id);
}
String mode =
config.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
loadDebuggerComboBox(config, id);
String mode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
fRunButton.setSelection(true);
@ -247,16 +254,15 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
if (isValid(config)) {
super.performApply(config);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, !fVarBookKeeping.getSelection());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING,
!fVarBookKeeping.getSelection());
if (fAttachButton.getSelection() == true) {
config.setAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
} else {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
config.setAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
}
}
}
@ -293,7 +299,8 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
}
String debuggerPlatform = debugConfig.getPlatform();
boolean isNative = platform.equals(projectPlatform);
if (debuggerPlatform.equalsIgnoreCase(projectPlatform) || (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
if (debuggerPlatform.equalsIgnoreCase(projectPlatform)
|| (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
if (debugConfig.supportsCPU(projectCPU)) {
return true;
}
@ -302,8 +309,8 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
}
/**
* Return the class that implements <code>ILaunchConfigurationTab</code>
* that is registered against the debugger id of the currently selected debugger.
* Return the class that implements <code>ILaunchConfigurationTab</code> that is registered against the debugger id of the
* currently selected debugger.
*/
protected ICDebugConfiguration getConfigForCurrentDebugger() {
int selectedIndex = fDCombo.getSelectionIndex();

View file

@ -7,12 +7,12 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
@ -122,7 +122,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
}
protected String getPlatform(ILaunchConfiguration config) {
String platform = BootLoader.getOS();
String platform = Platform.getOS();
try {
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PLATFORM, platform);
}

View file

@ -23,16 +23,17 @@ import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT;
@ -315,16 +316,16 @@ public class CMainTab extends CLaunchConfigurationTab {
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object [] selection) {
if(selection.length == 0 || !(selection[0] instanceof IFile)) {
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$
return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$
} else {
try {
ICElement celement = cproject.findElement(((IFile)selection[0]).getProjectRelativePath());
if(celement == null ||
(celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) {
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
}
return new Status(IStatus.OK, LaunchUIPlugin.PLUGIN_ID, IStatus.OK, celement.getResource().getName(), null);
return new Status(IStatus.OK, LaunchUIPlugin.getUniqueIdentifier(), IStatus.OK, celement.getResource().getName(), null);
} catch(Exception ex) {
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
}
@ -421,7 +422,7 @@ public class CMainTab extends CLaunchConfigurationTab {
protected ICProject[] getCProjects() throws CModelException {
ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects();
ArrayList list = new ArrayList(cproject.length);
boolean isNative = filterPlatform.equals(BootLoader.getOS());
boolean isNative = filterPlatform.equals(Platform.getOS());
for (int i = 0; i < cproject.length; i++) {
ICDescriptor cdesciptor = null;

View file

@ -113,13 +113,22 @@ public class CorefileDebuggerTab extends AbstractCDebuggerTab {
initializingComboBox = false;
}
public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
super.activated(workingCopy);
try {
String id = workingCopy.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
if (getDebugConfig() == null || !getDebugConfig().getID().equals(id) || !validateDebuggerConfig(workingCopy)) {
loadDebuggerComboBox(workingCopy, id);
}
} catch (CoreException e) {
}
}
public void initializeFrom(ILaunchConfiguration config) {
super.initializeFrom(config);
try {
String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
if (getDebugConfig() == null || !getDebugConfig().getID().equals(id)) {
loadDebuggerComboBox(config, id);
}
loadDebuggerComboBox(config, id);
} catch (CoreException e) {
return;
}
@ -165,7 +174,6 @@ public class CorefileDebuggerTab extends AbstractCDebuggerTab {
return true;
}
}
setDebugConfig(null);
return false;
}