mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-21 07:55:24 +02:00
added attach/core/run modes in lauch pages
This commit is contained in:
parent
f5bea71c1d
commit
5f42e5c287
7 changed files with 367 additions and 263 deletions
|
@ -26,11 +26,12 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
||||||
|
|
||||||
abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDelegate {
|
abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDelegate {
|
||||||
|
|
||||||
abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException;
|
abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
|
||||||
|
throws CoreException;
|
||||||
|
|
||||||
protected String[] getEnvironmentArray(ILaunchConfiguration config) {
|
protected String[] getEnvironmentArray(ILaunchConfiguration config) {
|
||||||
// Map env = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
|
// Map env = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
|
||||||
// TODO create env array;
|
// TODO create env array;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,25 +43,28 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
}
|
}
|
||||||
if ( env == null )
|
if (env == null)
|
||||||
return prop;
|
return prop;
|
||||||
Iterator entries = env.entrySet().iterator();
|
Iterator entries = env.entrySet().iterator();
|
||||||
Entry entry;
|
Entry entry;
|
||||||
while( entries.hasNext() ) {
|
while (entries.hasNext()) {
|
||||||
entry = (Entry) entries.next();
|
entry = (Entry) entries.next();
|
||||||
prop.setProperty((String)entry.getKey(), (String)entry.getValue());
|
prop.setProperty((String) entry.getKey(), (String) entry.getValue());
|
||||||
}
|
}
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File getWorkingDir(ILaunchConfiguration config) throws CoreException {
|
protected File getWorkingDir(ILaunchConfiguration config) throws CoreException {
|
||||||
String path = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
|
String path = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
File dir = new File(path);
|
File dir = new File(path);
|
||||||
if (!dir.isDirectory()) {
|
if (!dir.isDirectory()) {
|
||||||
abort("Specified working directory does not exist or is not a directory", null, ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
|
abort(
|
||||||
|
"Specified working directory does not exist or is not a directory",
|
||||||
|
null,
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
@ -94,11 +98,11 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProjectName(ILaunchConfiguration configuration) throws CoreException {
|
public String getProjectName(ILaunchConfiguration configuration) throws CoreException {
|
||||||
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
|
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProgramName(ILaunchConfiguration configuration) throws CoreException {
|
public String getProgramName(ILaunchConfiguration configuration) throws CoreException {
|
||||||
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
|
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +111,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
|
||||||
* @return the program arguments as a String
|
* @return the program arguments as a String
|
||||||
*/
|
*/
|
||||||
public String getProgramArguments(ILaunchConfiguration config) throws CoreException {
|
public String getProgramArguments(ILaunchConfiguration config) throws CoreException {
|
||||||
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
|
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -122,37 +126,38 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
|
||||||
private static String[] parseArguments(String args) {
|
private static String[] parseArguments(String args) {
|
||||||
if (args == null)
|
if (args == null)
|
||||||
return new String[0];
|
return new String[0];
|
||||||
ArgumentParser parser= new ArgumentParser(args);
|
ArgumentParser parser = new ArgumentParser(args);
|
||||||
String[] res= parser.parseArguments();
|
String[] res = parser.parseArguments();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ArgumentParser {
|
private static class ArgumentParser {
|
||||||
private String fArgs;
|
private String fArgs;
|
||||||
private int fIndex= 0;
|
private int fIndex = 0;
|
||||||
private int ch= -1;
|
private int ch = -1;
|
||||||
|
|
||||||
public ArgumentParser(String args) {
|
public ArgumentParser(String args) {
|
||||||
fArgs= args;
|
fArgs = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] parseArguments() {
|
public String[] parseArguments() {
|
||||||
ArrayList v= new ArrayList();
|
ArrayList v = new ArrayList();
|
||||||
|
|
||||||
ch= getNext();
|
ch = getNext();
|
||||||
while (ch > 0) {
|
while (ch > 0) {
|
||||||
while (Character.isWhitespace((char)ch))
|
while (Character.isWhitespace((char) ch))
|
||||||
ch= getNext();
|
ch = getNext();
|
||||||
|
|
||||||
if (ch == '"') {
|
if (ch == '"') {
|
||||||
v.add(parseString());
|
v.add(parseString());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
v.add(parseToken());
|
v.add(parseToken());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] result= new String[v.size()];
|
String[] result = new String[v.size()];
|
||||||
v.toArray(result);
|
v.toArray(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -164,46 +169,49 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
|
||||||
}
|
}
|
||||||
|
|
||||||
private String parseString() {
|
private String parseString() {
|
||||||
StringBuffer buf= new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
ch= getNext();
|
ch = getNext();
|
||||||
while (ch > 0 && ch != '"') {
|
while (ch > 0 && ch != '"') {
|
||||||
if (ch == '\\') {
|
if (ch == '\\') {
|
||||||
ch= getNext();
|
ch = getNext();
|
||||||
if (ch != '"') { // Only escape double quotes
|
if (ch != '"') { // Only escape double quotes
|
||||||
buf.append('\\');
|
buf.append('\\');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ch > 0) {
|
if (ch > 0) {
|
||||||
buf.append((char)ch);
|
buf.append((char) ch);
|
||||||
ch= getNext();
|
ch = getNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ch= getNext();
|
ch = getNext();
|
||||||
|
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String parseToken() {
|
private String parseToken() {
|
||||||
StringBuffer buf= new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
|
|
||||||
while (ch > 0 && !Character.isWhitespace((char)ch)) {
|
while (ch > 0 && !Character.isWhitespace((char) ch)) {
|
||||||
if (ch == '\\') {
|
if (ch == '\\') {
|
||||||
ch= getNext();
|
ch = getNext();
|
||||||
if (ch > 0) {
|
if (ch > 0) {
|
||||||
if (ch != '"') { // Only escape double quotes
|
if (ch != '"') { // Only escape double quotes
|
||||||
buf.append('\\');
|
buf.append('\\');
|
||||||
}
|
}
|
||||||
buf.append((char)ch);
|
buf.append((char) ch);
|
||||||
ch= getNext();
|
ch = getNext();
|
||||||
} else if (ch == -1) { // Don't lose a trailing backslash
|
}
|
||||||
|
else if (ch == -1) { // Don't lose a trailing backslash
|
||||||
buf.append('\\');
|
buf.append('\\');
|
||||||
}
|
}
|
||||||
} else if (ch == '"') {
|
}
|
||||||
|
else if (ch == '"') {
|
||||||
buf.append(parseString());
|
buf.append(parseString());
|
||||||
} else {
|
}
|
||||||
buf.append((char)ch);
|
else {
|
||||||
ch= getNext();
|
buf.append((char) ch);
|
||||||
|
ch = getNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
|
|
|
@ -50,26 +50,50 @@ public interface ICDTLaunchConfigurationConstants {
|
||||||
*/
|
*/
|
||||||
public static final String ATTR_PROGRAM_ENVIROMENT_MAP = LaunchUIPlugin.getUniqueIdentifier() + ".ENVIRONMENT_MAP"; //$NON-NLS-1$
|
public static final String ATTR_PROGRAM_ENVIROMENT_MAP = LaunchUIPlugin.getUniqueIdentifier() + ".ENVIRONMENT_MAP"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch configuration attribute key. The value is the platform string of the launch configuration
|
||||||
|
*/
|
||||||
|
public static final String ATTR_PLATFORM = LaunchUIPlugin.getUniqueIdentifier() + ".PLATFFORM"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch configuration attribute key. The value is the debugger id
|
* Launch configuration attribute key. The value is the debugger id
|
||||||
* used when launching a C/C++ application for debug.
|
* used when launching a C/C++ application for debug.
|
||||||
*/
|
*/
|
||||||
public static final String ATTR_DEBUGGER_ID = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_ID"; //$NON-NLS-1$
|
public static final String ATTR_DEBUGGER_ID = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_ID"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch configuration attribute key. The value is the platform string of the launch configuration
|
|
||||||
*/
|
|
||||||
public static final String ATTR_PLATFORM = LaunchUIPlugin.getUniqueIdentifier() + ".PLATFFORM"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch configuration attribute key. The value is the platform string of the launch configuration
|
* Launch configuration attribute key. The value is the platform string of the launch configuration
|
||||||
*/
|
*/
|
||||||
public static final String ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_SPECIFIC_ATTRS_MAP"; //$NON-NLS-1$
|
public static final String ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_SPECIFIC_ATTRS_MAP"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch configuration attribute key. The value is the platform string of the launch configuration
|
* Launch configuration attribute key. The value is a boolean specifying whether to stop at main().
|
||||||
*/
|
*/
|
||||||
public static final String ATTR_DEBUGGER_STOP_AT_MAIN = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_STOP_AT_MAIN"; //$NON-NLS-1$
|
public static final String ATTR_DEBUGGER_STOP_AT_MAIN = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_STOP_AT_MAIN"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch configuration attribute key. The value is the startup mode for the debugger.
|
||||||
|
*/
|
||||||
|
public static final String ATTR_DEBUGGER_START_MODE = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_START_MODE"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch configuration attribute value. The key is ATTR_DEBUGGER_START_MODE.
|
||||||
|
* Startup debugger running the program.
|
||||||
|
*/
|
||||||
|
public static String DEBUGGER_MODE_RUN = "run";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch configuration attribute value. The key is ATTR_DEBUGGER_START_MODE.
|
||||||
|
* Startup debugger and attach to running process.
|
||||||
|
*/
|
||||||
|
public static String DEBUGGER_MODE_ATTACH = "attach";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch configuration attribute value. The key is ATTR_DEBUGGER_START_MODE.
|
||||||
|
* Startup debugger to view a core file.
|
||||||
|
*/
|
||||||
|
public static String DEBUGGER_MODE_CORE = "core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status code indicating that the Eclipse runtime does not support
|
* Status code indicating that the Eclipse runtime does not support
|
||||||
* launching a program with a working directory. This feature is only
|
* launching a program with a working directory. This feature is only
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.ILaunch;
|
import org.eclipse.debug.core.ILaunch;
|
||||||
|
@ -41,6 +43,9 @@ import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchManager;
|
import org.eclipse.debug.core.ILaunchManager;
|
||||||
import org.eclipse.debug.core.IStatusHandler;
|
import org.eclipse.debug.core.IStatusHandler;
|
||||||
import org.eclipse.debug.core.model.IProcess;
|
import org.eclipse.debug.core.model.IProcess;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert the type's description here.
|
* Insert the type's description here.
|
||||||
|
@ -48,15 +53,15 @@ import org.eclipse.debug.core.model.IProcess;
|
||||||
*/
|
*/
|
||||||
public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
protected String renderDebugTarget(ICDISession session) {
|
protected String renderDebugTarget(ICDISession session) {
|
||||||
String format= "{0} at localhost {1}";
|
String format= "{0} at localhost {1}";
|
||||||
return MessageFormat.format(format, new String[] { classToRun, String.valueOf(host) });
|
return MessageFormat.format(format, new String[] { classToRun, String.valueOf(host) });
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
public String renderProcessLabel(String[] commandLine) {
|
public String renderProcessLabel(String[] commandLine) {
|
||||||
String format= "{0} ({1})";
|
String format = "{0} ({1})";
|
||||||
String timestamp= DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
|
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
|
||||||
return MessageFormat.format(format, new String[] { commandLine[0], timestamp });
|
return MessageFormat.format(format, new String[] { commandLine[0], timestamp });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,9 +76,9 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ICProject cproject = getCProject(config);
|
ICProject cproject = getCProject(config);
|
||||||
IPath projectPath = ((IProject)cproject.getResource()).getFile(getProgramName(config)).getLocation();
|
IPath projectPath = ((IProject) cproject.getResource()).getFile(getProgramName(config)).getLocation();
|
||||||
String arguments[] = getProgramArgumentsArray(config);
|
String arguments[] = getProgramArgumentsArray(config);
|
||||||
ArrayList command = new ArrayList(1+arguments.length);
|
ArrayList command = new ArrayList(1 + arguments.length);
|
||||||
command.add(projectPath.toOSString());
|
command.add(projectPath.toOSString());
|
||||||
command.addAll(Arrays.asList(arguments));
|
command.addAll(Arrays.asList(arguments));
|
||||||
|
|
||||||
|
@ -81,11 +86,19 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||||
ICDebugConfiguration dbgCfg = null;
|
ICDebugConfiguration dbgCfg = null;
|
||||||
ICDebugger cdebugger = null;
|
ICDebugger cdebugger = null;
|
||||||
try {
|
try {
|
||||||
dbgCfg = CDebugCorePlugin.getDefault().getDebugConfiguration(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""));
|
dbgCfg =
|
||||||
|
CDebugCorePlugin.getDefault().getDebugConfiguration(
|
||||||
|
config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""));
|
||||||
cdebugger = dbgCfg.getDebugger();
|
cdebugger = dbgCfg.getDebugger();
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED, "CDT Debubger not installed", e);
|
IStatus status =
|
||||||
|
new Status(
|
||||||
|
IStatus.ERROR,
|
||||||
|
LaunchUIPlugin.getUniqueIdentifier(),
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED,
|
||||||
|
"CDT Debubger not installed",
|
||||||
|
e);
|
||||||
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
|
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
|
||||||
|
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
|
@ -98,33 +111,90 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||||
IFile exe = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(projectPath);
|
IFile exe = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(projectPath);
|
||||||
ICDISession dsession = null;
|
ICDISession dsession = null;
|
||||||
try {
|
try {
|
||||||
dsession = cdebugger.createLaunchSession(config, exe);
|
String debugMode =
|
||||||
|
config.getAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
|
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
||||||
|
dsession = cdebugger.createLaunchSession(config, exe);
|
||||||
|
}
|
||||||
|
else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|
||||||
|
int pid = getProcessID();
|
||||||
|
dsession = cdebugger.createAttachSession(config, exe, pid);
|
||||||
|
}
|
||||||
|
else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
|
||||||
|
IPath corefile = getCoreFilePath((IProject)cproject.getResource());
|
||||||
|
dsession = cdebugger.createCoreSession(config, exe, corefile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CDIException e) {
|
catch (CDIException e) {
|
||||||
IStatus status = new Status(0, LaunchUIPlugin.getUniqueIdentifier(), ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,"CDI Error", e);
|
IStatus status =
|
||||||
|
new Status(
|
||||||
|
0,
|
||||||
|
LaunchUIPlugin.getUniqueIdentifier(),
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,
|
||||||
|
"CDI Error",
|
||||||
|
e);
|
||||||
throw new CoreException(status);
|
throw new CoreException(status);
|
||||||
}
|
}
|
||||||
ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
|
ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
|
||||||
opt.setArguments(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""));
|
opt.setArguments(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""));
|
||||||
File wd = getWorkingDir(config);
|
File wd = getWorkingDir(config);
|
||||||
if ( wd != null ) {
|
if (wd != null) {
|
||||||
opt.setWorkingDirectory(wd.toString());
|
opt.setWorkingDirectory(wd.toString());
|
||||||
}
|
}
|
||||||
opt.setEnvironment(getEnvironmentProperty(config));
|
opt.setEnvironment(getEnvironmentProperty(config));
|
||||||
ICDITarget dtarget = dsession.getTargets()[0];
|
ICDITarget dtarget = dsession.getTargets()[0];
|
||||||
Process process = dtarget.getProcess();
|
Process process = dtarget.getProcess();
|
||||||
IProcess iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel((String [])command.toArray(new String[command.size()])));
|
IProcess iprocess =
|
||||||
|
DebugPlugin.newProcess(launch, process, renderProcessLabel((String[]) command.toArray(new String[command.size()])));
|
||||||
boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
||||||
CDebugModel.newDebugTarget(launch, dsession.getTargets()[0], dbgCfg.getName(), iprocess, exe.getProject(), true, false, stopInMain );
|
CDebugModel.newDebugTarget(
|
||||||
|
launch,
|
||||||
|
dsession.getTargets()[0],
|
||||||
|
dbgCfg.getName(),
|
||||||
|
iprocess,
|
||||||
|
exe.getProject(),
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
stopInMain);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String []commandArray = (String [])command.toArray(new String[command.size()]);
|
String[] commandArray = (String[]) command.toArray(new String[command.size()]);
|
||||||
Process process = exec(commandArray, getEnvironmentArray(config), getWorkingDir(config));
|
Process process = exec(commandArray, getEnvironmentArray(config), getWorkingDir(config));
|
||||||
DebugPlugin.getDefault().newProcess(launch, process, renderProcessLabel(commandArray));
|
DebugPlugin.getDefault().newProcess(launch, process, renderProcessLabel(commandArray));
|
||||||
}
|
}
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IPath getCoreFilePath(IProject project) {
|
||||||
|
Shell shell = LaunchUIPlugin.getShell();
|
||||||
|
if ( shell == null )
|
||||||
|
return null;
|
||||||
|
FileDialog dialog = new FileDialog( shell );
|
||||||
|
dialog.setText( "Select Corefile" );
|
||||||
|
|
||||||
|
String initPath = null;
|
||||||
|
try {
|
||||||
|
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath"));
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
}
|
||||||
|
if ( initPath == null || initPath.equals("") ) {
|
||||||
|
initPath = project.getLocation().toString();
|
||||||
|
}
|
||||||
|
dialog.setFilterPath( initPath );
|
||||||
|
String res = dialog.open();
|
||||||
|
if ( res != null )
|
||||||
|
return new Path( res );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int getProcessID() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a runtime exec on the given command line in the context
|
* Performs a runtime exec on the given command line in the context
|
||||||
|
@ -159,7 +229,13 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||||
catch (NoSuchMethodError e) {
|
catch (NoSuchMethodError e) {
|
||||||
//attempting launches on 1.2.* - no ability to set working directory
|
//attempting launches on 1.2.* - no ability to set working directory
|
||||||
|
|
||||||
IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_NOT_SUPPORTED, "Eclipse runtime does not support working directory", e);
|
IStatus status =
|
||||||
|
new Status(
|
||||||
|
IStatus.ERROR,
|
||||||
|
LaunchUIPlugin.getUniqueIdentifier(),
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_NOT_SUPPORTED,
|
||||||
|
"Eclipse runtime does not support working directory",
|
||||||
|
e);
|
||||||
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
|
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
|
||||||
|
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
|
|
|
@ -41,8 +41,9 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
if (!ss.isEmpty()) {
|
if (!ss.isEmpty()) {
|
||||||
Object obj = ss.getFirstElement();
|
Object obj = ss.getFirstElement();
|
||||||
if (obj instanceof ICElement) {
|
if (obj instanceof ICElement) {
|
||||||
ICProjectDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(((ICElement)obj).getCProject().getProject());
|
ICProjectDescriptor descriptor =
|
||||||
if ( descriptor.getPlatform().equals(getPlatform(config)) )
|
CCorePlugin.getDefault().getCProjectDescription(((ICElement) obj).getCProject().getProject());
|
||||||
|
if (descriptor.getPlatform().equals(getPlatform(config)))
|
||||||
return (ICElement) obj;
|
return (ICElement) obj;
|
||||||
}
|
}
|
||||||
if (obj instanceof IResource) {
|
if (obj instanceof IResource) {
|
||||||
|
@ -52,8 +53,9 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
ce = CoreModel.getDefault().create(pro);
|
ce = CoreModel.getDefault().create(pro);
|
||||||
}
|
}
|
||||||
if (ce != null) {
|
if (ce != null) {
|
||||||
ICProjectDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject());
|
ICProjectDescriptor descriptor =
|
||||||
if ( descriptor.getPlatform().equals(getPlatform(config)) )
|
CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject());
|
||||||
|
if (descriptor.getPlatform().equals(getPlatform(config)))
|
||||||
return ce;
|
return ce;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,8 +83,13 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getPlatform(ILaunchConfiguration config) throws CoreException {
|
protected String getPlatform(ILaunchConfiguration config) {
|
||||||
String platform = BootLoader.getOS();
|
String platform = BootLoader.getOS();
|
||||||
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PLATFORM, platform);
|
try {
|
||||||
|
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PLATFORM, platform);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,13 @@ public class LaunchUIPlugin extends AbstractUIPlugin {
|
||||||
return fgPlugin;
|
return fgPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Shell getShell() {
|
||||||
|
if (getActiveWorkbenchWindow() != null) {
|
||||||
|
return getActiveWorkbenchWindow().getShell();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method which returns the unique identifier of this plugin.
|
* Convenience method which returns the unique identifier of this plugin.
|
||||||
*/
|
*/
|
||||||
|
@ -54,7 +61,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin {
|
||||||
// If the default instance is not yet initialized,
|
// If the default instance is not yet initialized,
|
||||||
// return a static identifier. This identifier must
|
// return a static identifier. This identifier must
|
||||||
// match the plugin id defined in plugin.xml
|
// match the plugin id defined in plugin.xml
|
||||||
return "org.eclipse.jdt.debug.ui"; //$NON-NLS-1$
|
return "org.eclipse.cdt.launch"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return getDefault().getDescriptor().getUniqueIdentifier();
|
return getDefault().getDescriptor().getUniqueIdentifier();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.eclipse.cdt.launch.ui;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
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.CDebugUIPlugin;
|
||||||
|
@ -21,8 +20,8 @@ import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.ModifyEvent;
|
import org.eclipse.swt.events.ModifyEvent;
|
||||||
import org.eclipse.swt.events.ModifyListener;
|
import org.eclipse.swt.events.ModifyListener;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
@ -34,26 +33,29 @@ import org.eclipse.swt.widgets.Group;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
|
||||||
public class CDebuggerTab extends CLaunchConfigurationTab {
|
public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||||
ArrayList fDinfo;
|
|
||||||
int fDindex;
|
|
||||||
Combo fDCombo;
|
Combo fDCombo;
|
||||||
Button stopInMain;
|
Button stopInMain;
|
||||||
|
|
||||||
|
protected Button fAttachButton;
|
||||||
|
protected Button fCoreButton;
|
||||||
|
protected Button fRunButton;
|
||||||
|
|
||||||
// Dynamic Debugger UI widgets
|
// Dynamic Debugger UI widgets
|
||||||
protected ILaunchConfigurationTab fDynamicTab;
|
protected ILaunchConfigurationTab fDynamicTab;
|
||||||
protected Composite fDynamicTabHolder;
|
protected Composite fDynamicTabHolder;
|
||||||
|
protected ICDebugConfiguration fCurrentDebugConfig;
|
||||||
|
|
||||||
protected ILaunchConfigurationWorkingCopy fWorkingCopy;
|
protected ILaunchConfigurationWorkingCopy fWorkingCopy;
|
||||||
protected ILaunchConfiguration fLaunchConfiguration;
|
protected ILaunchConfiguration fLaunchConfiguration;
|
||||||
|
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
Composite comp= new Composite(parent, SWT.NONE);
|
Composite comp = new Composite(parent, SWT.NONE);
|
||||||
setControl(comp);
|
setControl(comp);
|
||||||
GridLayout topLayout = new GridLayout(3, false);
|
GridLayout topLayout = new GridLayout(3, false);
|
||||||
comp.setLayout(topLayout);
|
comp.setLayout(topLayout);
|
||||||
Label dlabel = new Label(comp, SWT.NONE);
|
Label dlabel = new Label(comp, SWT.NONE);
|
||||||
dlabel.setText("Debugger:");
|
dlabel.setText("Debugger:");
|
||||||
fDCombo = new Combo(comp, SWT.DROP_DOWN|SWT.READ_ONLY);
|
fDCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
|
||||||
fDCombo.addModifyListener(new ModifyListener() {
|
fDCombo.addModifyListener(new ModifyListener() {
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
handleDebuggerComboBoxModified();
|
handleDebuggerComboBoxModified();
|
||||||
|
@ -62,15 +64,27 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||||
stopInMain = new Button(comp, SWT.CHECK);
|
stopInMain = new Button(comp, SWT.CHECK);
|
||||||
stopInMain.setText("Stop at main() on startup.");
|
stopInMain.setText("Stop at main() on startup.");
|
||||||
GridData gd = new GridData();
|
GridData gd = new GridData();
|
||||||
gd.grabExcessHorizontalSpace = true;
|
gd.horizontalIndent = 10;
|
||||||
gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
|
|
||||||
stopInMain.setLayoutData(gd);
|
stopInMain.setLayoutData(gd);
|
||||||
|
|
||||||
|
Composite radioComp = new Composite(comp, SWT.NONE);
|
||||||
|
GridLayout radioLayout = new GridLayout(3, true);
|
||||||
|
radioLayout.marginHeight = 0;
|
||||||
|
radioLayout.marginWidth = 0;
|
||||||
|
radioComp.setLayout(radioLayout);
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalSpan = 3;
|
||||||
|
radioComp.setLayoutData(gd);
|
||||||
|
fRunButton = createRadioButton(radioComp, "Run program in debugger.");
|
||||||
|
fAttachButton = createRadioButton(radioComp, "Attach to running process.");
|
||||||
|
fCoreButton = createRadioButton(radioComp, "View Corefile.");
|
||||||
|
|
||||||
Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
|
Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
|
||||||
debuggerGroup.setText("Debugger Options");
|
debuggerGroup.setText("Debugger Options");
|
||||||
setDynamicTabHolder(debuggerGroup);
|
setDynamicTabHolder(debuggerGroup);
|
||||||
GridLayout tabHolderLayout = new GridLayout();
|
GridLayout tabHolderLayout = new GridLayout();
|
||||||
tabHolderLayout.marginHeight= 0;
|
tabHolderLayout.marginHeight = 0;
|
||||||
tabHolderLayout.marginWidth= 0;
|
tabHolderLayout.marginWidth = 0;
|
||||||
tabHolderLayout.numColumns = 1;
|
tabHolderLayout.numColumns = 1;
|
||||||
getDynamicTabHolder().setLayout(tabHolderLayout);
|
getDynamicTabHolder().setLayout(tabHolderLayout);
|
||||||
gd = new GridData(GridData.FILL_BOTH);
|
gd = new GridData(GridData.FILL_BOTH);
|
||||||
|
@ -94,7 +108,13 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||||
return fDynamicTab;
|
return fDynamicTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ICDebugConfiguration getDebugConfig() {
|
||||||
|
return fCurrentDebugConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDebugConfig(ICDebugConfiguration config) {
|
||||||
|
fCurrentDebugConfig = config;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Notification that the user changed the selection in the JRE combo box.
|
* Notification that the user changed the selection in the JRE combo box.
|
||||||
*/
|
*/
|
||||||
|
@ -107,101 +127,98 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||||
// remove any debug specfic args from the config
|
// remove any debug specfic args from the config
|
||||||
if (wc == null) {
|
if (wc == null) {
|
||||||
if (getLaunchConfiguration().isWorkingCopy()) {
|
if (getLaunchConfiguration().isWorkingCopy()) {
|
||||||
wc = (ILaunchConfigurationWorkingCopy)getLaunchConfiguration();
|
wc = (ILaunchConfigurationWorkingCopy) getLaunchConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wc != null) {
|
if (wc != null) {
|
||||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
|
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (wc == null) {
|
if (wc == null) {
|
||||||
try {
|
try {
|
||||||
if (getLaunchConfiguration().isWorkingCopy()) {
|
if (getLaunchConfiguration().isWorkingCopy()) {
|
||||||
// get a fresh copy to work on
|
// get a fresh copy to work on
|
||||||
wc = ((ILaunchConfigurationWorkingCopy)getLaunchConfiguration()).getOriginal().getWorkingCopy();
|
wc = ((ILaunchConfigurationWorkingCopy) getLaunchConfiguration()).getOriginal().getWorkingCopy();
|
||||||
} else {
|
|
||||||
wc = getLaunchConfiguration().getWorkingCopy();
|
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
else {
|
||||||
|
wc = getLaunchConfiguration().getWorkingCopy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getDynamicTab().setDefaults(wc);
|
getDynamicTab().setDefaults(wc);
|
||||||
getDynamicTab().initializeFrom(wc);
|
getDynamicTab().initializeFrom(wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLaunchConfigurationDialog();
|
updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadDebuggerComboBox(ILaunchConfiguration config) {
|
protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
|
||||||
ICDebugConfiguration[] debugConfigs;
|
ICDebugConfiguration[] debugConfigs;
|
||||||
String platform;
|
String platform = getPlatform(config);
|
||||||
try {
|
|
||||||
platform = getPlatform(config);
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fDCombo.removeAll();
|
fDCombo.removeAll();
|
||||||
if ( fDinfo != null ) {
|
|
||||||
fDinfo.clear();
|
|
||||||
}
|
|
||||||
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
|
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
|
||||||
fDinfo = new ArrayList(debugConfigs.length);
|
int x = 0;
|
||||||
for( int i = 0; i < debugConfigs.length; i++ ) {
|
int selndx = 0;
|
||||||
|
for (int i = 0; i < debugConfigs.length; i++) {
|
||||||
String supported[] = debugConfigs[i].getPlatforms();
|
String supported[] = debugConfigs[i].getPlatforms();
|
||||||
for( int j = 0; j < supported.length; j++ ) {
|
for (int j = 0; j < supported.length; j++) {
|
||||||
if (supported[j].equals("*") || supported[j].equalsIgnoreCase(platform)) {
|
if (supported[j].equals("*") || supported[j].equalsIgnoreCase(platform)) {
|
||||||
fDinfo.add(debugConfigs[i]);
|
|
||||||
fDCombo.add(debugConfigs[i].getName());
|
fDCombo.add(debugConfigs[i].getName());
|
||||||
|
fDCombo.setData(Integer.toString(x), debugConfigs[i]);
|
||||||
|
if (selection.equals(debugConfigs[i].getID())) {
|
||||||
|
selndx = x;
|
||||||
|
}
|
||||||
|
x++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fDCombo.getParent().layout();
|
fDCombo.select(selndx);
|
||||||
}
|
fDCombo.getParent().layout(true);
|
||||||
|
|
||||||
protected void setSelection(String id) {
|
|
||||||
for (int i = 0; i < fDinfo.size(); i++ ) {
|
|
||||||
ICDebugConfiguration debugConfig = (ICDebugConfiguration) fDinfo.get(i);
|
|
||||||
if ( debugConfig != null && debugConfig.getID().equals(id) ) {
|
|
||||||
fDCombo.select(i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||||
setLaunchConfigurationWorkingCopy(config);
|
setLaunchConfigurationWorkingCopy(config);
|
||||||
loadDebuggerComboBox(config);
|
|
||||||
if ( fDinfo.size() > 0 ) {
|
|
||||||
ICDebugConfiguration dbgCfg = (ICDebugConfiguration) fDinfo.get(0);
|
|
||||||
if ( dbgCfg != null ) {
|
|
||||||
setSelection(dbgCfg.getID());
|
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, dbgCfg.getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||||
if (dynamicTab != null) {
|
if (dynamicTab != null) {
|
||||||
dynamicTab.setDefaults(config);
|
dynamicTab.setDefaults(config);
|
||||||
}
|
}
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
||||||
|
config.setAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeFrom(ILaunchConfiguration config) {
|
public void initializeFrom(ILaunchConfiguration config) {
|
||||||
String id;
|
String id;
|
||||||
|
|
||||||
setLaunchConfiguration(config);
|
setLaunchConfiguration(config);
|
||||||
loadDebuggerComboBox(config);
|
|
||||||
try {
|
try {
|
||||||
id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "");
|
id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "");
|
||||||
setSelection(id);
|
loadDebuggerComboBox(config, id);
|
||||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||||
if (dynamicTab != null) {
|
if (dynamicTab != null) {
|
||||||
dynamicTab.initializeFrom(config);
|
dynamicTab.initializeFrom(config);
|
||||||
}
|
}
|
||||||
if ( config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false) == true ) {
|
if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false) == true) {
|
||||||
stopInMain.setSelection(true);
|
stopInMain.setSelection(true);
|
||||||
}
|
}
|
||||||
|
String mode =
|
||||||
|
config.getAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
|
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|
||||||
|
fAttachButton.setSelection(true);
|
||||||
|
}
|
||||||
|
else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
|
||||||
|
fCoreButton.setSelection(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fRunButton.setSelection(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
return;
|
return;
|
||||||
|
@ -209,16 +226,31 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
||||||
if ( isValid(config) ) {
|
if (isValid(config)) {
|
||||||
ICDebugConfiguration dbgCfg = (ICDebugConfiguration)fDinfo.get(fDCombo.getSelectionIndex());
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID());
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, dbgCfg.getID() );
|
|
||||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||||
if (dynamicTab == null) {
|
if (dynamicTab == null) {
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
dynamicTab.performApply(config);
|
dynamicTab.performApply(config);
|
||||||
}
|
}
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, stopInMain.getSelection());
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, stopInMain.getSelection());
|
||||||
|
if (fAttachButton.getSelection() == true) {
|
||||||
|
config.setAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
|
||||||
|
}
|
||||||
|
else if (fCoreButton.getSelection() == true) {
|
||||||
|
config.setAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
config.setAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +258,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||||
setErrorMessage(null);
|
setErrorMessage(null);
|
||||||
setMessage(null);
|
setMessage(null);
|
||||||
|
|
||||||
if ( fDCombo.getSelectionIndex() == -1 ) {
|
if (fDCombo.getSelectionIndex() == -1) {
|
||||||
setErrorMessage("No debugger avalible");
|
setErrorMessage("No debugger avalible");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -242,13 +274,9 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||||
* Return the class that implements <code>ILaunchConfigurationTab</code>
|
* Return the class that implements <code>ILaunchConfigurationTab</code>
|
||||||
* that is registered against the debugger id of the currently selected debugger.
|
* that is registered against the debugger id of the currently selected debugger.
|
||||||
*/
|
*/
|
||||||
protected ILaunchConfigurationTab getTabForCurrentDebugger() {
|
protected ICDebugConfiguration getConfigForCurrentDebugger() {
|
||||||
int selectedIndex = fDCombo.getSelectionIndex();
|
int selectedIndex = fDCombo.getSelectionIndex();
|
||||||
if (selectedIndex >= 0 && !fDinfo.isEmpty()) {
|
return (ICDebugConfiguration) fDCombo.getData(Integer.toString(selectedIndex));
|
||||||
ICDebugConfiguration dbgCfg = (ICDebugConfiguration) fDinfo.get(selectedIndex);
|
|
||||||
return CDebugUIPlugin.getDefault().getDebuggerPage(dbgCfg.getID());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,16 +291,25 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the dynamic UI for the current Debugger
|
// Retrieve the dynamic UI for the current Debugger
|
||||||
setDynamicTab(getTabForCurrentDebugger());
|
ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
|
||||||
|
if (debugConfig == null) {
|
||||||
|
setDynamicTab(null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setDynamicTab(CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID()));
|
||||||
|
}
|
||||||
if (getDynamicTab() == null) {
|
if (getDynamicTab() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setDebugConfig(debugConfig);
|
||||||
// Ask the dynamic UI to create its Control
|
// Ask the dynamic UI to create its Control
|
||||||
getDynamicTab().setLaunchConfigurationDialog(getLaunchConfigurationDialog());
|
getDynamicTab().setLaunchConfigurationDialog(getLaunchConfigurationDialog());
|
||||||
getDynamicTab().createControl(getDynamicTabHolder());
|
getDynamicTab().createControl(getDynamicTabHolder());
|
||||||
getDynamicTab().getControl().setVisible(true);
|
getDynamicTab().getControl().setVisible(true);
|
||||||
getDynamicTabHolder().layout(true);
|
getDynamicTabHolder().layout(true);
|
||||||
|
|
||||||
|
fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
|
||||||
|
fCoreButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -284,7 +321,8 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||||
ILaunchConfigurationTab tab = getDynamicTab();
|
ILaunchConfigurationTab tab = getDynamicTab();
|
||||||
if ((super.getErrorMessage() != null) || (tab == null)) {
|
if ((super.getErrorMessage() != null) || (tab == null)) {
|
||||||
return super.getErrorMessage();
|
return super.getErrorMessage();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return tab.getErrorMessage();
|
return tab.getErrorMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,7 @@ package org.eclipse.cdt.launch.ui;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICProjectDescriptor;
|
import org.eclipse.cdt.core.ICProjectDescriptor;
|
||||||
|
@ -17,23 +15,14 @@ import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ICRoot;
|
|
||||||
import org.eclipse.cdt.internal.ui.CElementLabelProvider;
|
import org.eclipse.cdt.internal.ui.CElementLabelProvider;
|
||||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
|
import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
|
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||||
import org.eclipse.cdt.utils.elf.Elf;
|
|
||||||
import org.eclipse.core.resources.IContainer;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
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.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
@ -51,8 +40,6 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
|
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
|
||||||
import org.eclipse.ui.dialogs.FilteredList;
|
|
||||||
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A launch configuration tab that displays and edits project and
|
* A launch configuration tab that displays and edits project and
|
||||||
|
@ -86,7 +73,6 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
|
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
Composite comp = new Composite(parent, SWT.NONE);
|
||||||
setControl(comp);
|
setControl(comp);
|
||||||
// WorkbenchHelp.setHelp(getControl(), IJavaDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB);
|
|
||||||
GridLayout topLayout = new GridLayout();
|
GridLayout topLayout = new GridLayout();
|
||||||
comp.setLayout(topLayout);
|
comp.setLayout(topLayout);
|
||||||
|
|
||||||
|
@ -158,13 +144,10 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
* @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
|
* @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
|
||||||
*/
|
*/
|
||||||
public void initializeFrom(ILaunchConfiguration config) {
|
public void initializeFrom(ILaunchConfiguration config) {
|
||||||
try {
|
filterPlatform = getPlatform(config);
|
||||||
filterPlatform = getPlatform(config);
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
}
|
|
||||||
updateProjectFromConfig(config);
|
updateProjectFromConfig(config);
|
||||||
updateProgramFromConfig(config);
|
updateProgramFromConfig(config);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateProjectFromConfig(ILaunchConfiguration config) {
|
protected void updateProjectFromConfig(ILaunchConfiguration config) {
|
||||||
|
@ -197,26 +180,22 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) fProgText.getText());
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) fProgText.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ILaunchConfigurationTab#dispose()
|
|
||||||
*/
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a dialog that lists all main types
|
* Show a dialog that lists all main types
|
||||||
*/
|
*/
|
||||||
protected void handleSearchButtonSelected() {
|
protected void handleSearchButtonSelected() {
|
||||||
String project = fProjText.getText();
|
|
||||||
|
|
||||||
if(project == null || project.length() == 0) {
|
if (getCProject() == null) {
|
||||||
MessageDialog.openInformation(getShell(), "Project required", "Project must first be entered before searching for a program");
|
MessageDialog.openInformation(
|
||||||
|
getShell(),
|
||||||
|
"Project required",
|
||||||
|
"Project must first be entered before searching for a program");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFile [] executables = getExeFiles(project);
|
IBinary[] executables = getBinaryFiles(getCProject());
|
||||||
|
|
||||||
ILabelProvider labelProvider = new WorkbenchLabelProvider();
|
ILabelProvider labelProvider = new CElementLabelProvider();
|
||||||
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
|
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
|
||||||
dialog.setTitle("Program Selection");
|
dialog.setTitle("Program Selection");
|
||||||
dialog.setMessage("Choose a &program to run");
|
dialog.setMessage("Choose a &program to run");
|
||||||
|
@ -229,57 +208,22 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (dialog.open() == dialog.OK) {
|
if (dialog.open() == dialog.OK) {
|
||||||
IFile file = (IFile)dialog.getFirstResult();
|
IBinary binary = (IBinary) dialog.getFirstResult();
|
||||||
fProgText.setText(file.getProjectRelativePath().toString());
|
try {
|
||||||
}
|
fProgText.setText(binary.getResource().getProjectRelativePath().toString());
|
||||||
}
|
}
|
||||||
|
catch (CModelException e) {
|
||||||
/**
|
|
||||||
* Iterate through and suck up all of the executable files that
|
|
||||||
* we can find.
|
|
||||||
*/
|
|
||||||
protected IFile [] getExeFiles(String projectName) {
|
|
||||||
ArrayList exeList = new ArrayList(1);
|
|
||||||
|
|
||||||
IProject project;
|
|
||||||
project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
|
||||||
if(project == null) {
|
|
||||||
return new IFile[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList kids = new ArrayList();
|
|
||||||
try {
|
|
||||||
kids.addAll(Arrays.asList(project.members()));
|
|
||||||
} catch(Exception e) { /* Ignore */ }
|
|
||||||
|
|
||||||
for(int i = 0; i < kids.size(); i++) {
|
|
||||||
Object res = kids.get(i);
|
|
||||||
if(res instanceof IFile) {
|
|
||||||
Elf elf = null;
|
|
||||||
try {
|
|
||||||
elf = new Elf(((IFile)res).getLocation().toOSString());
|
|
||||||
switch(elf.getAttributes().getType()) {
|
|
||||||
case Elf.Attribute.ELF_TYPE_EXE:
|
|
||||||
exeList.add(res);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
|
||||||
/* Ignore */
|
|
||||||
} finally {
|
|
||||||
if(elf != null) {
|
|
||||||
elf.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(res instanceof IContainer) {
|
|
||||||
try {
|
|
||||||
kids.addAll(Arrays.asList(((IContainer)res).members()));
|
|
||||||
} catch(Exception e) { /* Ignore */ }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IFile [])exeList.toArray(new IFile[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate through and suck up all of the executable files that
|
||||||
|
* we can find.
|
||||||
|
*/
|
||||||
|
protected IBinary[] getBinaryFiles(ICProject cproject) {
|
||||||
|
return cproject.getBinaryContainer().getBinaries();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a dialog that lets the user select a project. This in turn provides
|
* Show a dialog that lets the user select a project. This in turn provides
|
||||||
|
@ -376,7 +320,7 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
setErrorMessage("Program not specified");
|
setErrorMessage("Program not specified");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!project.getFile(name).exists() ) {
|
if (!project.getFile(name).exists()) {
|
||||||
setErrorMessage("Program does not exist");
|
setErrorMessage("Program does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue