mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Bug 437782 - Standalone Debugger does not consider the executable PATH
- add code to search PATH using "which" command if the executable consists of a single segment and is not absolute Change-Id: I0e36adc99d206c4f61e58747eb3ebfc30cd1437c Reviewed-on: https://git.eclipse.org/r/28790 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
This commit is contained in:
parent
49b65cb5b2
commit
3d78256606
1 changed files with 38 additions and 1 deletions
|
@ -10,8 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.application;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
|
@ -19,11 +23,13 @@ import org.eclipse.cdt.internal.debug.application.DebugAttachedExecutable;
|
|||
import org.eclipse.cdt.internal.debug.application.DebugCoreFile;
|
||||
import org.eclipse.cdt.internal.debug.application.DebugExecutable;
|
||||
import org.eclipse.cdt.internal.debug.application.JobContainer;
|
||||
import org.eclipse.cdt.utils.spawner.ProcessFactory;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.MultiStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
@ -105,6 +111,37 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
|||
}
|
||||
}
|
||||
|
||||
// Private method to search for executable names on PATH
|
||||
private String findExecutable(String input) {
|
||||
String result = input;
|
||||
|
||||
Path x = new Path(input);
|
||||
try {
|
||||
if (!x.isAbsolute() && x.segmentCount() == 1) {
|
||||
String command = "which " + input; //$NON-NLS-1$
|
||||
Process p = null;
|
||||
InputStream in = null;
|
||||
try {
|
||||
p = ProcessFactory.getFactory().exec(command);
|
||||
in = p.getInputStream();
|
||||
InputStreamReader reader = new InputStreamReader(in);
|
||||
BufferedReader br = new BufferedReader(reader);
|
||||
String line = br.readLine();
|
||||
if (line != null)
|
||||
result = line;
|
||||
} finally {
|
||||
if (in != null)
|
||||
in.close();
|
||||
if (p != null)
|
||||
p.destroy();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// do nothing
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public class PostWindowCreateRunnable implements IRunnableWithProgress {
|
||||
|
||||
@Override
|
||||
|
@ -143,7 +180,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
|||
else if ("-e".equals(args[i])) {
|
||||
++i;
|
||||
if (i < args.length)
|
||||
executable = args[i];
|
||||
executable = findExecutable(args[i]);
|
||||
++i;
|
||||
StringBuffer argBuffer = new StringBuffer();
|
||||
// Remaining values are arguments to the executable
|
||||
|
|
Loading…
Add table
Reference in a new issue