[PATCH] qapitrace: Support executing glretrace on a remote target host.

Carl Worth cworth at cworth.org
Thu Aug 9 08:32:44 PDT 2012


This is supported with a new command-line argument:

	qapitrace --remote-target <HOST> <trace-file>

In order for this to work, the following must be available in the
system configuration:

1. It must be possible for the current user to initiate an ssh session
   with X forwarding available with the following command:

        ssh -Y <HOST>

2. The target host must have a function glretrace binary available

3. The target host must have access to <trace-file> at the same path
   in the filesystem as the <trace-file> path on the host system being
   passed to the qapitrace command line.
---

 This is really a quick hack mostly as an RFC. It does seem to work in
 one simple test. I'd be interested to hear thoughts from people on
 what more realistic support for a similar feature might look like.

 gui/main.cpp       |   19 ++++++++++++++++++-
 gui/mainwindow.cpp |    5 +++++
 gui/mainwindow.h   |    2 ++
 gui/retracer.cpp   |   22 +++++++++++++++++++++-
 gui/retracer.h     |    4 ++++
 5 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/gui/main.cpp b/gui/main.cpp
index 18e07f1..562730c 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -8,6 +8,8 @@
 #include <QVariant>
 #include <QImage>
 
+#include <stdio.h>
+
 Q_DECLARE_METATYPE(QList<ApiTraceFrame*>);
 Q_DECLARE_METATYPE(QVector<ApiTraceCall*>);
 Q_DECLARE_METATYPE(Qt::CaseSensitivity);
@@ -17,7 +19,10 @@ Q_DECLARE_METATYPE(QList<QImage>);
 
 static void usage(void)
 {
-    qWarning("usage: qapitrace [TRACE] [CALLNO]\n");
+    qWarning("usage: qapitrace [options] [TRACE] [CALLNO]\n"
+             "Valid options include:\n"
+             "    -h, --help            Print this help message\n"
+             "    --remote-target HOST  Replay trace on remote target HOST\n");
 }
 
 int main(int argc, char **argv)
@@ -32,6 +37,7 @@ int main(int argc, char **argv)
     qRegisterMetaType<ApiTrace::SearchRequest>();
     qRegisterMetaType<QList<QImage> >();
     QStringList args = app.arguments();
+    QString remoteTarget;
 
     int i = 1;
     while (i < args.count()) {
@@ -42,6 +48,13 @@ int main(int argc, char **argv)
         ++i;
         if (arg == QLatin1String("--")) {
             break;
+        } else if (arg == QLatin1String("--remote-target")) {
+            if (i == args.count()) {
+                qWarning("Option --remote-target requires an argument.\n");
+                exit(1);
+            }
+            remoteTarget = args[i];
+            ++i;
         } else if (arg == QLatin1String("-h") ||
                    arg == QLatin1String("--help")) {
             usage();
@@ -65,5 +78,9 @@ int main(int argc, char **argv)
         window.loadTrace(fileName, callNum);
     }
 
+    if (remoteTarget.length()) {
+        window.setRemoteTarget(remoteTarget);
+    }
+
     app.exec();
 }
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 50f7d91..ace1073 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -96,6 +96,11 @@ void MainWindow::loadTrace(const QString &fileName, int callNum)
     newTraceFile(fileName);
 }
 
+void MainWindow::setRemoteTarget(const QString &host)
+{
+    m_retracer->setRemoteTarget(host);
+}
+
 void MainWindow::callItemSelected(const QModelIndex &index)
 {
     ApiTraceEvent *event =
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index 1346b86..2ede8ee 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -42,6 +42,8 @@ public:
 public slots:
     void loadTrace(const QString &fileName, int callNum = -1);
 
+    void setRemoteTarget(const QString &host);
+
 private slots:
     void callItemSelected(const QModelIndex &index);
     void callItemActivated(const QModelIndex &index);
diff --git a/gui/retracer.cpp b/gui/retracer.cpp
index bbe638c..2cb7fd7 100644
--- a/gui/retracer.cpp
+++ b/gui/retracer.cpp
@@ -157,6 +157,16 @@ void Retracer::setFileName(const QString &name)
     m_fileName = name;
 }
 
+QString Retracer::remoteTarget() const
+{
+    return m_remoteTarget;
+}
+
+void Retracer::setRemoteTarget(const QString &host)
+{
+    m_remoteTarget = host;
+}
+
 void Retracer::setAPI(trace::API api)
 {
     m_api = api;
@@ -274,6 +284,17 @@ void Retracer::run()
     arguments << m_fileName;
 
     /*
+     * Support remote execution on a separate target.
+     */
+
+    if (m_remoteTarget.length() != 0) {
+        arguments.prepend(prog);
+        arguments.prepend(m_remoteTarget);
+        arguments.prepend(QLatin1String("-Y"));
+        prog = QLatin1String("ssh");
+    }
+
+    /*
      * Start the process.
      */
 
@@ -424,7 +445,6 @@ void Retracer::run()
     if (m_captureState) {
         ApiTraceState *state = new ApiTraceState(parsedJson);
         emit foundState(state);
-        msg = QLatin1String("State fetched.");
     }
 
     if (m_captureThumbnails && !thumbnails.isEmpty()) {
diff --git a/gui/retracer.h b/gui/retracer.h
index d6da7ac..c47213f 100644
--- a/gui/retracer.h
+++ b/gui/retracer.h
@@ -18,6 +18,9 @@ public:
     QString fileName() const;
     void setFileName(const QString &name);
 
+    QString remoteTarget() const;
+    void setRemoteTarget(const QString &host);
+
     void setAPI(trace::API api);
 
     bool isBenchmarking() const;
@@ -47,6 +50,7 @@ protected:
 
 private:
     QString m_fileName;
+    QString m_remoteTarget;
     trace::API m_api;
     bool m_benchmarking;
     bool m_doubleBuffered;
-- 
1.7.10



More information about the apitrace mailing list