mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-06 00:25:25 +02:00
Bug 497206: Remote-attach fails attach if binary not specified in launch
The core exception we used to throw when the program patch was not present is necessary for GDBBackend#getProgramPath() to set the path to an empty value instead of returning null. Although we could have made GdbLaunch#getProgramPath return and empty string to fix this problem, I thought we should play it safe and behave like we used to in case something else needed that exception thrown. Change-Id: I4684226c731aedef50bdeb37accdf2a2feb818b5
This commit is contained in:
parent
80f0c9e329
commit
db2d46c7fc
1 changed files with 30 additions and 3 deletions
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.dsf.gdb.launching;
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -808,12 +809,14 @@ public class GdbLaunch extends DsfLaunch implements ITerminate, IDisconnect, ITr
|
|||
(String) null);
|
||||
}
|
||||
if (programName == null) {
|
||||
return null;
|
||||
throwException(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
|
||||
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
|
||||
}
|
||||
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
|
||||
IPath programPath = new Path(programName);
|
||||
if (programPath.isEmpty()) {
|
||||
return null;
|
||||
throwException(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"), null, //$NON-NLS-1$
|
||||
ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
|
||||
}
|
||||
|
||||
if (!programPath.isAbsolute()) {
|
||||
|
@ -826,12 +829,36 @@ public class GdbLaunch extends DsfLaunch implements ITerminate, IDisconnect, ITr
|
|||
}
|
||||
}
|
||||
if (!programPath.toFile().exists()) {
|
||||
return null;
|
||||
throwException(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$
|
||||
new FileNotFoundException(
|
||||
LaunchMessages.getFormattedString("AbstractCLaunchDelegate.PROGRAM_PATH_not_found", //$NON-NLS-1$
|
||||
programPath.toOSString())),
|
||||
ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
|
||||
}
|
||||
|
||||
return programPath.toOSString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private static void throwException(String message, Throwable exception, int code) throws CoreException {
|
||||
MultiStatus status = new MultiStatus(GdbPlugin.PLUGIN_ID, code, message, exception);
|
||||
status.add(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, code,
|
||||
exception == null ? "" : exception.getLocalizedMessage(), //$NON-NLS-1$
|
||||
exception));
|
||||
throw new CoreException(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the program path
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue