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

[304433] Get ProgramRelatvePathSourceContainer to support DSF's ability to debug a binary outside a project

This commit is contained in:
John Cortell 2010-03-02 22:54:49 +00:00
parent e815923c47
commit 324bc25ac9

View file

@ -143,11 +143,16 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
return fProgramPath; // return empty path return fProgramPath; // return empty path
} }
// get current project // Get current project. Unlike CDI, DSF supports debugging
// executables that are not in an Eclipse project, so this may be
// null for a DSF session. See bugzilla 304433.
ICProject project = null;
String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null); String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
ICProject project = CoreModel.getDefault().getCModel().getCProject(projectName); if (projectName != null) {
if (project == null || !project.exists()) { project = CoreModel.getDefault().getCModel().getCProject(projectName);
return fProgramPath; // return empty path if (project == null || !project.exists()) {
return fProgramPath; // return empty path
}
} }
// get program name // get program name
@ -159,7 +164,23 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
// get executable file // get executable file
IFile exeFile = null; IFile exeFile = null;
try { try {
exeFile = project.getProject().getFile(new Path(programName)); if (project != null) {
exeFile = project.getProject().getFile(new Path(programName));
}
else {
// A DSF launch config need not reference a project. Try
// treating program name as either an absolute path or a
// path relative to the working directory
IPath path = new Path(programName);
if (path.toFile().exists()) {
fProgramPath = path;
return fProgramPath;
}
else {
return fProgramPath; // return empty path
}
}
} }
catch (IllegalArgumentException e){ catch (IllegalArgumentException e){
return fProgramPath; // return empty path return fProgramPath; // return empty path