diff -up ./debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh.fix ./debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh
--- ./debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh.fix 2014-07-10 13:27:20.764243433 -0400
+++ ./debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh 2014-07-10 13:27:25.076314647 -0400
@@ -10,27 +10,91 @@
# Red Hat Inc. - initial API and implementation
###############################################################################
ECLIPSE_HOME=@ECLIPSE_HOME@
+# Make sure local directory exists and is up to date
if [ $0 -nt $HOME/fcdtdebugger ]; then
rm -rf $HOME/fcdtdebugger >/dev/null
mkdir -p $HOME/fcdtdebugger
cp config.ini $HOME/fcdtdebugger
cp dev.properties $HOME/fcdtdebugger
fi
+
+usage="\
+Usage: $0 [ECLIPSE_OPTIONS] [-b BUILD_LOG] [TARGET_OPTION]
+
+Debug an executable, core-file, or an existing process using the Eclipse
+C/C++ Stand-alone Debugger. Eclipse command-line options may be passed
+except for -vmargs which is being used to start up the Eclipse Debugger.
+
+Operation modes:
+ -h, --help print this help, then exit
+
+Indexing assist options:
+ -b BUILD_LOG build log to use for compiler includes/flags
+
+Target options:
+ -a attach to an existing process (list will be shown)
+ -c COREFILE debug core-file (should also specify executable)
+ -e EXECUTABLE [ARGS...] debug given executable (passing ARGS to main)
+
+The -e option must be used last as subsequent options are passed to main.
+
+Specifying insufficient arguments for a particular target will result in a
+dialog displayed to enter the required values for that target. Specifying
+no target option brings up a dialog for debugging an executable with the
+executable path, program arguments, and build log filled in from the last -e
+invocation, if one exists.
+
+Wiki page: <http://wiki.eclipse.org/CDT/StandaloneDebugger>"
+
+exit_missing_arg='
+ echo $0": error: option [$1] requires an argument"; exit 1'
+
+# Parse command line.
+options=
+while test $# -gt 0 ; do
+ case $1 in
+ --help | -h )
+ echo "$usage"; exit ;;
+ -vmargs )
+ echo $0": error: -vmargs option is prohibited"; exit 1;;
+ -e )
+ test $# = 1 && eval "$exit_missing_arg"
+ options="$options $1 $2"
+ shift; shift;
+ # Get all options after -e and protect them from being
+ # processed by Eclipse as Eclipse options
+ while test $# -gt 0; do
+ options="$options \"$1\""
+ shift;
+ done ;;
+ -c )
+ test $# = 1 && eval "$exit_missing_arg"
+ options="$options $1 $2"
+ shift; shift ;;
+ * )
+ options="$options $1"; shift ;;
+ esac
+done
+
+
+# Calculate platform-specific jar file names
olddir=`pwd`
cd $ECLIPSE_HOME/plugins
OSGI_JAR=`ls org.eclipse.osgi_*.jar`
SWT_JAR=`ls -d org.eclipse.swt.*`
SWT_PLUGIN=`echo $SWT_JAR | sed -e "s/_[0-9]*\..*.jar//"`
-FS_JAR=`ls org.eclipse.core.filesystem*.jar | grep -v java7`
+FS_JAR=`ls org.eclipse.core.filesystem.*.jar | grep -v java7`
FS_PLUGIN=`echo $FS_JAR | sed -e "s/_[0-9]*\..*.jar//"`
cd @CDT_DROPINS@
LINUX_JAR=`ls org.eclipse.cdt.core.linux.*.jar`
LINUX_PLUGIN=`echo $LINUX_JAR | sed -e "s/_[0-9]*\..*.jar//"`
cd $olddir
+
+# Run eclipse with the Stand-alone Debugger product specified
$ECLIPSE_HOME/eclipse -clean -product org.eclipse.cdt.debug.application.product \
-application org.eclipse.cdt.debug.application.app \
-data $HOME/workspace-fcdtdebug -configuration file\:$HOME/fcdtdebugger \
--dev file\:$HOME/fcdtdebugger/dev.properties $@ \
+-dev file\:$HOME/fcdtdebugger/dev.properties $options \
-vmargs -Dosgi.jar=$OSGI_JAR -Dswt.plugin=$SWT_PLUGIN -Dfs.plugin=$FS_PLUGIN \
-Dlinux.plugin=$LINUX_PLUGIN -Declipse.home=$ECLIPSE_HOME
diff -up ./debug/org.eclipse.cdt.debug.application/scripts/install.sh.fix ./debug/org.eclipse.cdt.debug.application/scripts/install.sh
--- ./debug/org.eclipse.cdt.debug.application/scripts/install.sh.fix 2014-07-10 13:28:02.635933926 -0400
+++ ./debug/org.eclipse.cdt.debug.application/scripts/install.sh 2014-07-10 13:29:28.325347751 -0400
@@ -9,16 +9,4 @@
# Contributors:
# Red Hat Inc. - initial API and implementation
###############################################################################
-if [ ! -d $HOME/cdtdebugger ]; then
-mkdir -p $HOME/cdtdebugger
-fi
-cp config.ini $HOME/cdtdebugger
-cp dev.properties $HOME/cdtdebugger
-cp cdtdebug.sh $HOME/cdtdebugger
-chmod +x $HOME/cdtdebugger/cdtdebug.sh
-olddir=`pwd`
-cd ../..
-PLUGINS_DIR=`pwd`
-cd $olddir
-sed -i -e "s,cd ../..,cd $PLUGINS_DIR," $HOME/cdtdebugger/cdtdebug.sh
-echo "Installation complete"
+echo "Installation already done"
diff -up ./debug/org.eclipse.cdt.debug.application/scripts/README.fix ./debug/org.eclipse.cdt.debug.application/scripts/README
--- ./debug/org.eclipse.cdt.debug.application/scripts/README.fix 2014-07-10 13:30:00.077871376 -0400
+++ ./debug/org.eclipse.cdt.debug.application/scripts/README 2014-07-10 13:30:24.686277721 -0400
@@ -37,11 +37,4 @@ an executable, build log, and program ar
e.g. cdtdebug -b ~/build.log ~/myproject/bin/a.out arg1 arg2
-The cdtdebug.sh script that is found in the plug-in can also be run directly, but only
-from the scripts directory as it uses relative directories to find the Eclipse instance and
-the plugins directory. The one installed in the cdtdebugger directory replaces these
-relative directory references with absolute ones.
-
- e.g. sh ./cdtdebug.sh -b ~/build.log ~/myproject/bin/a.out arg1 arg2
-
diff -up ./debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java.fix ./debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java
--- ./debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java.fix 2014-07-10 13:31:50.775697240 -0400
+++ ./debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java 2014-07-10 13:32:17.761142405 -0400
@@ -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.ap
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 ApplicationWorkbenchWindowA
}
}
+ // 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 ApplicationWorkbenchWindowA
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
@@ -158,14 +195,19 @@ public class ApplicationWorkbenchWindowA
}
// Verify any core file or executable path is valid.
if (corefile != null) {
- File executableFile = new File(executable);
+ File executableFile = null;
+ if (executable != null) {
+ executableFile = new File(executable);
+ executable = executableFile.getCanonicalPath();
+ }
File coreFile = new File(corefile);
- if (!executableFile.exists() || !coreFile.exists()) {
+ corefile = coreFile.getCanonicalPath();
+ if (executable == null || !executableFile.exists() || !coreFile.exists()) {
final CoreFileInfo info = new CoreFileInfo("", "", ""); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
final IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0,
Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist, null);
final String executablePath = executable;
- final String coreFilePath = buildLog;
+ final String coreFilePath = corefile;
Display.getDefault().syncExec(new Runnable() {
@@ -197,7 +239,13 @@ public class ApplicationWorkbenchWindowA
}
} else if (executable != null) {
File executableFile = new File(executable);
- if (!executableFile.exists()) {
+ executable = executableFile.getCanonicalPath();
+ File buildLogFile = null;
+ if (buildLog != null) {
+ buildLogFile = new File(buildLog);
+ buildLog = buildLogFile.getCanonicalPath();
+ }
+ if (!executableFile.exists() || (buildLog != null && !buildLogFile.exists())) {
final NewExecutableInfo info = new NewExecutableInfo("", "", "", ""); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
final IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0,
Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist, null);