From eb83377f5a5fc54eddc06c1d669d67d604f720a2 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Mon, 6 Jul 2009 11:37:21 +0200
Subject: [PATCH] debugger: enhance time logging for individual commands

---
 src/plugins/debugger/gdb/gdbengine.cpp  | 6 ++++++
 src/plugins/debugger/gdb/gdbengine.h    | 2 ++
 tests/manual/gdbdebugger/simple/app.cpp | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 3fa987103ff..3b5431012aa 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -738,6 +738,7 @@ void GdbEngine::postCommand(const QString &command, GdbCommandFlags flags,
 void GdbEngine::flushCommand(GdbCommand &cmd)
 {
     ++currentToken();
+    cmd.postTime = QTime::currentTime();
     m_cookieForToken[currentToken()] = cmd;
     cmd.command = QString::number(currentToken()) + cmd.command;
     if (cmd.flags & EmbedToken)
@@ -761,6 +762,11 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record)
         return;
 
     GdbCommand cmd = m_cookieForToken.take(token);
+    if (theDebuggerBoolSetting(LogTimeStamps)) {
+        emit gdbOutputAvailable(LogTime, _("Response time: %1: %2 s")
+            .arg(cmd.command)
+            .arg(cmd.postTime.msecsTo(QTime::currentTime()) / 1000.));
+    }
 
     if (record.token < m_oldestAcceptableToken && (cmd.flags & Discardable)) {
         //qDebug() << "### SKIPPING OLD RESULT" << record.toString();
diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h
index 84f8ab32f82..41137705879 100644
--- a/src/plugins/debugger/gdb/gdbengine.h
+++ b/src/plugins/debugger/gdb/gdbengine.h
@@ -44,6 +44,7 @@
 #include <QtCore/QProcess>
 #include <QtCore/QPoint>
 #include <QtCore/QTextCodec>
+#include <QtCore/QTime>
 #include <QtCore/QVariant>
 
 QT_BEGIN_NAMESPACE
@@ -164,6 +165,7 @@ private:
         const char *callbackName;
         QString command;
         QVariant cookie;
+        QTime postTime;
     };
 
     // type and cookie are sender-internal data, opaque for the "event
diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp
index 9330df449a3..7686619734a 100644
--- a/tests/manual/gdbdebugger/simple/app.cpp
+++ b/tests/manual/gdbdebugger/simple/app.cpp
@@ -1275,4 +1275,4 @@ struct QMetaTypeId< QMap<uint, QStringList> >
         return metatype_id;                                    \
     }                                                           \
 };
-QT_END_NAMESPACE
\ No newline at end of file
+QT_END_NAMESPACE
-- 
GitLab