[rkward-cvs] [rkward] Make it easier to specify arguments for the frontend debugger.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Nov 17 19:19:56 UTC 2014


NOTE: This is a manual resend of a commit notification that was missing due to 
commit hooks not yet activated.

---

commit e4efb088b6e7af7b23856de1dd7ddb7548248d80
Commit:     Thomas Friedrichsmeier <thomas.friedrichsmeier at ruhr-uni-bochum.de>
CommitDate: Sun Nov 16 20:35:32 2014 +0100

    Make it easier to specify arguments for the frontend debugger.
    Makes it slightly(!) less convoluted to configure a direct debug launch 
from kdevelop...

diff --git a/doc/rkward/man-rkward.1.docbook b/doc/rkward/man-rkward.1.docbook
index dc57ed5..0576e5c 100644
--- a/doc/rkward/man-rkward.1.docbook
+++ b/doc/rkward/man-rkward.1.docbook
@@ -12,7 +12,7 @@
 <affiliation>
 <address><email>rkward-devel at lists.sourceforge.net</email></address>
 </affiliation>
-<date>2013-03-29</date>
+<date>2014-11-16</date>
 </refentryinfo>
 
 <refmeta>
@@ -32,7 +32,7 @@
 <group choice="opt"><option>--evaluate</option> <replaceable> 
Rcode</replaceable></group>
 <group choice="opt"><option>--debug-level</option> <replaceable> 
level</replaceable></group>
 <group choice="opt"><option>--debug-flags</option> <replaceable> 
flags</replaceable></group>
-<group choice="opt"><option>--debugger</option> <replaceable> 
debugger_command</replaceable></group>
+<arg><option>--debugger</option> 
<replaceable>debugger_command</replaceable><arg choice="opt">debugger_args<arg 
choice="opt"><option>--</option></arg></arg></arg>
 <group choice="opt"><option>--backend-debugger</option> <replaceable> 
debugger_command</replaceable></group>
 <group choice="opt"><option>--r-executable</option> <replaceable> 
path_to_executable</replaceable></group>
 <arg choice="opt">KDE Generic Options</arg>
@@ -63,9 +63,10 @@
 <listitem><para>Allows to configure, which sections of code to debug. Flags 
are given as a binary number. Refer to the source files for documentation, as 
this really is an internal option.</para></listitem>
 </varlistentry>
 <varlistentry>
-<term><option>--debugger</option> <replaceable>command</replaceable></term>
-<listitem><para>Run &rkward; through the specified debugger command. To add 
command line options to the debugger command, enclose them in single quotes 
('') together with the command. <emphasis>NOTE:</emphasis> To use the \-\-
debugger option, it must be specified as the first option on the command line. 
Only the frontend process will be debugged, using this option.</para>
-<para>Note that there are a number of pitfalls that may complicate setting up 
the debugger session as desired. Consider starting &rkward; with option \-\-
debug-lebel 3, which will print the effective command line used to start the 
frontend (but not set some environment variables). Under Windows, the debugger 
command will <emphasis>not</emphasis> be connected to stdin. For interactive 
debugging, consider using a graphical debugger.</para></listitem>
+<term><option>--debugger</option> <replaceable>command</replaceable> 
[<replaceable>arguments</replaceable> [<replaceable>--</replaceable>]]</term>
+<listitem><para>Run &rkward; through the specified debugger command. All 
arguments following this will be passed to the debugger command. To end 
debugger arguments (and add arguments to pass to &rkward;), use "--". 
<emphasis>NOTE:</emphasis> Only the frontend process will be debugged, using 
this option.</para>
+<para>Note that there are a number of pitfalls that may complicate setting up 
the debugger session as desired. Consider starting &rkward; with option \-\-
debug-lebel 3, which will print the effective command line used to start the 
frontend (but not all relevant environment variables). As one hint, you will 
generally need to pass a separator arugment with the debugger arguments, e.g. 
<command>rkward --debugger gdb --args</command>.
+Under Windows, the debugger command will <emphasis>not</emphasis> be 
connected to stdin. For interactive debugging, consider using a graphical 
debugger.</para></listitem>
 </varlistentry>
 <varlistentry>
 <term><option>--backend-debugger</option> 
<replaceable>command</replaceable></term>
diff --git a/rkward/main.cpp b/rkward/main.cpp
index 39958cc..6fc9883 100644
--- a/rkward/main.cpp
+++ b/rkward/main.cpp
@@ -123,7 +123,7 @@ int main(int argc, char *argv[]) {
 	options.add ("evaluate <Rcode>", ki18n ("After starting (and after loading 
the specified workspace, if applicable), evaluate the given R code."), 0);
 	options.add ("debug-level <level>", ki18n ("Verbosity of debug messages 
(0-5)"), "2");
 	options.add ("debug-flags <flags>", ki18n ("Mask for components to debug 
(see debug.h)"), QString::number (DEBUG_ALL).toLocal8Bit ());
-	options.add ("debugger <command>", ki18n ("Debugger (enclose any debugger 
arguments in single quotes ('') together with the command)"), "");
+	options.add ("debugger <command and arguments>", ki18n ("Debugger for the 
fronted. Specify last, or add '--' after all debugger arguments"), "");
 	options.add ("backend-debugger <command>", ki18n ("Debugger for the 
backend. (Enclose any debugger arguments in single quotes ('') together with 
the command. Make sure to re-direct stdout!)"), "");
 	options.add ("r-executable <command>", ki18n ("Use specified R 
installation, instead of the one configured at compile time (note: rkward R 
library must be installed to that installation of R)"), "");
 	options.add ("+[File]", ki18n ("R workspace file to open"), 0);
diff --git a/rkward/rkward_startup_wrapper.cpp 
b/rkward/rkward_startup_wrapper.cpp
index bda9753..c83b083 100644
--- a/rkward/rkward_startup_wrapper.cpp
+++ b/rkward/rkward_startup_wrapper.cpp
@@ -100,17 +100,19 @@ int main (int argc, char *argv[]) {
 
 	// Parse arguments that need handling in the wrapper
 	bool usage = false;
-	QString debugger_arg;
+	QStringList debugger_args;
 	QString r_exe_arg;
 	int debug_level = 2;
 
 	for (int i=0; i < args.size (); ++i) {
 		if (args[i] == "--debugger") {
-			if ((i+1) < args.size ()) {
-				debugger_arg = args.takeAt (i + 1);
-			} else usage = true;
 			args.removeAt (i);
-			--i;
+			while (i < args.size ()) {
+				QString arg = args.takeAt (i);
+				if (arg == "--") break;
+				debugger_args.append (arg);
+			}
+			if (debugger_args.isEmpty ()) usage = true;
 		} else if (args[i] == "--r-executable") {
 			if ((i+1) < args.size ()) {
 				r_exe_arg = args.takeAt (i + 1);
@@ -250,7 +252,7 @@ int main (int argc, char *argv[]) {
 
 	qputenv ("R_BINARY", r_exe.toLocal8Bit ());
 	QStringList call_args ("CMD");
-	if (!debugger_arg.isNull ()) call_args.append (debugger_arg.split (" "));
+	call_args.append (debugger_args);
 	call_args.append (quoteCommand (rkward_frontend_exe));
 
 	if (!args.isEmpty ()) {




More information about the rkward-tracker mailing list