diff options
author | Marc Khouzam | 2016-07-04 01:17:54 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-07-08 16:31:24 +0000 |
commit | db2d46c7fc29147f840c7f5278cf8e74938504a2 (patch) | |
tree | 485c870e815b51da7c3ed64b4294ccc5a1194d0d | |
parent | 80f0c9e329a6f3cdb9ff6e600aea28f9c1cfb267 (diff) | |
download | org.eclipse.cdt-db2d46c7fc29147f840c7f5278cf8e74938504a2.tar.gz org.eclipse.cdt-db2d46c7fc29147f840c7f5278cf8e74938504a2.tar.xz org.eclipse.cdt-db2d46c7fc29147f840c7f5278cf8e74938504a2.zip |
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
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java index 71ba42f4eeb..113ce91ee30 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java @@ -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,13 +829,37 @@ 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 * * @param programPath |