Tell the QML debug server exactly what services we expect

The services need to be loaded before the first QML engine is created.
The first QML engine may be created before a client connects. When the
JavaScript debug service is loaded the engine is put into interpreter
mode as we don't support debugging in JIT mode. Profiling, however
should be done in JIT mode, whenever possible.

Thus, in order to avoid the loading of unnecessary plugins and to get
better results from the QML profiler we tell the debug server which
services we expect, even before the client connects. Qt 5.6 will support
additional command line arguments to specify the services and this
change uses them.

Change-Id: I6dcee016c39995e9adada6eaf0e39d8299c9b7e7
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2015-08-10 17:43:58 +02:00
parent be31022276
commit 5f90990c30
16 changed files with 132 additions and 31 deletions

View File

@@ -21,7 +21,8 @@ HEADERS += \
$$PWD/basetoolsclient.h \
$$PWD/declarativetoolsclient.h \
$$PWD/qmltoolsclient.h \
$$PWD/qmlenginecontrolclient.h
$$PWD/qmlenginecontrolclient.h \
$$PWD/qmldebugcommandlinearguments.h
SOURCES += \
$$PWD/qmldebugclient.cpp \

View File

@@ -23,6 +23,7 @@ QtcLibrary {
"qmldebug_global.h",
"qmldebugclient.cpp",
"qmldebugclient.h",
"qmldebugcommandlinearguments.h",
"qmldebugconstants.h",
"qmlenginecontrolclient.cpp",
"qmlenginecontrolclient.h",

View File

@@ -0,0 +1,72 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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.
**
** In addition, 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.
**
****************************************************************************/
#ifndef QMLDEBUGCOMMANDLINEARGUMENTS_H
#define QMLDEBUGCOMMANDLINEARGUMENTS_H
#include <QString>
namespace QmlDebug {
enum QmlDebugServicesPreset {
NoQmlDebugServices,
QmlDebuggerServices,
QmlProfilerServices
};
static inline QString qmlDebugServices(QmlDebugServicesPreset preset)
{
switch (preset) {
case NoQmlDebugServices:
return QString();
case QmlDebuggerServices:
return QStringLiteral("DebugMessages,QmlDebugger,V8Debugger,QmlInspector");
case QmlProfilerServices:
return QStringLiteral("CanvasFrameRate,EngineControl");
default:
Q_ASSERT(false);
return QString();
}
}
static inline QString qmlDebugCommandLineArguments(QmlDebugServicesPreset services,
quint16 port = 0)
{
if (services == NoQmlDebugServices)
return QString();
return QString::fromLatin1("-qmljsdebugger=port:%1,block,services:%2")
.arg(port ? QString::number(port) : QStringLiteral("%qml_port%"))
.arg(qmlDebugServices(services));
}
} // namespace QmlDebug
#endif // QMLDEBUGCOMMANDLINEARGUMENTS_H

View File

@@ -134,13 +134,17 @@ AndroidRunner::AndroidRunner(QObject *parent,
= runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
const bool debuggingMode = (runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE || runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
m_useCppDebugger = debuggingMode && aspect->useCppDebugger();
m_useQmlDebugger = debuggingMode && aspect->useQmlDebugger();
if (debuggingMode && aspect->useQmlDebugger())
m_qmlDebugServices = QmlDebug::QmlDebuggerServices;
else if (runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
m_qmlDebugServices = QmlDebug::QmlProfilerServices;
else
m_qmlDebugServices = QmlDebug::NoQmlDebugServices;
QString channel = runConfig->remoteChannel();
QTC_CHECK(channel.startsWith(QLatin1Char(':')));
m_localGdbServerPort = channel.mid(1).toUShort();
QTC_CHECK(m_localGdbServerPort);
m_useQmlProfiler = runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE;
if (m_useQmlDebugger || m_useQmlProfiler) {
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) {
QTcpServer server;
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|| server.listen(QHostAddress::LocalHostIPv6),
@@ -289,12 +293,12 @@ void AndroidRunner::checkPID()
// gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below.
QByteArray serverChannel = ':' + QByteArray::number(m_localGdbServerPort);
emit remoteServerRunning(serverChannel, m_processPID);
} else if (m_useQmlDebugger) {
} else if (m_qmlDebugServices == QmlDebug::QmlDebuggerServices) {
// This will be funneled to the engine to actually start and attach
// gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below.
QByteArray serverChannel = QByteArray::number(m_qmlPort);
emit remoteServerRunning(serverChannel, m_processPID);
} else if (m_useQmlProfiler) {
} else if (m_qmlDebugServices == QmlDebug::QmlProfilerServices) {
emit remoteProcessStarted(-1, m_qmlPort);
} else {
// Start without debugging.
@@ -389,7 +393,7 @@ void AndroidRunner::asyncStart()
}
}
if (m_useQmlDebugger || m_useQmlProfiler) {
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) {
// currently forward to same port on device and host
const QString port = QString::fromLatin1("tcp:%1").arg(m_qmlPort);
QProcess adb;
@@ -402,8 +406,11 @@ void AndroidRunner::asyncStart()
emit remoteProcessFinished(tr("Failed to forward QML debugging ports."));
return;
}
args << _("-e") << _("qml_debug") << _("true");
args << _("-e") << _("qmljsdebugger") << QString::fromLatin1("port:%1,block").arg(m_qmlPort);
args << _("-e") << _("qml_debug") << _("true")
<< _("-e") << _("qmljsdebugger")
<< QString::fromLatin1("port:%1,block,services:%2")
.arg(m_qmlPort).arg(QmlDebug::qmlDebugServices(m_qmlDebugServices));
}
QProcess adb;

View File

@@ -34,6 +34,7 @@
#include "androidconfigurations.h"
#include <projectexplorer/runconfiguration.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <QObject>
#include <QTimer>
@@ -103,8 +104,7 @@ private:
QString m_deviceSerialNumber;
qint64 m_processPID;
bool m_useCppDebugger;
bool m_useQmlDebugger;
bool m_useQmlProfiler;
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
ushort m_localGdbServerPort; // Local end of forwarded debug socket.
quint16 m_qmlPort;
bool m_useLocalQtLibs;

View File

@@ -57,6 +57,7 @@
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <coreplugin/icore.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <QTcpServer>
@@ -462,7 +463,8 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
if (!m_rp.environment.hasKey(optimizerKey))
m_rp.environment.set(optimizerKey, _("1"));
QtcProcess::addArg(&m_rp.processArgs, QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_rp.qmlServerPort));
QtcProcess::addArg(&m_rp.processArgs, QmlDebug::qmlDebugCommandLineArguments(
QmlDebug::QmlDebuggerServices, m_rp.qmlServerPort));
}
}
}

View File

@@ -100,7 +100,8 @@ RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runC
IosAnalyzeSupport::IosAnalyzeSupport(IosRunConfiguration *runConfig,
AnalyzerRunControl *runControl, bool cppDebug, bool qmlDebug)
: QObject(runControl), m_runControl(runControl),
m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug))
m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug ? QmlDebug::QmlProfilerServices :
QmlDebug::NoQmlDebugServices))
{
connect(m_runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)),
m_runner, SLOT(start()));

View File

@@ -161,7 +161,8 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi
IosDebugSupport::IosDebugSupport(IosRunConfiguration *runConfig,
DebuggerRunControl *runControl, bool cppDebug, bool qmlDebug)
: QObject(runControl), m_runControl(runControl),
m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug))
m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug ? QmlDebug::QmlDebuggerServices :
QmlDebug::NoQmlDebugServices))
{
connect(m_runControl, SIGNAL(requestRemoteSetup()),
m_runner, SLOT(start()));

View File

@@ -42,7 +42,7 @@ namespace Internal {
IosRunControl::IosRunControl(IosRunConfiguration *rc)
: RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_runner(new IosRunner(this, rc, false, false))
, m_runner(new IosRunner(this, rc, false, QmlDebug::NoQmlDebugServices))
, m_running(false)
{
setIcon(QLatin1String(ProjectExplorer::Constants::ICON_DEBUG_SMALL));

View File

@@ -43,6 +43,7 @@
#include <projectexplorer/taskhub.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <QDir>
#include <QTime>
@@ -56,11 +57,12 @@ using namespace ProjectExplorer;
namespace Ios {
namespace Internal {
IosRunner::IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool cppDebug, bool qmlDebug)
IosRunner::IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool cppDebug,
QmlDebug::QmlDebugServicesPreset qmlDebugServices)
: QObject(parent), m_toolHandler(0), m_bundleDir(runConfig->bundleDirectory().toString()),
m_arguments(runConfig->commandLineArguments()),
m_device(DeviceKitInformation::device(runConfig->target()->kit())),
m_cppDebug(cppDebug), m_qmlDebug(qmlDebug), m_cleanExit(false),
m_cppDebug(cppDebug), m_qmlDebugServices(qmlDebugServices), m_cleanExit(false),
m_qmlPort(0), m_pid(0)
{
m_deviceType = runConfig->deviceType();
@@ -80,7 +82,7 @@ QStringList IosRunner::extraArgs()
{
QStringList res = m_arguments;
if (m_qmlPort != 0)
res << QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_qmlPort);
res << QmlDebug::qmlDebugCommandLineArguments(m_qmlDebugServices, m_qmlPort);
return res;
}
@@ -104,9 +106,9 @@ bool IosRunner::cppDebug() const
return m_cppDebug;
}
bool IosRunner::qmlDebug() const
QmlDebug::QmlDebugServicesPreset IosRunner::qmlDebugServices() const
{
return m_qmlDebug;
return m_qmlDebugServices;
}
void IosRunner::start()
@@ -130,7 +132,7 @@ void IosRunner::start()
emit finished(m_cleanExit);
return;
}
if (m_qmlDebug)
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices)
m_qmlPort = iosDevice->nextPort();
} else {
IosSimulator::ConstPtr sim = m_device.dynamicCast<const IosSimulator>();
@@ -138,7 +140,7 @@ void IosRunner::start()
emit finished(m_cleanExit);
return;
}
if (m_qmlDebug)
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices)
m_qmlPort = sim->nextPort();
}

View File

@@ -35,6 +35,7 @@
#include "iossimulator.h"
#include <projectexplorer/devicesupport/idevice.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <QObject>
#include <QTimer>
@@ -52,7 +53,8 @@ class IosRunner : public QObject
Q_OBJECT
public:
IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool cppDebug, bool qmlDebug);
IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool cppDebug,
QmlDebug::QmlDebugServicesPreset qmlDebugServices);
~IosRunner();
QString displayName() const;
@@ -62,7 +64,7 @@ public:
QString deviceId();
IosToolHandler::RunKind runType();
bool cppDebug() const;
bool qmlDebug() const;
QmlDebug::QmlDebugServicesPreset qmlDebugServices() const;
public slots:
void start();
void stop();
@@ -92,7 +94,8 @@ private:
ProjectExplorer::IDevice::ConstPtr m_device;
IosDeviceType m_deviceType;
bool m_cppDebug;
bool m_qmlDebug;
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
bool m_cleanExit;
quint16 m_qmlPort;
Q_PID m_pid;

View File

@@ -41,6 +41,7 @@
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <QTcpServer>
@@ -119,7 +120,8 @@ LocalQmlProfilerRunner::~LocalQmlProfilerRunner()
void LocalQmlProfilerRunner::start()
{
QString arguments = QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_configuration.port);
QString arguments = QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices,
m_configuration.port);
if (!m_configuration.executableArguments.isEmpty())
arguments += QLatin1Char(' ') + m_configuration.executableArguments;

View File

@@ -42,6 +42,7 @@
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
using namespace ProjectExplorer;
@@ -98,7 +99,8 @@ void QnxAnalyzeSupport::startExecution()
const QStringList args = QStringList()
<< Utils::QtcProcess::splitArgs(m_runControl->startParameters().debuggeeArgs)
<< QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_qmlPort);
<< QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, m_qmlPort);
appRunner()->setEnvironment(environment());
appRunner()->setWorkingDirectory(workingDirectory());
appRunner()->start(device(), executable(), args);

View File

@@ -45,6 +45,7 @@
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
using namespace ProjectExplorer;
using namespace RemoteLinux;
@@ -104,7 +105,8 @@ void QnxDebugSupport::startExecution()
setState(StartingRemoteProcess);
if (m_useQmlDebugger)
m_runControl->startParameters().processArgs += QString::fromLatin1(" -qmljsdebugger=port:%1,block").arg(m_qmlPort);
m_runControl->startParameters().processArgs +=
QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlDebuggerServices, m_qmlPort);
QStringList arguments;
if (m_useCppDebugger)

View File

@@ -43,6 +43,7 @@
#include <utils/qtcassert.h>
#include <qmldebug/qmloutputparser.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <QPointer>
@@ -147,7 +148,8 @@ void RemoteLinuxAnalyzeSupport::startExecution()
this, &RemoteLinuxAnalyzeSupport::handleAppRunnerError);
const QStringList args = arguments()
<< QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(d->qmlPort);
<< QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, d->qmlPort);
runner->setWorkingDirectory(workingDirectory());
runner->setEnvironment(environment());
runner->start(device(), remoteFilePath(), args);

View File

@@ -45,6 +45,7 @@
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <QPointer>
@@ -101,7 +102,8 @@ DebuggerStartParameters LinuxDeviceDebugSupport::startParameters(const AbstractR
aspect->setUseMultiProcess(true);
QStringList args = runConfig->arguments();
if (aspect->useQmlDebugger())
args.prepend(QString::fromLatin1("-qmljsdebugger=port:%qml_port%,block"));
args.prepend(QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlDebuggerServices));
params.processArgs = Utils::QtcProcess::joinArgs(args, Utils::OsTypeLinux);
params.executable = runConfig->localExecutableFilePath();
params.remoteChannel = device->sshParameters().host + QLatin1String(":-1");
@@ -164,7 +166,8 @@ void LinuxDeviceDebugSupport::startExecution()
QString command;
if (d->qmlDebugging)
args.prepend(QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(d->qmlPort));
args.prepend(QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlDebuggerServices,
d->qmlPort));
if (d->qmlDebugging && !d->cppDebugging) {
command = remoteFilePath();