QmlProfiler: merge back changes in creator/master

Change-Id: Ib9a13c1feb08defa1b8cf1fc308837d71c858fae
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Christiaan Janssen
2013-08-06 16:47:48 +02:00
parent cf287b5e28
commit 6a1832cd29
9 changed files with 133 additions and 230 deletions

View File

@@ -45,7 +45,7 @@ LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner(
RunConfiguration *runConfiguration, RunConfiguration *runConfiguration,
const Analyzer::AnalyzerStartParameters &sp, const Analyzer::AnalyzerStartParameters &sp,
QString *errorMessage, QString *errorMessage,
QmlProfilerEngine *engine) QmlProfilerRunControl *engine)
{ {
QmlProjectManager::QmlProjectRunConfiguration *rc1 = QmlProjectManager::QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration); qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
@@ -81,7 +81,7 @@ LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner(
} }
LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuration, LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuration,
QmlProfilerEngine *engine) : QmlProfilerRunControl *engine) :
AbstractQmlProfilerRunner(engine), AbstractQmlProfilerRunner(engine),
m_configuration(configuration), m_configuration(configuration),
m_engine(engine) m_engine(engine)
@@ -92,12 +92,12 @@ LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuratio
LocalQmlProfilerRunner::~LocalQmlProfilerRunner() LocalQmlProfilerRunner::~LocalQmlProfilerRunner()
{ {
disconnect(&m_launcher, SIGNAL(processExited(int)), this, SLOT(spontaneousStop(int))); disconnect();
} }
void LocalQmlProfilerRunner::start() void LocalQmlProfilerRunner::start()
{ {
if (m_engine->mode() != Analyzer::StartQml) if (m_engine->mode() != Analyzer::StartLocal)
return; return;
QString arguments = QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_configuration.port); QString arguments = QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_configuration.port);
@@ -111,26 +111,32 @@ void LocalQmlProfilerRunner::start()
m_launcher.setWorkingDirectory(m_configuration.workingDirectory); m_launcher.setWorkingDirectory(m_configuration.workingDirectory);
m_launcher.setEnvironment(m_configuration.environment); m_launcher.setEnvironment(m_configuration.environment);
connect(&m_launcher, SIGNAL(processExited(int)), this, SLOT(spontaneousStop(int))); connect(&m_launcher, SIGNAL(processExited(int,QProcess::ExitStatus)),
this, SLOT(spontaneousStop(int,QProcess::ExitStatus)));
m_launcher.start(ProjectExplorer::ApplicationLauncher::Gui, m_configuration.executable, m_launcher.start(ProjectExplorer::ApplicationLauncher::Gui, m_configuration.executable,
arguments); arguments);
emit started(); emit started();
} }
void LocalQmlProfilerRunner::spontaneousStop(int exitCode) void LocalQmlProfilerRunner::spontaneousStop(int exitCode, QProcess::ExitStatus status)
{ {
if (QmlProfilerPlugin::debugOutput) if (QmlProfilerPlugin::debugOutput) {
qWarning("QmlProfiler: Application exited (exit code %d).", exitCode); if (status == QProcess::CrashExit)
qWarning("QmlProfiler: Application crashed.");
else
qWarning("QmlProfiler: Application exited (exit code %d).", exitCode);
}
disconnect(&m_launcher, SIGNAL(processExited(int)), this, SLOT(spontaneousStop(int))); disconnect(&m_launcher, SIGNAL(processExited(int,QProcess::ExitStatus)),
this, SLOT(spontaneousStop(int,QProcess::ExitStatus)));
emit stopped(); emit stopped();
} }
void LocalQmlProfilerRunner::stop() void LocalQmlProfilerRunner::stop()
{ {
if (m_engine->mode() != Analyzer::StartQml) if (m_engine->mode() != Analyzer::StartLocal)
return; return;
if (QmlProfilerPlugin::debugOutput) if (QmlProfilerPlugin::debugOutput)

View File

@@ -41,7 +41,7 @@ namespace Analyzer { class AnalyzerStartParameters; }
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
class QmlProfilerEngine; class QmlProfilerRunControl;
class LocalQmlProfilerRunner : public AbstractQmlProfilerRunner class LocalQmlProfilerRunner : public AbstractQmlProfilerRunner
{ {
Q_OBJECT Q_OBJECT
@@ -58,7 +58,7 @@ public:
static LocalQmlProfilerRunner *createLocalRunner(ProjectExplorer::RunConfiguration *runConfiguration, static LocalQmlProfilerRunner *createLocalRunner(ProjectExplorer::RunConfiguration *runConfiguration,
const Analyzer::AnalyzerStartParameters &sp, const Analyzer::AnalyzerStartParameters &sp,
QString *errorMessage, QString *errorMessage,
QmlProfilerEngine *engine); QmlProfilerRunControl *engine);
~LocalQmlProfilerRunner(); ~LocalQmlProfilerRunner();
@@ -68,15 +68,15 @@ public:
virtual quint16 debugPort() const; virtual quint16 debugPort() const;
private slots: private slots:
void spontaneousStop(int exitCode); void spontaneousStop(int exitCode, QProcess::ExitStatus status);
private: private:
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerEngine *engine); LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerRunControl *engine);
private: private:
Configuration m_configuration; Configuration m_configuration;
ProjectExplorer::ApplicationLauncher m_launcher; ProjectExplorer::ApplicationLauncher m_launcher;
QmlProfilerEngine *m_engine; QmlProfilerRunControl *m_engine;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -33,7 +33,6 @@
#include <analyzerbase/analyzermanager.h> #include <analyzerbase/analyzermanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <coreplugin/helpmanager.h> #include <coreplugin/helpmanager.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -61,74 +60,26 @@ namespace Internal {
// QmlProfilerEnginePrivate // QmlProfilerEnginePrivate
// //
class QmlProfilerEngine::QmlProfilerEnginePrivate class QmlProfilerRunControl::QmlProfilerEnginePrivate
{ {
public: public:
QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {} QmlProfilerEnginePrivate() : m_running(false) {}
~QmlProfilerEnginePrivate() { delete m_runner; }
bool attach(const QString &address, uint port);
QmlProfilerEngine *q;
QmlProfilerStateManager *m_profilerState; QmlProfilerStateManager *m_profilerState;
QTimer m_noDebugOutputTimer; QTimer m_noDebugOutputTimer;
QmlDebug::QmlOutputParser m_outputParser; QmlDebug::QmlOutputParser m_outputParser;
bool m_running;
}; };
AbstractQmlProfilerRunner *
QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(ProjectExplorer::RunConfiguration *runConfiguration,
QObject *parent)
{
AbstractQmlProfilerRunner *runner = 0;
if (!runConfiguration) // attaching
return 0;
QmlProjectManager::QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
LocalApplicationRunConfiguration *rc2 =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
// Supports only local run configurations
if (!rc1 && !rc2)
return 0;
ProjectExplorer::EnvironmentAspect *environment
= runConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
QTC_ASSERT(environment, return 0);
LocalQmlProfilerRunner::Configuration conf;
if (rc1) {
// This is a "plain" .qmlproject.
conf.executable = rc1->observerPath();
conf.executableArguments = rc1->viewerArguments();
conf.workingDirectory = rc1->workingDirectory();
conf.environment = environment->environment();
} else {
// FIXME: Check.
conf.executable = rc2->executable();
conf.executableArguments = rc2->commandLineArguments();
conf.workingDirectory = rc2->workingDirectory();
conf.environment = environment->environment();
}
const ProjectExplorer::IDevice::ConstPtr device =
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
conf.port = q->m_sp.analyzerPort;
runner = new LocalQmlProfilerRunner(conf, parent);
return runner;
}
// //
// QmlProfilerEngine // QmlProfilerEngine
// //
QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp, QmlProfilerRunControl::QmlProfilerRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration) ProjectExplorer::RunConfiguration *runConfiguration)
: d(new QmlProfilerEnginePrivate(this)) : AnalyzerRunControl(sp, runConfiguration)
, d(new QmlProfilerEnginePrivate)
{ {
m_sp = sp;
m_runConfig = runConfiguration;
d->m_profilerState = 0; d->m_profilerState = 0;
// Only wait 4 seconds for the 'Waiting for connection' on application output, then just try to connect // Only wait 4 seconds for the 'Waiting for connection' on application output, then just try to connect
@@ -146,14 +97,14 @@ QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp
this, SLOT(wrongSetupMessageBox(QString))); this, SLOT(wrongSetupMessageBox(QString)));
} }
QmlProfilerEngine::~QmlProfilerEngine() QmlProfilerRunControl::~QmlProfilerRunControl()
{ {
if (d->m_profilerState && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) if (d->m_profilerState && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning)
stop(); stopEngine();
delete d; delete d;
} }
bool QmlProfilerEngine::start() bool QmlProfilerRunControl::startEngine()
{ {
QTC_ASSERT(d->m_profilerState, return false); QTC_ASSERT(d->m_profilerState, return false);
@@ -169,24 +120,7 @@ bool QmlProfilerEngine::start()
} }
} }
d->m_runner = d->createRunner(runConfiguration(), this); if (startParameters().startMode == StartLocal) {
if (LocalQmlProfilerRunner *qmlRunner = qobject_cast<LocalQmlProfilerRunner *>(d->m_runner)) {
if (!qmlRunner->hasExecutable()) {
showNonmodalWarning(tr("No executable file to launch."));
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
AnalyzerManager::stopTool();
return false;
}
}
if (d->m_runner) {
connect(d->m_runner, SIGNAL(stopped()), this, SLOT(notifyRemoteFinished()));
connect(d->m_runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
this, SLOT(logApplicationMessage(QString,Utils::OutputFormat)));
d->m_runner->start();
d->m_noDebugOutputTimer.start();
} else if (m_sp.startMode == StartQmlRemote) {
d->m_noDebugOutputTimer.start(); d->m_noDebugOutputTimer.start();
} else { } else {
emit processRunning(startParameters().analyzerPort); emit processRunning(startParameters().analyzerPort);
@@ -197,7 +131,7 @@ bool QmlProfilerEngine::start()
return true; return true;
} }
void QmlProfilerEngine::stop() void QmlProfilerRunControl::stopEngine()
{ {
QTC_ASSERT(d->m_profilerState, return); QTC_ASSERT(d->m_profilerState, return);
@@ -222,7 +156,7 @@ void QmlProfilerEngine::stop()
} }
} }
void QmlProfilerEngine::notifyRemoteFinished(bool success) void QmlProfilerRunControl::notifyRemoteFinished(bool success)
{ {
QTC_ASSERT(d->m_profilerState, return); QTC_ASSERT(d->m_profilerState, return);
@@ -234,7 +168,7 @@ void QmlProfilerEngine::notifyRemoteFinished(bool success)
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled); d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
AnalyzerManager::stopTool(); AnalyzerManager::stopTool();
engineFinished(); runControlFinished();
break; break;
} }
case QmlProfilerStateManager::AppStopped : case QmlProfilerStateManager::AppStopped :
@@ -250,7 +184,7 @@ void QmlProfilerEngine::notifyRemoteFinished(bool success)
} }
} }
void QmlProfilerEngine::cancelProcess() void QmlProfilerRunControl::cancelProcess()
{ {
QTC_ASSERT(d->m_profilerState, return); QTC_ASSERT(d->m_profilerState, return);
@@ -270,16 +204,16 @@ void QmlProfilerEngine::cancelProcess()
return; return;
} }
} }
engineFinished(); runControlFinished();
} }
void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputFormat format) void QmlProfilerRunControl::logApplicationMessage(const QString &msg, Utils::OutputFormat format)
{ {
emit outputReceived(msg, format); appendMessage(msg, format);
d->m_outputParser.processOutput(msg); d->m_outputParser.processOutput(msg);
} }
void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage) void QmlProfilerRunControl::wrongSetupMessageBox(const QString &errorMessage)
{ {
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow()); QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical); infoBox->setIcon(QMessageBox::Critical);
@@ -299,10 +233,10 @@ void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage)
// KILL // KILL
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying); d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
AnalyzerManager::stopTool(); AnalyzerManager::stopTool();
emit finished(); runControlFinished();
} }
void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button) void QmlProfilerRunControl::wrongSetupMessageBoxFinished(int button)
{ {
if (button == QMessageBox::Help) { if (button == QMessageBox::Help) {
Core::HelpManager *helpManager = Core::HelpManager::instance(); Core::HelpManager *helpManager = Core::HelpManager::instance();
@@ -311,7 +245,7 @@ void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button)
} }
} }
void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg) void QmlProfilerRunControl::showNonmodalWarning(const QString &warningMsg)
{ {
QMessageBox *noExecWarning = new QMessageBox(Core::ICore::mainWindow()); QMessageBox *noExecWarning = new QMessageBox(Core::ICore::mainWindow());
noExecWarning->setIcon(QMessageBox::Warning); noExecWarning->setIcon(QMessageBox::Warning);
@@ -323,27 +257,27 @@ void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg)
noExecWarning->show(); noExecWarning->show();
} }
void QmlProfilerEngine::notifyRemoteSetupDone(quint16 port) void QmlProfilerRunControl::notifyRemoteSetupDone(quint16 port)
{ {
d->m_noDebugOutputTimer.stop(); d->m_noDebugOutputTimer.stop();
emit processRunning(port); emit processRunning(port);
} }
void QmlProfilerEngine::processIsRunning(quint16 port) void QmlProfilerRunControl::processIsRunning(quint16 port)
{ {
d->m_noDebugOutputTimer.stop(); d->m_noDebugOutputTimer.stop();
if (port > 0 && mode() != StartQmlRemote) if (port > 0 && startParameters().analyzerPort != 0)
emit processRunning(port); emit processRunning(port);
} }
void QmlProfilerEngine::engineStarted() void QmlProfilerRunControl::engineStarted()
{ {
d->m_running = true; d->m_running = true;
emit starting(this); emit starting(this);
} }
void QmlProfilerEngine::engineFinished() void QmlProfilerRunControl::runControlFinished()
{ {
d->m_running = false; d->m_running = false;
emit finished(); emit finished();
@@ -351,7 +285,7 @@ void QmlProfilerEngine::engineFinished()
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Profiler State // Profiler State
void QmlProfilerEngine::registerProfilerStateManager( QmlProfilerStateManager *profilerState ) void QmlProfilerRunControl::registerProfilerStateManager( QmlProfilerStateManager *profilerState )
{ {
// disconnect old // disconnect old
if (d->m_profilerState) if (d->m_profilerState)
@@ -364,7 +298,7 @@ void QmlProfilerEngine::registerProfilerStateManager( QmlProfilerStateManager *p
connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged())); connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged()));
} }
void QmlProfilerEngine::profilerStateChanged() void QmlProfilerRunControl::profilerStateChanged()
{ {
switch (d->m_profilerState->currentState()) { switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::AppReadyToStop : { case QmlProfilerStateManager::AppReadyToStop : {

View File

@@ -30,21 +30,22 @@
#ifndef QMLPROFILERENGINE_H #ifndef QMLPROFILERENGINE_H
#define QMLPROFILERENGINE_H #define QMLPROFILERENGINE_H
#include <analyzerbase/ianalyzerengine.h>
#include "qmlprofilerstatemanager.h" #include "qmlprofilerstatemanager.h"
#include <analyzerbase/analyzerruncontrol.h>
#include <utils/outputformat.h> #include <utils/outputformat.h>
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
class QmlProfilerEngine : public Analyzer::IAnalyzerEngine class QmlProfilerRunControl : public Analyzer::AnalyzerRunControl
{ {
Q_OBJECT Q_OBJECT
public: public:
QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp, QmlProfilerRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration); ProjectExplorer::RunConfiguration *runConfiguration);
~QmlProfilerEngine(); ~QmlProfilerRunControl();
void registerProfilerStateManager( QmlProfilerStateManager *profilerState ); void registerProfilerStateManager( QmlProfilerStateManager *profilerState );
@@ -57,8 +58,8 @@ signals:
void timeUpdate(); void timeUpdate();
public slots: public slots:
bool start(); bool startEngine();
void stop(); void stopEngine();
private slots: private slots:
void notifyRemoteFinished(bool success = true); void notifyRemoteFinished(bool success = true);
@@ -69,7 +70,7 @@ private slots:
void wrongSetupMessageBoxFinished(int); void wrongSetupMessageBoxFinished(int);
void processIsRunning(quint16 port = 0); void processIsRunning(quint16 port = 0);
void engineStarted(); void engineStarted();
void engineFinished(); void runControlFinished();
private slots: private slots:
void profilerStateChanged(); void profilerStateChanged();

View File

@@ -38,8 +38,6 @@
#include <QtPlugin> #include <QtPlugin>
using namespace Analyzer; using namespace Analyzer;
using namespace QmlProfiler; using namespace QmlProfiler;
using namespace QmlProfiler::Internal; using namespace QmlProfiler::Internal;
@@ -52,10 +50,9 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
Q_UNUSED(arguments) Q_UNUSED(arguments)
Q_UNUSED(errorString) Q_UNUSED(errorString)
StartModes modes; IAnalyzerTool *tool = new QmlProfilerTool(this);
modes.append(StartMode(StartLocal)); AnalyzerManager::addTool(tool, StartLocal);
modes.append(StartMode(StartRemote)); AnalyzerManager::addTool(tool, StartRemote);
AnalyzerManager::addTool(new QmlProfilerTool(this), modes);
addAutoReleasedObject(new QmlProfilerRunControlFactory()); addAutoReleasedObject(new QmlProfilerRunControlFactory());
QmlProfilerPlugin::instance = this; QmlProfilerPlugin::instance = this;

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Kläralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
@@ -37,11 +37,22 @@
#include <analyzerbase/analyzerruncontrol.h> #include <analyzerbase/analyzerruncontrol.h>
#include <analyzerbase/analyzersettings.h> #include <analyzerbase/analyzersettings.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/localapplicationrunconfiguration.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <qmlprojectmanager/qmlprojectrunconfiguration.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QTcpServer>
using namespace Analyzer; using namespace Analyzer;
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -55,35 +66,65 @@ QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) :
bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const
{ {
if (mode != QmlProfilerRunMode) return mode == QmlProfilerRunMode
return false; && (qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration)
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode); || qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration));
if (tool) }
return tool->canRun(runConfiguration, mode);
return false; static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration *runConfiguration)
{
AnalyzerStartParameters sp;
EnvironmentAspect *environment = runConfiguration->extraAspect<EnvironmentAspect>();
// FIXME: This is only used to communicate the connParams settings.
if (QmlProjectManager::QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration)) {
// This is a "plain" .qmlproject.
if (environment)
sp.environment = environment->environment();
sp.workingDirectory = rc1->workingDirectory();
sp.debuggee = rc1->observerPath();
sp.debuggeeArgs = rc1->viewerArguments();
sp.displayName = rc1->displayName();
} else if (LocalApplicationRunConfiguration *rc2 =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) {
if (environment)
sp.environment = environment->environment();
sp.workingDirectory = rc2->workingDirectory();
sp.debuggee = rc2->executable();
sp.debuggeeArgs = rc2->commandLineArguments();
sp.displayName = rc2->displayName();
} else {
// What could that be?
QTC_ASSERT(false, return sp);
}
const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
QTcpServer server;
if (!server.listen(QHostAddress::LocalHost) && !server.listen(QHostAddress::LocalHostIPv6)) {
qWarning() << "Cannot open port on host for QML profiling.";
return sp;
}
sp.analyzerHost = server.serverAddress().toString();
sp.analyzerPort = server.serverPort();
}
sp.startMode = StartLocal;
return sp;
} }
RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{ {
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected"); // never happens
return 0;
}
QTC_ASSERT(canRun(runConfiguration, mode), return 0); QTC_ASSERT(canRun(runConfiguration, mode), return 0);
AnalyzerStartParameters sp = tool->createStartParameters(runConfiguration, mode); AnalyzerStartParameters sp = createQmlProfilerStartParameters(runConfiguration);
sp.toolId = tool->id(); sp.runMode = mode;
// only desktop device is supported // only desktop device is supported
const ProjectExplorer::IDevice::ConstPtr device = const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0); QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration); AnalyzerRunControl *rc = AnalyzerManager::createRunControl(sp, runConfiguration);
QmlProfilerEngine *engine = qobject_cast<QmlProfilerEngine *>(rc->engine()); QmlProfilerRunControl *engine = qobject_cast<QmlProfilerRunControl *>(rc);
if (!engine) { if (!engine) {
delete rc; delete rc;
return 0; return 0;
@@ -94,7 +135,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
connect(runner, SIGNAL(stopped()), engine, SLOT(notifyRemoteFinished())); connect(runner, SIGNAL(stopped()), engine, SLOT(notifyRemoteFinished()));
connect(runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)), connect(runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
engine, SLOT(logApplicationMessage(QString,Utils::OutputFormat))); engine, SLOT(logApplicationMessage(QString,Utils::OutputFormat)));
connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)), runner, connect(engine, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)), runner,
SLOT(start())); SLOT(start()));
connect(rc, SIGNAL(finished()), runner, SLOT(stop())); connect(rc, SIGNAL(finished()), runner, SLOT(stop()));
return rc; return rc;

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Kläralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.

View File

@@ -70,8 +70,6 @@
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
#include <debugger/debuggerrunconfigurationaspect.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <QApplication> #include <QApplication>
@@ -98,18 +96,12 @@ using namespace QmlProjectManager;
class QmlProfilerTool::QmlProfilerToolPrivate class QmlProfilerTool::QmlProfilerToolPrivate
{ {
public: public:
QmlProfilerToolPrivate(QmlProfilerTool *qq) : q(qq) {}
~QmlProfilerToolPrivate() {}
QmlProfilerTool *q;
QmlProfilerStateManager *m_profilerState; QmlProfilerStateManager *m_profilerState;
QmlProfilerClientManager *m_profilerConnections; QmlProfilerClientManager *m_profilerConnections;
QmlProfilerModelManager *m_profilerModelManager; QmlProfilerModelManager *m_profilerModelManager;
QmlProfilerViewManager *m_viewContainer; QmlProfilerViewManager *m_viewContainer;
Utils::FileInProjectFinder m_projectFinder; Utils::FileInProjectFinder m_projectFinder;
RunConfiguration *m_runConfiguration;
QToolButton *m_recordButton; QToolButton *m_recordButton;
QToolButton *m_clearButton; QToolButton *m_clearButton;
@@ -124,13 +116,12 @@ public:
}; };
QmlProfilerTool::QmlProfilerTool(QObject *parent) QmlProfilerTool::QmlProfilerTool(QObject *parent)
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this)) : IAnalyzerTool(parent), d(new QmlProfilerToolPrivate)
{ {
setObjectName(QLatin1String("QmlProfilerTool")); setObjectName(QLatin1String("QmlProfilerTool"));
d->m_profilerState = 0; d->m_profilerState = 0;
d->m_viewContainer = 0; d->m_viewContainer = 0;
d->m_runConfiguration = 0;
qmlRegisterType<QmlProfilerCanvas>("Monitor", 1, 0, "Canvas2D"); qmlRegisterType<QmlProfilerCanvas>("Monitor", 1, 0, "Canvas2D");
qmlRegisterType<Context2D>(); qmlRegisterType<Context2D>();
@@ -206,10 +197,10 @@ IAnalyzerTool::ToolMode QmlProfilerTool::toolMode() const
return AnyMode; return AnyMode;
} }
IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp, AnalyzerRunControl *QmlProfilerTool::createRunControl(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration) RunConfiguration *runConfiguration)
{ {
QmlProfilerEngine *engine = new QmlProfilerEngine(sp, runConfiguration); QmlProfilerRunControl *engine = new QmlProfilerRunControl(sp, runConfiguration);
engine->registerProfilerStateManager(d->m_profilerState); engine->registerProfilerStateManager(d->m_profilerState);
@@ -236,15 +227,13 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
if (isTcpConnection) if (isTcpConnection)
d->m_profilerConnections->setTcpConnection(sp.analyzerHost, sp.analyzerPort); d->m_profilerConnections->setTcpConnection(sp.analyzerHost, sp.analyzerPort);
d->m_runConfiguration = runConfiguration;
// //
// Initialize m_projectFinder // Initialize m_projectFinder
// //
QString projectDirectory; QString projectDirectory;
if (d->m_runConfiguration) { if (runConfiguration) {
Project *project = d->m_runConfiguration->target()->project(); Project *project = runConfiguration->target()->project();
projectDirectory = project->projectDirectory(); projectDirectory = project->projectDirectory();
} }
@@ -256,14 +245,6 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
return engine; return engine;
} }
bool QmlProfilerTool::canRun(RunConfiguration *runConfiguration, RunMode mode) const
{
if (qobject_cast<QmlProjectRunConfiguration *>(runConfiguration)
|| qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration))
return mode == runMode();
return false;
}
static QString sysroot(RunConfiguration *runConfig) static QString sysroot(RunConfiguration *runConfig)
{ {
QTC_ASSERT(runConfig, return QString()); QTC_ASSERT(runConfig, return QString());
@@ -273,54 +254,6 @@ static QString sysroot(RunConfiguration *runConfig)
return QString(); return QString();
} }
AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration *runConfiguration, RunMode mode) const
{
Q_UNUSED(mode);
AnalyzerStartParameters sp;
ProjectExplorer::EnvironmentAspect *environment
= runConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
Debugger::DebuggerRunConfigurationAspect *debugger
= runConfiguration->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
QTC_ASSERT(debugger, return sp);
// FIXME: This is only used to communicate the connParams settings.
if (QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectRunConfiguration *>(runConfiguration)) {
// This is a "plain" .qmlproject.
if (environment)
sp.environment = environment->environment();
sp.workingDirectory = rc1->workingDirectory();
sp.debuggee = rc1->observerPath();
sp.debuggeeArgs = rc1->viewerArguments();
sp.displayName = rc1->displayName();
} else if (LocalApplicationRunConfiguration *rc2 =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) {
if (environment)
sp.environment = environment->environment();
sp.workingDirectory = rc2->workingDirectory();
sp.debuggee = rc2->executable();
sp.debuggeeArgs = rc2->commandLineArguments();
sp.displayName = rc2->displayName();
} else {
// What could that be?
QTC_ASSERT(false, return sp);
}
const ProjectExplorer::IDevice::ConstPtr device =
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
QTcpServer server;
if (!server.listen(QHostAddress::LocalHost) && !server.listen(QHostAddress::LocalHostIPv6)) {
qWarning() << "Cannot open port on host for QML profiling.";
return sp;
}
sp.analyzerHost = server.serverAddress().toString();
sp.analyzerPort = server.serverPort();
}
sp.startMode = StartQml;
return sp;
}
QWidget *QmlProfilerTool::createWidgets() QWidget *QmlProfilerTool::createWidgets()
{ {
QTC_ASSERT(!d->m_viewContainer, return 0); QTC_ASSERT(!d->m_viewContainer, return 0);
@@ -333,7 +266,6 @@ QWidget *QmlProfilerTool::createWidgets()
connect(d->m_viewContainer, SIGNAL(gotoSourceLocation(QString,int,int)), connect(d->m_viewContainer, SIGNAL(gotoSourceLocation(QString,int,int)),
this, SLOT(gotoSourceLocation(QString,int,int))); this, SLOT(gotoSourceLocation(QString,int,int)));
// //
// Toolbar // Toolbar
// //
@@ -513,7 +445,6 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
} }
AnalyzerStartParameters sp; AnalyzerStartParameters sp;
sp.toolId = tool->id();
sp.startMode = mode; sp.startMode = mode;
IDevice::ConstPtr device = DeviceKitInformation::device(kit); IDevice::ConstPtr device = DeviceKitInformation::device(kit);
@@ -529,7 +460,8 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
sp.sysroot = SysRootKitInformation::sysRoot(kit).toString(); sp.sysroot = SysRootKitInformation::sysRoot(kit).toString();
sp.analyzerPort = port; sp.analyzerPort = port;
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0); //AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt())); QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));
ProjectExplorerPlugin::instance()->startRunControl(rc, tool->runMode()); ProjectExplorerPlugin::instance()->startRunControl(rc, tool->runMode());
@@ -597,8 +529,7 @@ void QmlProfilerTool::showLoadDialog()
if (ModeManager::currentMode()->id() != MODE_ANALYZE) if (ModeManager::currentMode()->id() != MODE_ANALYZE)
AnalyzerManager::showMode(); AnalyzerManager::showMode();
if (AnalyzerManager::currentSelectedTool() != this) AnalyzerManager::selectTool(this, StartRemote);
AnalyzerManager::selectTool(this, StartRemote);
QString filename = QFileDialog::getOpenFileName(Core::ICore::mainWindow(), tr("Load QML Trace"), QString(), QString filename = QFileDialog::getOpenFileName(Core::ICore::mainWindow(), tr("Load QML Trace"), QString(),
tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension))); tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension)));

View File

@@ -31,7 +31,7 @@
#define QMLPROFILERTOOL_H #define QMLPROFILERTOOL_H
#include <analyzerbase/ianalyzertool.h> #include <analyzerbase/ianalyzertool.h>
#include <analyzerbase/ianalyzerengine.h> #include <analyzerbase/analyzerruncontrol.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QMessageBox; class QMessageBox;
@@ -56,16 +56,9 @@ public:
void extensionsInitialized() {} void extensionsInitialized() {}
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp, Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0); ProjectExplorer::RunConfiguration *runConfiguration = 0);
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
Analyzer::AnalyzerStartParameters createStartParameters(
ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
QWidget *createWidgets(); QWidget *createWidgets();
void startTool(Analyzer::StartMode mode); void startTool(Analyzer::StartMode mode);