From 2f97c709dedbab76c653e303dfa41b11e43bf201 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 9 Jun 2011 14:34:26 +0200 Subject: [PATCH] QmlProfiler: Support profiling via CODA on Symbian Change-Id: I44be1a67c95814a78c82b17e991e5e3a722a63c8 Reviewed-by: Christiaan Janssen Reviewed-on: http://codereview.qt.nokia.com/428 Reviewed-by: Qt Sanity Bot Reviewed-by: Kai Koehne --- .../analyzerruncontrolfactory.cpp | 17 ++-- .../qmlprofiler/QmlProfiler.pluginspec.in | 1 + .../qmlprofiler/codaqmlprofilerrunner.cpp | 82 +++++++++++++++++++ .../qmlprofiler/codaqmlprofilerrunner.h | 71 ++++++++++++++++ src/plugins/qmlprofiler/qmlprofiler.pro | 7 +- src/plugins/qmlprofiler/qmlprofilerengine.cpp | 57 +++++++------ src/plugins/qmlprofiler/qmlprofilertool.cpp | 49 +++++++++-- .../qt-s60/s60runcontrolbase.cpp | 5 +- 8 files changed, 246 insertions(+), 43 deletions(-) create mode 100644 src/plugins/qmlprofiler/codaqmlprofilerrunner.cpp create mode 100644 src/plugins/qmlprofiler/codaqmlprofilerrunner.h diff --git a/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp b/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp index 5b26c4d2057..ddd3eed1017 100644 --- a/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp +++ b/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp @@ -92,9 +92,7 @@ AnalyzerRunControlFactory::AnalyzerRunControlFactory(QObject *parent) bool AnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const { - return runConfiguration->isEnabled() && mode == Constants::MODE_ANALYZE - && (qobject_cast(runConfiguration) - || qobject_cast(runConfiguration)); + return runConfiguration->isEnabled() && mode == Constants::MODE_ANALYZE; } ProjectExplorer::RunControl *AnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, @@ -102,9 +100,16 @@ ProjectExplorer::RunControl *AnalyzerRunControlFactory::create(RunConfiguration { QTC_ASSERT(canRun(runConfiguration, mode), return 0); - const AnalyzerStartParameters sp - = qobject_cast(runConfiguration) - ? localStartParameters(runConfiguration) : remoteLinuxStartParameters(runConfiguration); + AnalyzerStartParameters sp; + if (qobject_cast(runConfiguration)) { + sp = localStartParameters(runConfiguration); + } else if (qobject_cast(runConfiguration)) { + sp = remoteLinuxStartParameters(runConfiguration); + } else { + // might be S60DeviceRunfiguration, or something else ... + sp.startMode = StartRemote; + } + return create(sp, runConfiguration); } diff --git a/src/plugins/qmlprofiler/QmlProfiler.pluginspec.in b/src/plugins/qmlprofiler/QmlProfiler.pluginspec.in index 6bdcd694e72..62416ce23e7 100644 --- a/src/plugins/qmlprofiler/QmlProfiler.pluginspec.in +++ b/src/plugins/qmlprofiler/QmlProfiler.pluginspec.in @@ -16,5 +16,6 @@ + diff --git a/src/plugins/qmlprofiler/codaqmlprofilerrunner.cpp b/src/plugins/qmlprofiler/codaqmlprofilerrunner.cpp new file mode 100644 index 00000000000..b8fb7bc617d --- /dev/null +++ b/src/plugins/qmlprofiler/codaqmlprofilerrunner.cpp @@ -0,0 +1,82 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** No Commercial Usage +** +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#include "codaqmlprofilerrunner.h" +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace ProjectExplorer; +using namespace Qt4ProjectManager; +using namespace QmlProfiler::Internal; + +CodaQmlProfilerRunner::CodaQmlProfilerRunner(S60DeviceRunConfiguration *configuration, + QObject *parent) : + AbstractQmlProfilerRunner(parent), + m_runControl(new CodaRunControl(configuration, Analyzer::Constants::MODE_ANALYZE)) +{ + connect(m_runControl, SIGNAL(finished()), this, SIGNAL(stopped())); + connect(m_runControl, + SIGNAL(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)), + this, SLOT(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat))); +} + +CodaQmlProfilerRunner::~CodaQmlProfilerRunner() +{ + delete m_runControl; +} + +void CodaQmlProfilerRunner::start() +{ + QTC_ASSERT(m_runControl, return); + m_runControl->start(); +} + +void CodaQmlProfilerRunner::stop() +{ + QTC_ASSERT(m_runControl, return); + m_runControl->stop(); +} + +void CodaQmlProfilerRunner::appendMessage(ProjectExplorer::RunControl *, const QString &message, + Utils::OutputFormat format) +{ + emit appendMessage(message, format); +} + diff --git a/src/plugins/qmlprofiler/codaqmlprofilerrunner.h b/src/plugins/qmlprofiler/codaqmlprofilerrunner.h new file mode 100644 index 00000000000..9ebacaf4374 --- /dev/null +++ b/src/plugins/qmlprofiler/codaqmlprofilerrunner.h @@ -0,0 +1,71 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** No Commercial Usage +** +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef CODAQMLPROFILERRUNNER_H +#define CODAQMLPROFILERRUNNER_H + +#include "abstractqmlprofilerrunner.h" + +#include +#include +#include + +namespace QmlProfiler { +namespace Internal { + +class CodaQmlProfilerRunner : public AbstractQmlProfilerRunner +{ + Q_OBJECT + Q_DISABLE_COPY(CodaQmlProfilerRunner) + + using AbstractQmlProfilerRunner::appendMessage; // don't hide signal +public: + explicit CodaQmlProfilerRunner(Qt4ProjectManager::S60DeviceRunConfiguration *configuration, + QObject *parent = 0); + ~CodaQmlProfilerRunner(); + + // AbstractQmlProfilerRunner + virtual void start(); + virtual void stop(); + +private slots: + void appendMessage(ProjectExplorer::RunControl *, const QString &message, + Utils::OutputFormat format); +private: + ProjectExplorer::RunControl *m_runControl; +}; + +} // namespace Internal +} // namespace QmlProfiler + +#endif // CODAQMLPROFILERRUNNER_H diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index bd8fbd623a6..c240a5991bb 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -7,6 +7,7 @@ include(../../qtcreatorplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/analyzerbase/analyzerbase.pri) include(../../plugins/qmlprojectmanager/qmlprojectmanager.pri) +include(../../plugins/qt4projectmanager/qt4projectmanager.pri) include(../../libs/qmljsdebugclient/qmljsdebugclient-lib.pri) QT += network script declarative @@ -22,7 +23,8 @@ SOURCES += \ qmlprofilerattachdialog.cpp \ qmlprofilersummaryview.cpp \ qmlprojectanalyzerruncontrolfactory.cpp \ - localqmlprofilerrunner.cpp + localqmlprofilerrunner.cpp \ + codaqmlprofilerrunner.cpp HEADERS += \ qmlprofilerconstants.h \ @@ -36,7 +38,8 @@ HEADERS += \ qmlprofilersummaryview.h \ qmlprojectanalyzerruncontrolfactory.h \ abstractqmlprofilerrunner.h \ - localqmlprofilerrunner.h + localqmlprofilerrunner.h \ + codaqmlprofilerrunner.h RESOURCES += \ qml/qml.qrc diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp index aa631a7df1f..b0a893dd11d 100644 --- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp @@ -36,6 +36,7 @@ #include "qmlprofilerplugin.h" #include "qmlprofilertool.h" #include "localqmlprofilerrunner.h" +#include "codaqmlprofilerrunner.h" #include #include @@ -43,6 +44,7 @@ #include #include +#include #include @@ -65,8 +67,30 @@ namespace Internal { // QmlProfilerEnginePrivate // -static AbstractQmlProfilerRunner * -createRunner(const Analyzer::AnalyzerStartParameters &m_params, QObject *parent) +class QmlProfilerEngine::QmlProfilerEnginePrivate +{ +public: + QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {} + ~QmlProfilerEnginePrivate() {} + + bool attach(const QString &address, uint port); + static AbstractQmlProfilerRunner *createRunner(ProjectExplorer::RunConfiguration *runConfiguration, + const Analyzer::AnalyzerStartParameters &m_params, + QObject *parent); + + QmlProfilerEngine *q; + + Analyzer::AnalyzerStartParameters m_params; + AbstractQmlProfilerRunner *m_runner; + bool m_running; + bool m_fetchingData; + bool m_delayedDelete; +}; + +AbstractQmlProfilerRunner * +QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(ProjectExplorer::RunConfiguration *configuration, + const Analyzer::AnalyzerStartParameters &m_params, + QObject *parent) { AbstractQmlProfilerRunner *runner = 0; if (m_params.startMode == Analyzer::StartLocal) { @@ -78,32 +102,15 @@ createRunner(const Analyzer::AnalyzerStartParameters &m_params, QObject *parent) configuration.port = m_params.connParams.port; runner = new LocalQmlProfilerRunner(configuration, parent); - } else if (m_params.startMode == Analyzer::StartRemote) { - + if (Qt4ProjectManager::S60DeviceRunConfiguration *s60Config + = qobject_cast(configuration)) { + runner = new CodaQmlProfilerRunner(s60Config, parent); + } } return runner; } - -class QmlProfilerEngine::QmlProfilerEnginePrivate -{ -public: - QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {} - ~QmlProfilerEnginePrivate() {} - - bool attach(const QString &address, uint port); - - QmlProfilerEngine *q; - - Analyzer::AnalyzerStartParameters m_params; - AbstractQmlProfilerRunner *m_runner; - bool m_running; - bool m_fetchingData; - bool m_delayedDelete; -}; - - // // QmlProfilerEngine // @@ -129,10 +136,9 @@ QmlProfilerEngine::~QmlProfilerEngine() void QmlProfilerEngine::start() { QTC_ASSERT(!d->m_runner, return); - d->m_runner = createRunner(d->m_params, this); + d->m_runner = QmlProfilerEnginePrivate::createRunner(runConfiguration(), d->m_params, this); QTC_ASSERT(d->m_runner, return); - connect(d->m_runner, SIGNAL(started()), this, SIGNAL(processRunning())); connect(d->m_runner, SIGNAL(stopped()), this, SLOT(stopped())); connect(d->m_runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)), this, SLOT(logApplicationMessage(QString,Utils::OutputFormat))); @@ -148,6 +154,7 @@ void QmlProfilerEngine::stop() if (d->m_fetchingData) { if (d->m_running) d->m_delayedDelete = true; + // will result in dataReceived() call emit stopRecording(); } else { finishProcess(); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 61d5f166e34..ff872816a80 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -66,6 +66,8 @@ #include #include +#include + #include #include @@ -96,8 +98,15 @@ public: QAction *m_attachAction; QToolButton *m_recordButton; bool m_recordingEnabled; - QString m_host; - quint64 m_port; + + enum ConnectMode { + TcpConnection, OstConnection + }; + + ConnectMode m_connectMode; + QString m_tcpHost; + quint64 m_tcpPort; + QString m_ostDevice; }; QmlProfilerTool::QmlProfilerTool(QObject *parent) @@ -142,8 +151,22 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp { QmlProfilerEngine *engine = new QmlProfilerEngine(sp, runConfiguration); - d->m_host = sp.connParams.host; - d->m_port = sp.connParams.port; + d->m_connectMode = QmlProfilerToolPrivate::TcpConnection; + + if (Qt4ProjectManager::S60DeployConfiguration *deployConfig + = qobject_cast( + runConfiguration->target()->activeDeployConfiguration())) { + if (deployConfig->communicationChannel() + == Qt4ProjectManager::S60DeployConfiguration::CommunicationCodaSerialConnection) { + d->m_connectMode = QmlProfilerToolPrivate::OstConnection; + d->m_ostDevice = deployConfig->serialPortName(); + } + } + + if (d->m_connectMode == QmlProfilerToolPrivate::TcpConnection) { + d->m_tcpHost = sp.connParams.host; + d->m_tcpPort = sp.connParams.port; + } d->m_runConfiguration = runConfiguration; d->m_project = runConfiguration->target()->project(); @@ -274,10 +297,18 @@ void QmlProfilerTool::connectToClient() { if (!d->m_client || d->m_client->state() != QAbstractSocket::UnconnectedState) return; - if (QmlProfilerPlugin::debugOutput) - qWarning("QmlProfiler: Connecting to %s:%lld ...", qPrintable(d->m_host), d->m_port); - d->m_client->connectToHost(d->m_host, d->m_port); + if (d->m_connectMode == QmlProfilerToolPrivate::TcpConnection) { + if (QmlProfilerPlugin::debugOutput) + qWarning("QmlProfiler: Connecting to %s:%lld ...", qPrintable(d->m_tcpHost), d->m_tcpPort); + + d->m_client->connectToHost(d->m_tcpHost, d->m_tcpPort); + } else { + if (QmlProfilerPlugin::debugOutput) + qWarning("QmlProfiler: Connecting to ost device %s...", qPrintable(d->m_ostDevice)); + + d->m_client->connectToOst(d->m_ostDevice); + } } void QmlProfilerTool::disconnectClient() @@ -367,8 +398,8 @@ void QmlProfilerTool::attach() if (result == QDialog::Rejected) return; - d->m_port = dialog.port(); - d->m_host = dialog.address(); + d->m_tcpPort = dialog.port(); + d->m_tcpHost = dialog.address(); connectClient(); AnalyzerManager::instance()->showMode(); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runcontrolbase.cpp b/src/plugins/qt4projectmanager/qt-s60/s60runcontrolbase.cpp index e88223d0a77..25750934495 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60runcontrolbase.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60runcontrolbase.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -90,7 +91,9 @@ S60RunControlBase::S60RunControlBase(RunConfiguration *runConfiguration, const Q m_targetName = s60runConfig->targetName(); m_commandLineArguments = s60runConfig->commandLineArguments(); QString qmlArgs = s60runConfig->qmlCommandLineArguments(); - if (mode == Debugger::Constants::DEBUGMODE && qmlArgs.length()) { + if ((mode == Debugger::Constants::DEBUGMODE) + || (mode == Analyzer::Constants::MODE_ANALYZE) + && !qmlArgs.isEmpty()) { m_commandLineArguments.prepend(' '); m_commandLineArguments.prepend(qmlArgs); }