aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/debugger')
-rw-r--r--src/qml/debugger/qdebugmessageservice.cpp2
-rw-r--r--src/qml/debugger/qqmldebugserverconnection_p.h6
-rw-r--r--src/qml/debugger/qqmlinspectorinterface_p.h5
-rw-r--r--src/qml/debugger/qqmlprofilerservice.cpp62
-rw-r--r--src/qml/debugger/qqmlprofilerservice_p.h158
-rw-r--r--src/qml/debugger/qv8profilerservice.cpp14
-rw-r--r--src/qml/debugger/qv8profilerservice_p.h1
7 files changed, 174 insertions, 74 deletions
diff --git a/src/qml/debugger/qdebugmessageservice.cpp b/src/qml/debugger/qdebugmessageservice.cpp
index 2c52809e56..dcaa514cd7 100644
--- a/src/qml/debugger/qdebugmessageservice.cpp
+++ b/src/qml/debugger/qdebugmessageservice.cpp
@@ -42,6 +42,8 @@
#include "qdebugmessageservice_p.h"
#include "qqmldebugservice_p_p.h"
+#include <QDataStream>
+
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QDebugMessageService, qmlDebugMessageService)
diff --git a/src/qml/debugger/qqmldebugserverconnection_p.h b/src/qml/debugger/qqmldebugserverconnection_p.h
index c9092f1911..ab9e7bd73f 100644
--- a/src/qml/debugger/qqmldebugserverconnection_p.h
+++ b/src/qml/debugger/qqmldebugserverconnection_p.h
@@ -43,7 +43,7 @@
#define QQMLDEBUGSERVERCONNECTION_H
#include <QtQml/qtqmlglobal.h>
-#include <QtCore/QtPlugin>
+#include <private/qqmlglobal_p.h>
//
// W A R N I N G
@@ -76,7 +76,9 @@ public:
virtual bool waitForMessage() = 0;
};
-Q_DECLARE_INTERFACE(QQmlDebugServerConnection, "com.trolltech.Qt.QQmlDebugServerConnection/1.0")
+#define QQmlDebugServerConnection_iid "org.qt-project.Qt.QQmlDebugServerConnection"
+
+Q_DECLARE_INTERFACE(QQmlDebugServerConnection, QQmlDebugServerConnection_iid)
QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmlinspectorinterface_p.h b/src/qml/debugger/qqmlinspectorinterface_p.h
index 7f52dffa2e..5b015d36df 100644
--- a/src/qml/debugger/qqmlinspectorinterface_p.h
+++ b/src/qml/debugger/qqmlinspectorinterface_p.h
@@ -54,6 +54,7 @@
//
#include <QtQml/qtqmlglobal.h>
+#include <private/qqmlglobal_p.h>
QT_BEGIN_HEADER
@@ -74,7 +75,9 @@ public:
virtual void clientMessage(const QByteArray &message) = 0;
};
-Q_DECLARE_INTERFACE(QQmlInspectorInterface, "com.trolltech.Qt.QQmlInspectorInterface/1.0")
+#define QQmlInspectorInterface_iid "org.qt-project.Qt.QQmlInspectorInterface"
+
+Q_DECLARE_INTERFACE(QQmlInspectorInterface, QQmlInspectorInterface_iid)
QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmlprofilerservice.cpp b/src/qml/debugger/qqmlprofilerservice.cpp
index d6a0307836..2731d2046b 100644
--- a/src/qml/debugger/qqmlprofilerservice.cpp
+++ b/src/qml/debugger/qqmlprofilerservice.cpp
@@ -52,23 +52,10 @@
QT_BEGIN_NAMESPACE
+// instance will be set, unset in constructor. Allows static methods to be inlined.
+QQmlProfilerService *QQmlProfilerService::instance = 0;
Q_GLOBAL_STATIC(QQmlProfilerService, profilerInstance)
-QQmlBindingProfiler::QQmlBindingProfiler(const QString &url, int line, int column)
-{
- QQmlProfilerService::startRange(QQmlProfilerService::Binding);
- QQmlProfilerService::rangeLocation(QQmlProfilerService::Binding, url, line, column);
-}
-
-QQmlBindingProfiler::~QQmlBindingProfiler()
-{
- QQmlProfilerService::endRange(QQmlProfilerService::Binding);
-}
-
-void QQmlBindingProfiler::addDetail(const QString &details)
-{
- QQmlProfilerService::rangeData(QQmlProfilerService::Binding, details);
-}
// convert to a QByteArray that can be sent to the debug client
// use of QDataStream can skew results
@@ -106,12 +93,13 @@ QQmlProfilerService::QQmlProfilerService()
QQmlProfilerService::~QQmlProfilerService()
{
+ instance = 0;
}
void QQmlProfilerService::initialize()
{
// just make sure that the service is properly registered
- profilerInstance();
+ instance = profilerInstance();
}
bool QQmlProfilerService::startProfiling()
@@ -134,36 +122,6 @@ void QQmlProfilerService::addEvent(EventType t)
profilerInstance()->addEventImpl(t);
}
-void QQmlProfilerService::startRange(RangeType t)
-{
- profilerInstance()->startRangeImpl(t);
-}
-
-void QQmlProfilerService::rangeData(RangeType t, const QString &data)
-{
- profilerInstance()->rangeDataImpl(t, data);
-}
-
-void QQmlProfilerService::rangeData(RangeType t, const QUrl &data)
-{
- profilerInstance()->rangeDataImpl(t, data);
-}
-
-void QQmlProfilerService::rangeLocation(RangeType t, const QString &fileName, int line, int column)
-{
- profilerInstance()->rangeLocationImpl(t, fileName, line, column);
-}
-
-void QQmlProfilerService::rangeLocation(RangeType t, const QUrl &fileName, int line, int column)
-{
- profilerInstance()->rangeLocationImpl(t, fileName, line, column);
-}
-
-void QQmlProfilerService::endRange(RangeType t)
-{
- profilerInstance()->endRangeImpl(t);
-}
-
void QQmlProfilerService::animationFrame(qint64 delta)
{
profilerInstance()->animationFrameImpl(delta);
@@ -214,7 +172,7 @@ void QQmlProfilerService::addEventImpl(EventType event)
processMessage(ed);
}
-void QQmlProfilerService::startRangeImpl(RangeType range)
+void QQmlProfilerService::startRange(RangeType range)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -223,7 +181,7 @@ void QQmlProfilerService::startRangeImpl(RangeType range)
processMessage(rd);
}
-void QQmlProfilerService::rangeDataImpl(RangeType range, const QString &rData)
+void QQmlProfilerService::rangeData(RangeType range, const QString &rData)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -232,7 +190,7 @@ void QQmlProfilerService::rangeDataImpl(RangeType range, const QString &rData)
processMessage(rd);
}
-void QQmlProfilerService::rangeDataImpl(RangeType range, const QUrl &rData)
+void QQmlProfilerService::rangeData(RangeType range, const QUrl &rData)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -241,7 +199,7 @@ void QQmlProfilerService::rangeDataImpl(RangeType range, const QUrl &rData)
processMessage(rd);
}
-void QQmlProfilerService::rangeLocationImpl(RangeType range, const QString &fileName, int line, int column)
+void QQmlProfilerService::rangeLocation(RangeType range, const QString &fileName, int line, int column)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -250,7 +208,7 @@ void QQmlProfilerService::rangeLocationImpl(RangeType range, const QString &file
processMessage(rd);
}
-void QQmlProfilerService::rangeLocationImpl(RangeType range, const QUrl &fileName, int line, int column)
+void QQmlProfilerService::rangeLocation(RangeType range, const QUrl &fileName, int line, int column)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -259,7 +217,7 @@ void QQmlProfilerService::rangeLocationImpl(RangeType range, const QUrl &fileNam
processMessage(rd);
}
-void QQmlProfilerService::endRangeImpl(RangeType range)
+void QQmlProfilerService::endRange(RangeType range)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/qml/debugger/qqmlprofilerservice_p.h
index a74ce10c74..7a708456ba 100644
--- a/src/qml/debugger/qqmlprofilerservice_p.h
+++ b/src/qml/debugger/qqmlprofilerservice_p.h
@@ -54,9 +54,11 @@
//
#include <private/qqmldebugservice_p.h>
+#include <QtQml/qtqmlglobal.h>
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qmutex.h>
#include <QtCore/qvector.h>
+#include <QtCore/qstringbuilder.h>
QT_BEGIN_HEADER
@@ -83,13 +85,6 @@ Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_MOVABLE_TYPE);
class QUrl;
class QQmlEngine;
-// RAII
-class Q_AUTOTEST_EXPORT QQmlBindingProfiler {
-public:
- QQmlBindingProfiler(const QString &url, int line, int column);
- ~QQmlBindingProfiler();
- void addDetail(const QString &details);
-};
class Q_QML_EXPORT QQmlProfilerService : public QQmlDebugService
{
@@ -132,12 +127,6 @@ public:
static bool stopProfiling();
static void sendStartedProfilingMessage();
static void addEvent(EventType);
- static void startRange(RangeType);
- static void rangeData(RangeType, const QString &);
- static void rangeData(RangeType, const QUrl &);
- static void rangeLocation(RangeType, const QString &, int, int);
- static void rangeLocation(RangeType, const QUrl &, int, int);
- static void endRange(RangeType);
static void animationFrame(qint64);
static void sendProfilingData();
@@ -154,14 +143,16 @@ private:
bool stopProfilingImpl();
void sendStartedProfilingMessageImpl();
void addEventImpl(EventType);
- void startRangeImpl(RangeType);
- void rangeDataImpl(RangeType, const QString &);
- void rangeDataImpl(RangeType, const QUrl &);
- void rangeLocationImpl(RangeType, const QString &, int, int);
- void rangeLocationImpl(RangeType, const QUrl &, int, int);
- void endRangeImpl(RangeType);
void animationFrameImpl(qint64);
+ void startRange(RangeType);
+ void rangeData(RangeType, const QString &);
+ void rangeData(RangeType, const QUrl &);
+ void rangeLocation(RangeType, const QString &, int, int);
+ void rangeLocation(RangeType, const QUrl &, int, int);
+ void endRange(RangeType);
+
+
bool profilingEnabled();
void setProfilingEnabled(bool enable);
void sendMessages();
@@ -173,6 +164,135 @@ private:
bool m_messageReceived;
QVector<QQmlProfilerData> m_data;
QMutex m_mutex;
+
+ static QQmlProfilerService *instance;
+
+ friend struct QQmlBindingProfiler;
+ friend struct QQmlHandlingSignalProfiler;
+ friend struct QQmlObjectCreatingProfiler;
+ friend struct QQmlCompilingProfiler;
+};
+
+//
+// RAII helper structs
+//
+
+struct QQmlBindingProfiler {
+ QQmlBindingProfiler(const QString &url, int line, int column)
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ? instance->profilingEnabled() : false;
+ if (enabled) {
+ instance->startRange(QQmlProfilerService::Binding);
+ instance->rangeLocation(QQmlProfilerService::Binding, url, line, column);
+ }
+ }
+
+ ~QQmlBindingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Binding);
+ }
+
+ void addDetail(const QString &details)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(QQmlProfilerService::Binding,
+ details);
+ }
+\
+ bool enabled;
+};
+
+struct QQmlHandlingSignalProfiler {
+ QQmlHandlingSignalProfiler()
+ {
+ enabled = QQmlProfilerService::instance
+ ? QQmlProfilerService::instance->profilingEnabled() : false;
+ if (enabled) {
+ QQmlProfilerService::instance->startRange(
+ QQmlProfilerService::HandlingSignal);
+ }
+ }
+
+ void setSignalInfo(const QString &name, const QString &expression)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(
+ QQmlProfilerService::HandlingSignal,
+ name % QLatin1String(": ") % expression);
+ }
+
+ void setLocation(const QString &file, int line, int column)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeLocation(
+ QQmlProfilerService::HandlingSignal, file, line, column);
+ }
+
+ ~QQmlHandlingSignalProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(
+ QQmlProfilerService::HandlingSignal);
+ }
+
+ bool enabled;
+};
+
+struct QQmlObjectCreatingProfiler {
+ QQmlObjectCreatingProfiler()
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ?
+ instance->profilingEnabled() : false;
+ if (enabled)
+ instance->startRange(QQmlProfilerService::Creating);
+ }
+
+ void setTypeName(const QString &typeName)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(
+ QQmlProfilerService::Creating, typeName);
+ }
+
+ void setLocation(const QUrl &url, int line, int column)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeLocation(
+ QQmlProfilerService::Creating, url, line, column);
+ }
+
+ ~QQmlObjectCreatingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating);
+ }
+
+ bool enabled;
+};
+
+struct QQmlCompilingProfiler {
+ QQmlCompilingProfiler(const QString &name)
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ?
+ instance->profilingEnabled() : false;
+ if (enabled) {
+ instance->startRange(QQmlProfilerService::Compiling);
+ instance->rangeLocation(QQmlProfilerService::Compiling, name, 1, 1);
+ instance->rangeData(QQmlProfilerService::Compiling, name);
+ }
+ }
+
+ ~QQmlCompilingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Compiling);
+ }
+
+ bool enabled;
};
QT_END_NAMESPACE
diff --git a/src/qml/debugger/qv8profilerservice.cpp b/src/qml/debugger/qv8profilerservice.cpp
index eba8b0feef..6473a2f4fb 100644
--- a/src/qml/debugger/qv8profilerservice.cpp
+++ b/src/qml/debugger/qv8profilerservice.cpp
@@ -187,6 +187,13 @@ void QV8ProfilerService::startProfiling(const QString &title)
v8::CpuProfiler::StartProfiling(v8title);
d->m_ongoing.append(title);
+
+ // indicate profiling started
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (int)QV8ProfilerService::V8Started;
+
+ sendMessage(data);
}
void QV8ProfilerService::stopProfiling(const QString &title)
@@ -205,6 +212,13 @@ void QV8ProfilerService::stopProfiling(const QString &title)
// can happen at start
const v8::CpuProfileNode *rootNode = cpuProfile->GetTopDownRoot();
d->printProfileTree(rootNode);
+ } else {
+ // indicate completion, even without data
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (int)QV8ProfilerService::V8Complete;
+
+ sendMessage(data);
}
}
diff --git a/src/qml/debugger/qv8profilerservice_p.h b/src/qml/debugger/qv8profilerservice_p.h
index d408d9ed0e..b706d1762a 100644
--- a/src/qml/debugger/qv8profilerservice_p.h
+++ b/src/qml/debugger/qv8profilerservice_p.h
@@ -85,6 +85,7 @@ public:
V8Complete,
V8SnapshotChunk,
V8SnapshotComplete,
+ V8Started,
V8MaximumMessage
};