diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-11-13 11:12:45 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-11-17 18:42:56 +0000 |
commit | fee44872dce081b3480f3cb3bb74d12940a92068 (patch) | |
tree | 354964ced53b31fd5485ce8979e0d7b13608f641 /src/plugins | |
parent | ec88ecf42bae7bfd486bb171a3325b7b2dabcca9 (diff) |
Extend QDebugMessageService
Add category and timestamp, and allow synchronizing the timestamps with
QQmlProfilerService.
Change-Id: I8dc67e43e1087e231167fc4cfdfb5f659e00c5b2
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/plugins')
3 files changed, 19 insertions, 4 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp index 6300b2b9c6..6880417f1d 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp @@ -49,6 +49,7 @@ QDebugMessageServiceImpl::QDebugMessageServiceImpl(QObject *parent) : { // don't execute stateChanged() in parallel QMutexLocker lock(&initMutex); + timer.start(); if (state() == Enabled) { oldMsgHandler = qInstallMessageHandler(DebugMessageHandler); prevState = Enabled; @@ -64,8 +65,8 @@ void QDebugMessageServiceImpl::sendDebugMessage(QtMsgType type, //only if a client is connected to it. QQmlDebugPacket ws; ws << QByteArray("MESSAGE") << type << buf.toUtf8(); - ws << QString::fromLatin1(ctxt.file).toUtf8(); - ws << ctxt.line << QString::fromLatin1(ctxt.function).toUtf8(); + ws << QByteArray(ctxt.file) << ctxt.line << QByteArray(ctxt.function); + ws << QByteArray(ctxt.category) << timer.nsecsElapsed(); emit messageToClient(name(), ws.data()); if (oldMsgHandler) @@ -89,4 +90,10 @@ void QDebugMessageServiceImpl::stateChanged(State state) prevState = state; } +void QDebugMessageServiceImpl::synchronizeTime(const QElapsedTimer &otherTimer) +{ + QMutexLocker lock(&initMutex); + timer = otherTimer; +} + QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.h b/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.h index 04f5966dd7..a5ff1fc3d7 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.h @@ -49,6 +49,7 @@ #include <QtCore/qlogging.h> #include <QtCore/qmutex.h> +#include <QtCore/qelapsedtimer.h> QT_BEGIN_NAMESPACE @@ -60,8 +61,8 @@ class QDebugMessageServiceImpl : public QDebugMessageService public: QDebugMessageServiceImpl(QObject *parent = 0); - void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt, - const QString &buf); + void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt, const QString &buf); + void synchronizeTime(const QElapsedTimer &otherTimer); protected: void stateChanged(State); @@ -72,6 +73,7 @@ private: QtMessageHandler oldMsgHandler; QQmlDebugService::State prevState; QMutex initMutex; + QElapsedTimer timer; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp index e05717f8eb..462bd5e394 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp @@ -215,6 +215,12 @@ void QQmlProfilerServiceImpl::startProfiling(QJSEngine *engine, quint64 features { QMutexLocker lock(&m_configMutex); + if (features & static_cast<quint64>(1) << ProfileDebugMessages) { + if (QDebugMessageService *messageService = + QQmlDebugConnector::instance()->service<QDebugMessageService>()) + messageService->synchronizeTime(m_timer); + } + QQmlDebugPacket d; d << m_timer.nsecsElapsed() << (int)Event << (int)StartTrace; |