aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-20 18:09:42 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-08-04 13:35:21 +0000
commitf8e5cfcfc26499eef30fc222e24957a753651cbc (patch)
tree23943933c7ad81d1bb535978bba39f94a1606614
parent275ddd68af1881c5712848a4be9892f84b62b321 (diff)
Move profiler and engine control services into a plugin
Change-Id: I12627a07ceedea4aceafa6f0e630c0cab69d156d Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qmldbg_profiler.pro27
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp (renamed from src/qml/debugger/qqmlenginecontrolservice.cpp)14
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h (renamed from src/qml/debugger/qqmlenginecontrolservice_p.h)8
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp123
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h69
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp (renamed from src/qml/debugger/qqmlprofilerservice.cpp)22
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h (renamed from src/qml/debugger/qqmlprofilerservice_p.h)15
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.json3
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.cpp51
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h62
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp (renamed from src/qml/debugger/qv4profileradapter.cpp)5
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h (renamed from src/qml/debugger/qv4profileradapter_p.h)4
-rw-r--r--src/plugins/qmltooling/qmltooling.pro1
-rw-r--r--src/qml/debugger/debugger.pri7
-rw-r--r--src/qml/debugger/qqmldebugconnector.cpp5
-rw-r--r--src/qml/debugger/qqmlprofiler.cpp82
-rw-r--r--src/qml/debugger/qqmlprofiler_p.h21
17 files changed, 366 insertions, 153 deletions
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qmldbg_profiler.pro b/src/plugins/qmltooling/qmldbg_profiler/qmldbg_profiler.pro
new file mode 100644
index 0000000000..dc5ee44711
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_profiler/qmldbg_profiler.pro
@@ -0,0 +1,27 @@
+TARGET = qmldbg_profiler
+QT = qml-private core-private
+
+PLUGIN_TYPE = qmltooling
+PLUGIN_CLASS_NAME = QQmlProfilerServiceFactory
+load(qt_plugin)
+
+SOURCES += \
+ $$PWD/qqmlenginecontrolservice.cpp \
+ $$PWD/qqmlprofileradapter.cpp \
+ $$PWD/qqmlprofilerservice.cpp \
+ $$PWD/qqmlprofilerservicefactory.cpp \
+ $$PWD/qv4profileradapter.cpp
+
+HEADERS += \
+ $$PWD/qqmlenginecontrolservice.h \
+ $$PWD/qqmlprofileradapter.h \
+ $$PWD/qqmlprofilerservice.h \
+ $$PWD/qqmlprofilerservicefactory.h \
+ $$PWD/qv4profileradapter.h
+
+INCLUDEPATH += $$PWD \
+ $$PWD/../shared
+
+OTHER_FILES += \
+ $$PWD/qqmlprofilerservice.json
+
diff --git a/src/qml/debugger/qqmlenginecontrolservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
index eaf948426d..4f131ac481 100644
--- a/src/qml/debugger/qqmlenginecontrolservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
@@ -31,24 +31,18 @@
**
****************************************************************************/
+#include "qqmlenginecontrolservice.h"
#include <QQmlEngine>
-#include "qqmldebug.h"
-#include "qqmlenginecontrolservice_p.h"
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QQmlEngineControlService, qmlEngineControlService)
+const QString QQmlEngineControlService::s_key = QStringLiteral("EngineControl");
-QQmlEngineControlService::QQmlEngineControlService() :
- QQmlDebugService(QStringLiteral("EngineControl"), 1)
+QQmlEngineControlService::QQmlEngineControlService(QObject *parent) :
+ QQmlDebugService(s_key, 1, parent)
{
}
-QQmlEngineControlService *QQmlEngineControlService::instance()
-{
- return qmlEngineControlService();
-}
-
void QQmlEngineControlService::messageReceived(const QByteArray &message)
{
QMutexLocker lock(&dataMutex);
diff --git a/src/qml/debugger/qqmlenginecontrolservice_p.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h
index 2171937efe..e2a93e562a 100644
--- a/src/qml/debugger/qqmlenginecontrolservice_p.h
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h
@@ -35,7 +35,7 @@
#define QQMLENGINECONTROLSERVICE_H
#include <QMutex>
-#include "qqmldebugservice_p.h"
+#include <private/qqmldebugservice_p.h>
//
// W A R N I N G
@@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE
class QQmlEngineControlService : public QQmlDebugService
{
public:
+ static const QString s_key;
+
enum MessageType {
EngineAboutToBeAdded,
EngineAdded,
@@ -65,9 +67,7 @@ public:
StopWaitingEngine
};
- QQmlEngineControlService();
-
- static QQmlEngineControlService *instance();
+ QQmlEngineControlService(QObject *parent = 0);
protected:
QMutex dataMutex;
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
new file mode 100644
index 0000000000..349c181d13
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlprofileradapter.h"
+#include <private/qqmldebugserviceinterfaces_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QQmlProfilerAdapter::QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine) :
+ QQmlAbstractProfilerAdapter(service), next(0)
+{
+ engine->enableProfiler();
+ connect(this, SIGNAL(profilingEnabled(quint64)), engine->profiler, SLOT(startProfiling(quint64)));
+ connect(this, SIGNAL(profilingEnabledWhileWaiting(quint64)),
+ engine->profiler, SLOT(startProfiling(quint64)), Qt::DirectConnection);
+ connect(this, SIGNAL(profilingDisabled()), engine->profiler, SLOT(stopProfiling()));
+ connect(this, SIGNAL(profilingDisabledWhileWaiting()),
+ engine->profiler, SLOT(stopProfiling()), Qt::DirectConnection);
+ connect(this, SIGNAL(dataRequested()), engine->profiler, SLOT(reportData()));
+ connect(this, SIGNAL(referenceTimeKnown(QElapsedTimer)),
+ engine->profiler, SLOT(setTimer(QElapsedTimer)));
+ connect(engine->profiler, SIGNAL(dataReady(QVector<QQmlProfilerData>)),
+ this, SLOT(receiveData(QVector<QQmlProfilerData>)));
+}
+
+// convert to QByteArrays that can be sent to the debug client
+// use of QDataStream can skew results
+// (see tst_qqmldebugtrace::trace() benchmark)
+static void qQmlProfilerDataToByteArrays(const QQmlProfilerData *d, QList<QByteArray> &messages)
+{
+ QByteArray data;
+ Q_ASSERT_X(((d->messageType | d->detailType) & (1 << 31)) == 0, Q_FUNC_INFO,
+ "You can use at most 31 message types and 31 detail types.");
+ for (uint decodedMessageType = 0; (d->messageType >> decodedMessageType) != 0;
+ ++decodedMessageType) {
+ if ((d->messageType & (1 << decodedMessageType)) == 0)
+ continue;
+
+ for (uint decodedDetailType = 0; (d->detailType >> decodedDetailType) != 0;
+ ++decodedDetailType) {
+ if ((d->detailType & (1 << decodedDetailType)) == 0)
+ continue;
+
+ //### using QDataStream is relatively expensive
+ QQmlDebugStream ds(&data, QIODevice::WriteOnly);
+ ds << d->time << decodedMessageType << decodedDetailType;
+
+ switch (decodedMessageType) {
+ case QQmlProfilerDefinitions::RangeStart:
+ if (decodedDetailType == (int)QQmlProfilerDefinitions::Binding)
+ ds << QQmlProfilerDefinitions::QmlBinding;
+ break;
+ case QQmlProfilerDefinitions::RangeData:
+ ds << d->detailString;
+ break;
+ case QQmlProfilerDefinitions::RangeLocation:
+ ds << (d->detailUrl.isEmpty() ? d->detailString : d->detailUrl.toString()) << d->x
+ << d->y;
+ break;
+ case QQmlProfilerDefinitions::RangeEnd: break;
+ default:
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message type.");
+ break;
+ }
+ messages << data;
+ data.clear();
+ }
+ }
+}
+
+qint64 QQmlProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
+{
+ while (next != data.length()) {
+ if (data[next].time > until)
+ return data[next].time;
+ qQmlProfilerDataToByteArrays(&(data[next++]), messages);
+ }
+
+ next = 0;
+ data.clear();
+ return -1;
+}
+
+void QQmlProfilerAdapter::receiveData(const QVector<QQmlProfilerData> &new_data)
+{
+ if (data.isEmpty())
+ data = new_data;
+ else
+ data.append(new_data);
+ service->dataReady(this);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h
new file mode 100644
index 0000000000..eceb58ce3a
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef QQMLPROFILERADAPTER_H
+#define QQMLPROFILERADAPTER_H
+
+#include <private/qqmlabstractprofileradapter_p.h>
+#include <private/qqmlprofiler_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlProfilerAdapter : public QQmlAbstractProfilerAdapter {
+ Q_OBJECT
+public:
+ QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine);
+ qint64 sendMessages(qint64 until, QList<QByteArray> &messages);
+
+public slots:
+ void receiveData(const QVector<QQmlProfilerData> &new_data);
+
+private:
+ QVector<QQmlProfilerData> data;
+ int next;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLPROFILERADAPTER_H
diff --git a/src/qml/debugger/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
index a858dcf915..65b99ef7ca 100644
--- a/src/qml/debugger/qqmlprofilerservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
@@ -31,10 +31,10 @@
**
****************************************************************************/
-#include "qqmlprofilerservice_p.h"
-#include "qv4profileradapter_p.h"
-#include "qqmlprofiler_p.h"
-#include "qqmldebugconnector_p.h"
+#include "qqmlprofilerservice.h"
+#include "qv4profileradapter.h"
+#include "qqmlprofileradapter.h"
+#include "qqmlprofilerservicefactory.h"
#include <private/qqmlengine_p.h>
#include <QtCore/qdatastream.h>
@@ -45,11 +45,9 @@
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QQmlProfilerServiceImpl, profilerInstance)
-
-QQmlProfilerServiceImpl::QQmlProfilerServiceImpl()
- : QQmlConfigurableDebugService<QQmlProfilerService>(1),
- m_waitingForStop(false)
+QQmlProfilerServiceImpl::QQmlProfilerServiceImpl(QObject *parent) :
+ QQmlConfigurableDebugService<QQmlProfilerService>(1, parent),
+ m_waitingForStop(false)
{
m_timer.start();
}
@@ -94,12 +92,6 @@ void QQmlProfilerServiceImpl::dataReady(QQmlAbstractProfilerAdapter *profiler)
}
}
-QQmlProfilerServiceImpl *QQmlProfilerServiceImpl::instance()
-{
- // just make sure that the service is properly registered
- return profilerInstance();
-}
-
void QQmlProfilerServiceImpl::engineAboutToBeAdded(QQmlEngine *engine)
{
Q_ASSERT_X(QThread::currentThread() == engine->thread(), Q_FUNC_INFO,
diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h
index ea73216010..da96f58ce6 100644
--- a/src/qml/debugger/qqmlprofilerservice_p.h
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h
@@ -45,11 +45,10 @@
// We mean it.
//
-#include "qqmlconfigurabledebugservice_p.h"
-#include "qqmldebugserviceinterfaces_p.h"
-#include "qqmlprofilerdefinitions_p.h"
-#include "qqmlabstractprofileradapter_p.h"
-
+#include <private/qqmlconfigurabledebugservice_p.h>
+#include <private/qqmldebugserviceinterfaces_p.h>
+#include <private/qqmlprofilerdefinitions_p.h>
+#include <private/qqmlabstractprofileradapter_p.h>
#include <private/qqmlboundsignal_p.h>
#include <QtCore/qelapsedtimer.h>
@@ -68,14 +67,13 @@ class QUrl;
class QQmlEngine;
-class Q_QML_PRIVATE_EXPORT QQmlProfilerServiceImpl :
+class QQmlProfilerServiceImpl :
public QQmlConfigurableDebugService<QQmlProfilerService>,
public QQmlProfilerDefinitions
{
Q_OBJECT
public:
- static QQmlProfilerServiceImpl *instance();
void engineAboutToBeAdded(QQmlEngine *engine);
void engineAboutToBeRemoved(QQmlEngine *engine);
void engineAdded(QQmlEngine *engine);
@@ -87,7 +85,7 @@ public:
void startProfiling(QQmlEngine *engine, quint64 features = std::numeric_limits<quint64>::max());
void stopProfiling(QQmlEngine *engine);
- QQmlProfilerServiceImpl();
+ QQmlProfilerServiceImpl(QObject *parent = 0);
~QQmlProfilerServiceImpl();
void dataReady(QQmlAbstractProfilerAdapter *profiler);
@@ -104,6 +102,7 @@ protected:
virtual void messageReceived(const QByteArray &);
private:
+ friend class QQmlProfilerServiceFactory;
void sendMessages();
void addEngineProfiler(QQmlAbstractProfilerAdapter *profiler, QQmlEngine *engine);
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.json b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.json
new file mode 100644
index 0000000000..ec1ec364da
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "CanvasFrameRate", "EngineControl" ]
+}
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.cpp
new file mode 100644
index 0000000000..83c2075246
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlprofilerservice.h"
+#include "qqmlenginecontrolservice.h"
+#include "qqmlprofilerservicefactory.h"
+
+QT_BEGIN_NAMESPACE
+
+QQmlDebugService *QQmlProfilerServiceFactory::create(const QString &key)
+{
+ if (key == QQmlProfilerServiceImpl::s_key)
+ return new QQmlProfilerServiceImpl(this);
+
+ if (key == QQmlEngineControlService::s_key)
+ return new QQmlEngineControlService(this);
+
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h
new file mode 100644
index 0000000000..b570136e5b
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPROFILERSERVICE_H
+#define QQMLPROFILERSERVICE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qqmldebugservicefactory_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlProfilerServiceFactory : public QQmlDebugServiceFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmlprofilerservice.json")
+public:
+ QQmlDebugService *create(const QString &key);
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLPROFILERSERVICE_H
diff --git a/src/qml/debugger/qv4profileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
index 0da8c47939..24e01f4c68 100644
--- a/src/qml/debugger/qv4profileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
@@ -31,9 +31,8 @@
**
****************************************************************************/
-#include "qv4profileradapter_p.h"
-#include "qqmlprofilerservice_p.h"
-#include "qqmldebugservice_p.h"
+#include "qv4profileradapter.h"
+#include "qqmlprofilerservice.h"
QT_BEGIN_NAMESPACE
diff --git a/src/qml/debugger/qv4profileradapter_p.h b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h
index 34c37baf59..cea3da72e3 100644
--- a/src/qml/debugger/qv4profileradapter_p.h
+++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h
@@ -45,8 +45,8 @@
// We mean it.
//
-#include "qv4profiling_p.h"
-#include "qqmlabstractprofileradapter_p.h"
+#include <private/qv4profiling_p.h>
+#include <private/qqmlabstractprofileradapter_p.h>
#include <QStack>
#include <QList>
diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro
index 6af954ccf1..cfcf631f1a 100644
--- a/src/plugins/qmltooling/qmltooling.pro
+++ b/src/plugins/qmltooling/qmltooling.pro
@@ -2,6 +2,7 @@ TEMPLATE = subdirs
SUBDIRS += \
qmldbg_local \
+ qmldbg_profiler \
qmldbg_server \
qmldbg_tcp
diff --git a/src/qml/debugger/debugger.pri b/src/qml/debugger/debugger.pri
index b401216d77..9734e07a1d 100644
--- a/src/qml/debugger/debugger.pri
+++ b/src/qml/debugger/debugger.pri
@@ -5,22 +5,17 @@ SOURCES += \
$$PWD/qqmldebugconnector.cpp \
$$PWD/qqmldebugservice.cpp \
$$PWD/qqmldebugserviceinterfaces.cpp \
- $$PWD/qqmlprofilerservice.cpp \
$$PWD/qqmlenginedebugservice.cpp \
$$PWD/qdebugmessageservice.cpp \
$$PWD/qv4debugservice.cpp \
- $$PWD/qqmlenginecontrolservice.cpp \
$$PWD/qqmlabstractprofileradapter.cpp \
- $$PWD/qv4profileradapter.cpp \
$$PWD/qqmlprofiler.cpp
-
HEADERS += \
$$PWD/qqmldebugconnector_p.h \
$$PWD/qqmldebugpluginmanager_p.h \
$$PWD/qqmldebugservice_p.h \
$$PWD/qqmldebugservicefactory_p.h \
- $$PWD/qqmlprofilerservice_p.h \
$$PWD/qqmldebugserviceinterfaces_p.h \
$$PWD/qqmldebugstatesdelegate_p.h \
$$PWD/qqmlenginedebugservice_p.h \
@@ -28,10 +23,8 @@ HEADERS += \
$$PWD/qdebugmessageservice_p.h \
$$PWD/qv4debugservice_p.h \
$$PWD/qqmlconfigurabledebugservice_p.h \
- $$PWD/qqmlenginecontrolservice_p.h \
$$PWD/qqmlprofilerdefinitions_p.h \
$$PWD/qqmlabstractprofileradapter_p.h \
- $$PWD/qv4profileradapter_p.h \
$$PWD/qqmlprofiler_p.h
INCLUDEPATH += $$PWD
diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp
index e1dabb439e..9565f19563 100644
--- a/src/qml/debugger/qqmldebugconnector.cpp
+++ b/src/qml/debugger/qqmldebugconnector.cpp
@@ -34,9 +34,7 @@
#include "qqmldebugpluginmanager_p.h"
#include "qqmldebugconnector_p.h"
#include "qdebugmessageservice_p.h"
-#include "qqmlenginecontrolservice_p.h"
#include "qqmlenginedebugservice_p.h"
-#include "qqmlprofilerservice_p.h"
#include "qv4debugservice_p.h"
#include "qqmldebugservicefactory_p.h"
#include <QtCore/QPluginLoader>
@@ -56,6 +54,7 @@ Q_QML_IMPORT_DEBUG_PLUGIN(QQmlDebugServerFactory)
Q_QML_DEBUG_PLUGIN_LOADER(QQmlDebugService)
Q_QML_IMPORT_DEBUG_PLUGIN(QQmlInspectorServiceFactory)
+Q_QML_IMPORT_DEBUG_PLUGIN(QQmlProfilerServiceFactory)
struct QQmlDebugConnectorParams {
QString pluginKey;
@@ -121,9 +120,7 @@ QQmlDebugConnector *QQmlDebugConnector::instance()
if (params->instance) {
QQmlEngineDebugServiceImpl::instance();
QV4DebugServiceImpl::instance();
- QQmlProfilerServiceImpl::instance();
QDebugMessageService::instance();
- QQmlEngineControlService::instance();
foreach (const QJsonObject &object, metaDataForQQmlDebugService()) {
foreach (const QJsonValue &key, object.value(QLatin1String("MetaData")).toObject()
diff --git a/src/qml/debugger/qqmlprofiler.cpp b/src/qml/debugger/qqmlprofiler.cpp
index 30e089ac44..a6423d769a 100644
--- a/src/qml/debugger/qqmlprofiler.cpp
+++ b/src/qml/debugger/qqmlprofiler.cpp
@@ -32,92 +32,10 @@
****************************************************************************/
#include "qqmlprofiler_p.h"
-#include "qqmlprofilerservice_p.h"
#include "qqmldebugservice_p.h"
QT_BEGIN_NAMESPACE
-// convert to QByteArrays that can be sent to the debug client
-// use of QDataStream can skew results
-// (see tst_qqmldebugtrace::trace() benchmark)
-void QQmlProfilerData::toByteArrays(QList<QByteArray> &messages) const
-{
- QByteArray data;
- Q_ASSERT_X(((messageType | detailType) & (1 << 31)) == 0, Q_FUNC_INFO, "You can use at most 31 message types and 31 detail types.");
- for (uint decodedMessageType = 0; (messageType >> decodedMessageType) != 0; ++decodedMessageType) {
- if ((messageType & (1 << decodedMessageType)) == 0)
- continue;
-
- for (uint decodedDetailType = 0; (detailType >> decodedDetailType) != 0; ++decodedDetailType) {
- if ((detailType & (1 << decodedDetailType)) == 0)
- continue;
-
- //### using QDataStream is relatively expensive
- QQmlDebugStream ds(&data, QIODevice::WriteOnly);
- ds << time << decodedMessageType << decodedDetailType;
-
- switch (decodedMessageType) {
- case QQmlProfilerDefinitions::RangeStart:
- if (decodedDetailType == (int)QQmlProfilerDefinitions::Binding)
- ds << QQmlProfilerDefinitions::QmlBinding;
- break;
- case QQmlProfilerDefinitions::RangeData:
- ds << detailString;
- break;
- case QQmlProfilerDefinitions::RangeLocation:
- ds << (detailUrl.isEmpty() ? detailString : detailUrl.toString()) << x << y;
- break;
- case QQmlProfilerDefinitions::RangeEnd: break;
- default:
- Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message type.");
- break;
- }
- messages << data;
- data.clear();
- }
- }
-}
-
-QQmlProfilerAdapter::QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine) :
- QQmlAbstractProfilerAdapter(service), next(0)
-{
- engine->enableProfiler();
- connect(this, SIGNAL(profilingEnabled(quint64)), engine->profiler, SLOT(startProfiling(quint64)));
- connect(this, SIGNAL(profilingEnabledWhileWaiting(quint64)),
- engine->profiler, SLOT(startProfiling(quint64)), Qt::DirectConnection);
- connect(this, SIGNAL(profilingDisabled()), engine->profiler, SLOT(stopProfiling()));
- connect(this, SIGNAL(profilingDisabledWhileWaiting()),
- engine->profiler, SLOT(stopProfiling()), Qt::DirectConnection);
- connect(this, SIGNAL(dataRequested()), engine->profiler, SLOT(reportData()));
- connect(this, SIGNAL(referenceTimeKnown(QElapsedTimer)),
- engine->profiler, SLOT(setTimer(QElapsedTimer)));
- connect(engine->profiler, SIGNAL(dataReady(QVector<QQmlProfilerData>)),
- this, SLOT(receiveData(QVector<QQmlProfilerData>)));
-}
-
-qint64 QQmlProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
-{
- while (next != data.length()) {
- if (data[next].time > until)
- return data[next].time;
- data[next++].toByteArrays(messages);
- }
-
- next = 0;
- data.clear();
- return -1;
-}
-
-void QQmlProfilerAdapter::receiveData(const QVector<QQmlProfilerData> &new_data)
-{
- if (data.isEmpty())
- data = new_data;
- else
- data.append(new_data);
- service->dataReady(this);
-}
-
-
QQmlProfiler::QQmlProfiler() : featuresEnabled(0)
{
static int metatype = qRegisterMetaType<QVector<QQmlProfilerData> >();
diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h
index 67e6c9eda6..3c8337c969 100644
--- a/src/qml/debugger/qqmlprofiler_p.h
+++ b/src/qml/debugger/qqmlprofiler_p.h
@@ -68,8 +68,9 @@ QT_BEGIN_NAMESPACE
// This struct is somewhat dangerous to use:
// The messageType is a bit field. You can pack multiple messages into
// one object, e.g. RangeStart and RangeLocation. Each one will be read
-// independently by toByteArrays. Thus you can only pack messages if their data
-// doesn't overlap. It's up to you to figure that out.
+// independently when converting to QByteArrays. Thus you can only pack
+// messages if their data doesn't overlap. It's up to you to figure that
+// out.
struct Q_AUTOTEST_EXPORT QQmlProfilerData
{
QQmlProfilerData() {}
@@ -103,8 +104,6 @@ struct Q_AUTOTEST_EXPORT QQmlProfilerData
int x; //used by RangeLocation
int y; //used by RangeLocation
-
- void toByteArrays(QList<QByteArray> &messages) const;
};
Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_MOVABLE_TYPE);
@@ -178,20 +177,6 @@ protected:
QVector<QQmlProfilerData> m_data;
};
-class QQmlProfilerAdapter : public QQmlAbstractProfilerAdapter {
- Q_OBJECT
-public:
- QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine);
- qint64 sendMessages(qint64 until, QList<QByteArray> &messages);
-
-public slots:
- void receiveData(const QVector<QQmlProfilerData> &new_data);
-
-private:
- QVector<QQmlProfilerData> data;
- int next;
-};
-
//
// RAII helper structs
//