[PATCH 5/6] Create a call set for thumbnails requested

Dan McCabe zen3d.linux at gmail.com
Fri Jun 1 13:40:06 PDT 2012


Retracer now knows what thumbnails are needed. This information needs
to be communicated to the glretrace command.

Construct a string that contains the call numbers for all missing thumbnails.

The constructed string is then passed to glretrace with the "-S" argument.

TODO: we want to be able to detect contiguous sequences of calls and emit
them as a range. However, I wasn't able to get this working correctly and
will defer this to a future patch.
---
 gui/retracer.cpp |   25 +++++++++++++++++++++++++
 gui/retracer.h   |    2 ++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/gui/retracer.cpp b/gui/retracer.cpp
index aecd2f1..996f8f5 100644
--- a/gui/retracer.cpp
+++ b/gui/retracer.cpp
@@ -224,6 +224,27 @@ void Retracer::resetThumbnailsToCapture()
     m_thumbnailsToCapture.clear();
 }
 
+QString Retracer::thumbnailCallSet()
+{
+    QString callSet;
+
+    bool isFirst = true;
+
+    foreach (qlonglong callIndex, m_thumbnailsToCapture) {
+        // TODO: detect contiguous ranges
+        if (!isFirst) {
+            callSet.append(QLatin1String(","));
+        } else {
+            isFirst = false;
+        }
+
+        //emit "callIndex"
+        callSet.append(QString::number(callIndex));
+    }
+
+    //qDebug() << QLatin1String("debug: call set to capture: ") << callSet;
+    return callSet;
+}
 
 /**
  * Starting point for the retracing thread.
@@ -277,6 +298,10 @@ void Retracer::run()
         arguments << QLatin1String("-D");
         arguments << QString::number(m_captureCall);
     } else if (m_captureThumbnails) {
+        if (!m_thumbnailsToCapture.isEmpty()) {
+            arguments << QLatin1String("-S");
+            arguments << thumbnailCallSet();
+        }
         arguments << QLatin1String("-s"); // emit snapshots
         arguments << QLatin1String("-"); // emit to stdout
     } else if (m_benchmarking) {
diff --git a/gui/retracer.h b/gui/retracer.h
index ff4efaf..1569818 100644
--- a/gui/retracer.h
+++ b/gui/retracer.h
@@ -39,6 +39,8 @@ public:
     void addThumbnailToCapture(qlonglong num);
     void resetThumbnailsToCapture();
 
+    QString thumbnailCallSet();
+
 signals:
     void finished(const QString &output);
     void foundState(ApiTraceState *state);
-- 
1.7.9.1



More information about the apitrace mailing list