[rkward-cvs] SF.net SVN: rkward-code:[4640] trunk/rkward

tfry at users.sf.net tfry at users.sf.net
Fri Mar 29 12:15:50 UTC 2013


Revision: 4640
          http://sourceforge.net/p/rkward/code/4640
Author:   tfry
Date:     2013-03-29 12:15:49 +0000 (Fri, 29 Mar 2013)
Log Message:
-----------
Add --backend-debugger command line option. Should help esp. with debugging backend startup problems in the future.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/doc/rkward/man-rkward.1.docbook
    trunk/rkward/rkward/main.cpp
    trunk/rkward/rkward/rbackend/rkfrontendtransmitter.cpp
    trunk/rkward/rkward/rkglobals.cpp
    trunk/rkward/rkward/rkglobals.h
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/rkward.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2013-03-28 17:51:54 UTC (rev 4639)
+++ trunk/rkward/ChangeLog	2013-03-29 12:15:49 UTC (rev 4640)
@@ -1,3 +1,5 @@
+- Add command line option --backend-debugger
+
 --- Version 0.6.1 - Apr-02-2013
 - Add option to force-close a graphics window
 - Add plugin for subsetting data.frames by rows or columns

Modified: trunk/rkward/doc/rkward/man-rkward.1.docbook
===================================================================
--- trunk/rkward/doc/rkward/man-rkward.1.docbook	2013-03-28 17:51:54 UTC (rev 4639)
+++ trunk/rkward/doc/rkward/man-rkward.1.docbook	2013-03-29 12:15:49 UTC (rev 4640)
@@ -12,7 +12,7 @@
 <affiliation>
 <address><email>rkward-devel at lists.sourceforge.net</email></address>
 </affiliation>
-<date>2011-05-23</date>
+<date>2013-03-29</date>
 </refentryinfo>
 
 <refmeta>
@@ -33,6 +33,7 @@
 <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>
+<group choice="opt"><option>--backend-debugger</option> <replaceable> debugger_command</replaceable></group>
 <arg choice="opt">KDE Generic Options</arg>
 <arg choice="opt">Qt Generic Options</arg>
 </cmdsynopsis>
@@ -64,6 +65,10 @@
 <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></listitem>
 </varlistentry>
+<varlistentry>
+<term><option>--backend-debugger</option> <replaceable>command</replaceable></term>
+<listitem><para>Run the &rkward; backend 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> Debugger arguments will be split by spaces. If this is not appropriate, you will have to write your own wrapper script for invoking the debugger. Also, make sure to redirect all debugger output and/or input as appropriate. See the examples.</para></listitem>
+</varlistentry>
 </variablelist>
 
 </refsect1>
@@ -75,6 +80,14 @@
 </refsect1>
 
 <refsect1>
+<title>Examples</title>
+<para><programlisting>
+# Run the rkward backend through valgrind
+rkward --backend-debugger 'valgrind --log-file=valgrind.log'.
+</programlisting></para>
+</refsect1>
+
+<refsect1>
 <title>Authors</title>
 <para>&rkward; was written by Thomas Friedrichsmeier and the &rkward; team. See <ulink url="http://rkward.sf.net/">the &rkward; website</ulink>.</para>
 </refsect1>

Modified: trunk/rkward/rkward/main.cpp
===================================================================
--- trunk/rkward/rkward/main.cpp	2013-03-28 17:51:54 UTC (rev 4639)
+++ trunk/rkward/rkward/main.cpp	2013-03-29 12:15:49 UTC (rev 4640)
@@ -2,7 +2,7 @@
                           main.cpp  -  description
                              -------------------
     begin                : Tue Oct 29 20:06:08 CET 2002
-    copyright            : (C) 2002, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by Thomas Friedrichsmeier 
+    copyright            : (C) 2002-2013 by Thomas Friedrichsmeier 
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -64,6 +64,7 @@
 #include <stdlib.h>
 
 #include "rkward.h"
+#include "rkglobals.h"
 #include "rkwardapplication.h"
 #include "settings/rksettingsmoduledebug.h"
 #include "windows/rkdebugmessagewindow.h"
@@ -111,17 +112,11 @@
 }
 
 int main(int argc, char *argv[]) {
-/* #ifdef Q_WS_X11
-	This (along with the proper includes, of course) makes library (gWidgetsRGtk2) work on X11 on some systems.
-	Unfortunately, on others, I causes lockups when plotting.
-
-	XInitThreads ();
-	XtToolkitThreadInitialize ();
-#endif */
 	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)"), "8191");
 	options.add ("debugger <command>", ki18n ("Debugger (enclose any debugger arguments in single quotes ('') together with the command)"), "");
+	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 ("+[File]", ki18n ("R workspace file to open"), 0);
 
 	KAboutData aboutData("rkward", QByteArray (), ki18n ("RKWard"), RKWARD_VERSION, ki18n ("Frontend to the R statistics language"), KAboutData::License_GPL, ki18n ("(c) 2002, 2004 - 2013"), KLocalizedString (), "http://rkward.sf.net", "rkward-devel at lists.sourceforge.net");
@@ -163,11 +158,11 @@
 		RK_DEBUG (ALL, DL_ERROR, "--debugger option should have been handled by wrapper script. Ignoring.");
 	}
 
-	RKWardStartupOptions *stoptions = new RKWardStartupOptions;
 	if (args->count ()) {
-		stoptions->initial_url = args->url (0);
+		RKGlobals::startup_options["initial_url"] = QUrl (args->url (0));
 	}
-	stoptions->evaluate = args->getOption ("evaluate");
+	RKGlobals::startup_options["evaluate"] = args->getOption ("evaluate");
+	RKGlobals::startup_options["backend-debugger"] = args->getOption ("backend-debugger");
 
 	RKWardApplication app;
 	// install message handler *after* the componentData has been initialized
@@ -181,7 +176,7 @@
 	if (app.isSessionRestored ()) {
 		RESTORE(RKWardMainWindow);	// well, whatever this is supposed to do -> TODO
 	} else {
-		new RKWardMainWindow(stoptions);
+		new RKWardMainWindow ();
 	}
 	args->clear();
 

Modified: trunk/rkward/rkward/rbackend/rkfrontendtransmitter.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkfrontendtransmitter.cpp	2013-03-28 17:51:54 UTC (rev 4639)
+++ trunk/rkward/rkward/rbackend/rkfrontendtransmitter.cpp	2013-03-29 12:15:49 UTC (rev 4640)
@@ -2,7 +2,7 @@
                           rkfrontendtransmitter  -  description
                              -------------------
     begin                : Thu Nov 04 2010
-    copyright            : (C) 2010, 2011 by Thomas Friedrichsmeier
+    copyright            : (C) 2010-2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -20,10 +20,11 @@
 #include "rkrbackendprotocol_frontend.h"
 #include "../misc/rkcommonfunctions.h"
 #include "../settings/rksettingsmodulegeneral.h"
+#include "../rkglobals.h"
 
-#include "klocale.h"
-#include "krandom.h"
-#include "kstandarddirs.h"
+#include <klocale.h>
+#include <krandom.h>
+#include <kstandarddirs.h>
 #include <QCoreApplication>
 #include <QProcess>
 #include <QLocalServer>
@@ -77,7 +78,15 @@
         if (backend_executable.isEmpty ()) backend_executable = KStandardDirs::findExe (QDir::toNativeSeparators (QCoreApplication::applicationDirPath () + "/../../../rbackend/rkward.rbackend"));
 #endif
 	RK_ASSERT (!backend_executable.isEmpty ());
-	backend->start (backend_executable, args, QIODevice::ReadOnly);
+	QString debugger = RKGlobals::startup_options["backend-debugger"].toString ();
+	if (!debugger.isEmpty ()) {
+		args.prepend (backend_executable);
+		QStringList l = debugger.split (' ');
+		args = l.mid (1) + args;
+		backend->start (l.first (), args, QIODevice::ReadOnly);
+	} else {
+		backend->start (backend_executable, args, QIODevice::ReadOnly);
+	}
 
 	// fetch security token
 	if (!backend->canReadLine ()) backend->waitForReadyRead ();

Modified: trunk/rkward/rkward/rkglobals.cpp
===================================================================
--- trunk/rkward/rkward/rkglobals.cpp	2013-03-28 17:51:54 UTC (rev 4639)
+++ trunk/rkward/rkward/rkglobals.cpp	2013-03-29 12:15:49 UTC (rev 4640)
@@ -20,14 +20,8 @@
 
 RInterface *RKGlobals::rinter;
 RKModificationTracker *RKGlobals::mtracker;
+QVariantMap RKGlobals::startup_options;
 
-RKGlobals::RKGlobals () {
-}
-
-
-RKGlobals::~RKGlobals () {
-}
-
 #include <kdialog.h>
 
 int RKGlobals::marginHint () {

Modified: trunk/rkward/rkward/rkglobals.h
===================================================================
--- trunk/rkward/rkward/rkglobals.h	2013-03-28 17:51:54 UTC (rev 4639)
+++ trunk/rkward/rkward/rkglobals.h	2013-03-29 12:15:49 UTC (rev 4640)
@@ -2,7 +2,7 @@
                           rkglobals  -  description
                              -------------------
     begin                : Wed Aug 18 2004
-    copyright            : (C) 2004 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -17,6 +17,8 @@
 #ifndef RKGLOBALS_H
 #define RKGLOBALS_H
 
+#include <QVariantMap>
+
 class RKWardMainWindow;
 class RInterface;
 class RObjectList;
@@ -34,11 +36,6 @@
 */
 class RKGlobals{
 public:
-/** constructor. Do not use. No instance needed of this class. Only static stuff inside */
-	RKGlobals ();
-/** destructor. Do not use. No instance needed of this class. Only static stuff inside */
-	~RKGlobals ();
-
 /// static pointer to the RInterface
 	static RInterface *rInterface () { return rinter; };
 /// static pointer to the RKModificationTracker
@@ -49,8 +46,7 @@
 /// returns KDialog::spacingHint (), without the need to include kdialog.h in all the sources
 	static int spacingHint ();
 
-	static void deleteStrings (QString **strings, int count);
-
+	static QVariantMap startup_options;
 private:
 	friend class RKWardMainWindow;
 	static RInterface *rinter;

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2013-03-28 17:51:54 UTC (rev 4639)
+++ trunk/rkward/rkward/rkward.cpp	2013-03-29 12:15:49 UTC (rev 4640)
@@ -115,7 +115,7 @@
 //static
 RKWardMainWindow *RKWardMainWindow::rkward_mainwin = 0;
 
-RKWardMainWindow::RKWardMainWindow (RKWardStartupOptions *options) : KParts::MainWindow ((QWidget *)0, (Qt::WindowFlags) KDE_DEFAULT_WINDOWFLAGS) {
+RKWardMainWindow::RKWardMainWindow () : KParts::MainWindow ((QWidget *)0, (Qt::WindowFlags) KDE_DEFAULT_WINDOWFLAGS) {
 	RK_TRACE (APP);
 	RK_ASSERT (rkward_mainwin == 0);
 
@@ -159,8 +159,6 @@
 
 	RKComponentMap::initialize ();
 
-	startup_options = options;
-
 	// stuff which should wait until the event loop is running
 	QTimer::singleShot (0, this, SLOT (doPostInit ()));
 }
@@ -203,11 +201,8 @@
 		KMessageBox::error (this, i18n ("<p>RKWard either could not find its resource files at all, or only an old version of those files. The most likely cause is that the last installation failed to place the files in the correct place. This can lead to all sorts of problems, from single missing features to complete failure to function.</p><p><b>You should quit RKWard, now, and fix your installation</b>. For help with that, see <a href=\"http://p.sf.net/rkward/compiling\">http://p.sf.net/rkward/compiling</a>.</p>"), i18n ("Broken installation"), KMessageBox::Notify | KMessageBox::AllowLink);
 	}
 
-	// startup options will be deleted from the R thread (TODO correct this!), so we need to copy the initial_url here, or run into race conditions
-	KUrl open_url = startup_options ? startup_options->initial_url : KUrl ();
-	QString evaluate_code = startup_options ? startup_options->evaluate : QString ();
-	delete startup_options;
-	startup_options = 0;
+	KUrl open_url = RKGlobals::startup_options.take ("initial_url").toUrl ();
+	QString evaluate_code = RKGlobals::startup_options.take ("evaluate").toString ();
 
 	initPlugins ();
 	gui_rebuild_locked = false;

Modified: trunk/rkward/rkward/rkward.h
===================================================================
--- trunk/rkward/rkward/rkward.h	2013-03-28 17:51:54 UTC (rev 4639)
+++ trunk/rkward/rkward/rkward.h	2013-03-29 12:15:49 UTC (rev 4640)
@@ -31,11 +31,6 @@
 class KSqueezedTextLabel;
 class QAction;
 
-struct RKWardStartupOptions {
-	KUrl initial_url;	/**< The workspace file to load on startup. If empty, show a dialog asking what to do. **/
-	QString evaluate;	/**< R code to run after startup */
-};
-
 /**
 The main class of rkward. This is where all strings are tied togther, controlls the initialization, and there are some of the most important slots for user actions. All real work is done elsewhere.
 */
@@ -44,7 +39,7 @@
 public:
 /** construtor
 @param options Options from command line. RKWardMainWindow will take ownership of this pointer, and delete it, once not longer needed. */
-	RKWardMainWindow (RKWardStartupOptions *options = 0);
+	RKWardMainWindow ();
 /** destructor */
 	~RKWardMainWindow ();
 
@@ -181,8 +176,6 @@
 	/** Finds plugins and inserts them into the menu-structure */
 	void initPlugins (const QStringList &automatically_added = QStringList ());
 
-	RKWardStartupOptions *startup_options;
-
 	static RKWardMainWindow *rkward_mainwin;
 
 	friend class RInterface;





More information about the rkward-tracker mailing list