mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 295808, fix NPE.
This commit is contained in:
parent
107a6a6cf4
commit
3c6f76e9e1
1 changed files with 12 additions and 9 deletions
|
@ -38,20 +38,23 @@ public class MinGWDebuggerPage extends StandardGDBDebuggerPage {
|
|||
protected String defaultGdbCommand(ILaunchConfiguration configuration) {
|
||||
// Lets look it up in the project
|
||||
try {
|
||||
String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
|
||||
String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
|
||||
if (projectName.length() > 0) {
|
||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
|
||||
ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
|
||||
IEnvironmentVariableManager envVarMgr = CCorePlugin.getDefault().getBuildEnvironmentManager();
|
||||
IEnvironmentVariable pathvar = envVarMgr.getVariable("PATH", configDesc, true);
|
||||
String path = pathvar.getValue();
|
||||
String[] dirs = path.split(pathvar.getDelimiter());
|
||||
for (int i = 0; i < dirs.length; ++i) {
|
||||
IPath gdbPath = new Path(dirs[i]).append("gdb.exe"); //$NON-NLS-1$
|
||||
File gdbFile = gdbPath.toFile();
|
||||
if (gdbFile.exists())
|
||||
return gdbPath.toOSString();
|
||||
IEnvironmentVariable pathvar = envVarMgr.getVariable("PATH", configDesc, true); //$NON-NLS-1$
|
||||
if(pathvar != null)
|
||||
{
|
||||
String path = pathvar.getValue();
|
||||
String[] dirs = path.split(pathvar.getDelimiter());
|
||||
for (int i = 0; i < dirs.length; ++i) {
|
||||
IPath gdbPath = new Path(dirs[i]).append("gdb.exe"); //$NON-NLS-1$
|
||||
File gdbFile = gdbPath.toFile();
|
||||
if (gdbFile.exists())
|
||||
return gdbPath.toOSString();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue