[eclipse-cdt] Update Stand-alone debugger
Jeff Johnston
jjohnstn at fedoraproject.org
Thu Jul 10 23:19:17 UTC 2014
commit 9c89132fd2447538b64052ae107082852f110f1f
Author: Jeff Johnston <jjohnstn at redhat.com>
Date: Thu Jul 10 19:18:45 2014 -0400
Update Stand-alone debugger
- include fixes, help support, and a man page
cdtdebug.man | 85 +++++++++++++++
eclipse-cdt-cdtdebug.patch | 5 +-
eclipse-cdt-cdtdebug.patch2 | 248 +++++++++++++++++++++++++++++++++++++++++++
eclipse-cdt.spec | 26 +++++-
4 files changed, 361 insertions(+), 3 deletions(-)
---
diff --git a/cdtdebug.man b/cdtdebug.man
new file mode 100644
index 0000000..710d76f
--- /dev/null
+++ b/cdtdebug.man
@@ -0,0 +1,85 @@
+.\" Manpage for cdtdebug.
+.\" Contact jjohnstn at redhat.com to correct errors or typos.
+.TH man 1 "07 July 2014" "1.0" "cdtdebug man page"
+.SH NAME
+cdtdebug \- The Eclipse C/C++ Stand-alone Debugger
+.SH SYNOPSIS
+cdtdebug [
+.I "ECLIPSE-OPTIONS"
+] [
+.B -h, --help
+] [
+.B -b
+.I build-log
+] [
+.B -a
+] | [
+.B -c
+.I core
+]
+.B -e
+.I executable...
+]
+.SH DESCRIPTION
+cdtdebug is a graphical C/C++ debugger using Eclipse and gdb. The debugger uses Eclipse plug-ins and features found in the eclipse-cdt package
+and invokes an Eclipse application specialized to bring up just the C/C++ debugging elements. The debugger can be used to debug executables,
+core files, and can also attach to existing processes. Internally, gdb is used to perform the debugging tasks via the gdb/mi interface. For more info, see the upstream
+.UR https://wiki.eclipse.org/CDT/StandaloneDebugger
+wiki page
+.UE .
+.SH OPTIONS
+.PP
+Operation modes:
+.IP "\fB-h, --help\fR"
+.PD
+print help, then exit.
+.PD
+.PP
+Indexing assist options:
+.IP "\fB-b \fIbuild-log\fR"
+.PD
+specify build log to use for compiler includes/flags.
+.PP
+Target options:
+.IP "\fB-a\fR"
+.PD
+attach to an existing process (list will be shown).
+.PD
+.IP "\fB-c \fIcore\fR"
+.PD
+debug core file (need to also specify corresponding executable).
+.PD
+.IP "\fB-e \fIexecutable\fR [ \fIargs...\fR ]
+.PD
+debug given executable (passing
+.I args
+to main).
+.PD
+.PP
+The
+.B -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
+.B -e
+invocation, if one exists.
+
+For details on options that can be passed to Eclipse, see:
+.UR http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Frunning_eclipse.htm
+.UE .
+.SH SEE ALSO
+.I gdb(1)
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Jeff Johnston (jjohnstn at redhat.com)
+.SH COPYRIGHT
+Copyright (c) 2014 Red Hat Inc.
+
+Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being "Free Software" and "Free Software Needs Free Documentation", with the Front-Cover Texts being "A GNU Manual," and with the Back-Cover Texts as in (a) below.
+
+(a) The FSF's Back-Cover Text is: "You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom."
+
diff --git a/eclipse-cdt-cdtdebug.patch b/eclipse-cdt-cdtdebug.patch
index 6ece8ea..c01bd75 100644
--- a/eclipse-cdt-cdtdebug.patch
+++ b/eclipse-cdt-cdtdebug.patch
@@ -10,7 +10,7 @@ diff -up ./debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh.orig ./de
-cp config.ini $HOME/cdtdebugger
-cp dev.properties $HOME/cdtdebugger
+ECLIPSE_HOME=@ECLIPSE_HOME@
-+if [ $0 .nt $HOME/fcdtdebugger ]; then
++if [ $0 -nt $HOME/fcdtdebugger ]; then
+rm -rf $HOME/fcdtdebugger >/dev/null
+mkdir -p $HOME/fcdtdebugger
+cp config.ini $HOME/fcdtdebugger
@@ -20,7 +20,8 @@ diff -up ./debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh.orig ./de
-cd ../..
+cd $ECLIPSE_HOME/plugins
OSGI_JAR=`ls org.eclipse.osgi_*.jar`
- SWT_JAR=`ls org.eclipse.swt.*.jar`
+-SWT_JAR=`ls org.eclipse.swt.*.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`
+FS_JAR=`ls org.eclipse.core.filesystem*.jar | grep -v java7`
diff --git a/eclipse-cdt-cdtdebug.patch2 b/eclipse-cdt-cdtdebug.patch2
new file mode 100644
index 0000000..a268b64
--- /dev/null
+++ b/eclipse-cdt-cdtdebug.patch2
@@ -0,0 +1,248 @@
+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);
diff --git a/eclipse-cdt.spec b/eclipse-cdt.spec
index 4c0d1c2..f5f0fd3 100644
--- a/eclipse-cdt.spec
+++ b/eclipse-cdt.spec
@@ -28,7 +28,7 @@ Epoch: 1
Summary: Eclipse C/C++ Development Tools (CDT) plugin
Name: %{?scl_prefix}eclipse-cdt
Version: %{majmin}.%{micro}
-Release: 1%{?dist}
+Release: 2%{?dist}
License: EPL and CPL
Group: Development/Tools
URL: http://www.eclipse.org/cdt
@@ -40,6 +40,9 @@ Source2: http://git.eclipse.org/c/linuxtools/org.eclipse.linuxtools.git/snapshot
Source3: eclipse-cdt.desktop
+# man-page for /usr/bin/cdtdebug
+Source4: cdtdebug.man
+
# Script to run the tests in Xvnc
Source5: %{name}-runtests.sh
@@ -89,6 +92,10 @@ Patch13: %{pkg_name}-cdtdebug-readme.patch
# Following fixes jetty reqs in CDT target
Patch14: %{pkg_name}-target.patch
+# Following add help support for cdtdebug and fixes executable location support to
+# include system path and properly use relative directories
+Patch15: %{pkg_name}-cdtdebug.patch2
+
BuildRequires: tycho
BuildRequires: tycho-extras
BuildRequires: %{?scl_prefix}eclipse-pde >= 1:4.3.0
@@ -158,6 +165,10 @@ Source for Eclipse CDT for use within Eclipse.
mkdir desktop
cp %{SOURCE3} desktop
+# handle man page
+mkdir man
+cp %{SOURCE4} man
+
pushd %{cdt_snapshot}
%patch0 -p1
%patch4 -p1
@@ -168,6 +179,7 @@ pushd %{cdt_snapshot}
%patch12 -p1
%patch13 -p1
%patch14 -p1
+%patch15 -p1
sed -i -e 's/<arch>x86<\/arch>/<arch>%{eclipse_arch}<\/arch>/g' pom.xml
# Add secondary arch support if we are building there
%ifarch %{arm} s390 s390x aarch64
@@ -303,12 +315,14 @@ parsersInstallDir=${installDir}-parsers
llvmInstallDir=${installDir}-llvm
sdkInstallDir=${installDir}-sdk
binInstallDir=${RPM_BUILD_ROOT}/%{_bindir}
+manInstallDir=${RPM_BUILD_ROOT}/%{_mandir}/man1
install -d -m755 $installDir
install -d -m755 $parsersInstallDir
install -d -m755 $llvmInstallDir
install -d -m755 $sdkInstallDir
install -d -m755 $testInstallDir
install -d -m755 $binInstallDir
+install -d -m755 $manInstallDir
# Unzip contents of the cdt repo, removing all but plugins and features
unzip -q -o %{cdt_snapshot}/releng/org.eclipse.cdt.repo/target/org.eclipse.cdt.repo.zip \
@@ -392,6 +406,8 @@ PLUGIN=$(ls . | grep org.eclipse.cdt.debug.ui_)
sed -i -e "s,org.eclipse.cdt.debug.ui\,,file\\\\:%{eclipse_base}/dropins/cdt/eclipse/plugins/$PLUGIN\,," org.eclipse.cdt.debug.application_$DEBUGAPPLICATIONVERSION/scripts/config.ini
PLUGIN=$(ls . | grep org.eclipse.cdt.debug.core_)
sed -i -e "s,org.eclipse.cdt.debug.core\,,file\\\\:%{eclipse_base}/dropins/cdt/eclipse/plugins/$PLUGIN\,," org.eclipse.cdt.debug.application_$DEBUGAPPLICATIONVERSION/scripts/config.ini
+PLUGIN=$(ls . | grep org.eclipse.cdt.core.native_)
+sed -i -e "s,org.eclipse.cdt.core.native\,,file\\\\:%{eclipse_base}/dropins/cdt/eclipse/plugins/$PLUGIN\,," org.eclipse.cdt.debug.application_$DEBUGAPPLICATIONVERSION/scripts/config.ini
PLUGIN=$(ls . | grep 'org.eclipse.cdt.core.linux\..*.jar' | grep -v source)
sed -i -e "s,\$linux.plugin\$\,,file\\\\:%{eclipse_base}/dropins/cdt/eclipse/plugins/$PLUGIN\,," org.eclipse.cdt.debug.application_$DEBUGAPPLICATIONVERSION/scripts/config.ini
sed -i -e "s,cp config.ini,cp %{eclipse_base}/dropins/cdt/eclipse/plugins/org.eclipse.cdt.debug.application_$DEBUGAPPLICATIONVERSION/scripts/config.ini," org.eclipse.cdt.debug.application_$DEBUGAPPLICATIONVERSION/scripts/cdtdebug.sh
@@ -402,6 +418,9 @@ popd
install -D desktop/eclipse-cdt.desktop $RPM_BUILD_ROOT/%{_datadir}/applications/%{?scl_prefix}eclipse-cdt.desktop
desktop-file-validate $RPM_BUILD_ROOT/%{_datadir}/applications/%{?scl_prefix}eclipse-cdt.desktop
+# man page
+cp man/cdtdebug.man $manInstallDir/cdtdebug.1
+
# Unpack all existing feature jars
for x in $installDir/eclipse/features/*.jar; do
dirname=`echo $x | sed -e 's:\\(.*\\)\\.jar:\\1:g'`
@@ -459,6 +478,7 @@ rm -rf $installDir/eclipse/binary
%{eclipse_base}/dropins/cdt
%{_bindir}/cdtdebug
%{_datadir}/applications/*
+%{_mandir}/man1/cdtdebug.1*
%doc %{cdt_snapshot}/releng/org.eclipse.cdt.releng/epl-v10.html
%doc %{cdt_snapshot}/releng/org.eclipse.cdt.releng/notice.html
@@ -483,6 +503,10 @@ rm -rf $installDir/eclipse/binary
%doc %{cdt_snapshot}/releng/org.eclipse.cdt.releng/notice.html
%changelog
+* Thu Jul 10 2014 Jeff Johnston <jjohnstn at redhat.com> 1:8.4.0-2
+- Update Stand-alone debugger support to include fixes, help
+ support, and a man page
+
* Thu Jun 26 2014 Jeff Johnston <jjohnstn at redhat.com> 1:8.4.0-1
- Update to offical Luna CDT 8.4.0 and Linux Tools 3.0
More information about the scm-commits
mailing list