diff options
author | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2014-03-26 09:58:55 +0100 |
---|---|---|
committer | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2014-03-31 15:13:04 +0200 |
commit | 2ef08b7580c26517a46c5cd5503192f3d9cbfc78 (patch) | |
tree | 27688fa8ca77b11a119e54fb960aa258b820f8b9 | |
parent | 04948228bb9192d049c714cc89a8341789fa3834 (diff) |
ios: add qml profiler support
Change-Id: I6dbea675a77ed0d151dc6bbdcfa501c00107998c
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
-rw-r--r-- | src/plugins/ios/ios.pro | 6 | ||||
-rw-r--r-- | src/plugins/ios/ios.qbs | 3 | ||||
-rw-r--r-- | src/plugins/ios/ios_dependencies.pri | 3 | ||||
-rw-r--r-- | src/plugins/ios/iosanalyzesupport.cpp | 175 | ||||
-rw-r--r-- | src/plugins/ios/iosanalyzesupport.h | 78 | ||||
-rw-r--r-- | src/plugins/ios/iosrunfactories.cpp | 6 |
6 files changed, 267 insertions, 4 deletions
diff --git a/src/plugins/ios/ios.pro b/src/plugins/ios/ios.pro index 4c93ba5860..187f2769b7 100644 --- a/src/plugins/ios/ios.pro +++ b/src/plugins/ios/ios.pro @@ -32,7 +32,8 @@ HEADERS += \ iosdeployconfiguration.h \ iosdeploystep.h \ iosdeploystepfactory.h \ - iosdeploystepwidget.h + iosdeploystepwidget.h \ + iosanalyzesupport.h SOURCES += \ @@ -59,7 +60,8 @@ SOURCES += \ iosdeployconfiguration.cpp \ iosdeploystep.cpp \ iosdeploystepfactory.cpp \ - iosdeploystepwidget.cpp + iosdeploystepwidget.cpp \ + iosanalyzesupport.cpp FORMS += \ iossettingswidget.ui \ diff --git a/src/plugins/ios/ios.qbs b/src/plugins/ios/ios.qbs index fd50541b59..ae27e1ab58 100644 --- a/src/plugins/ios/ios.qbs +++ b/src/plugins/ios/ios.qbs @@ -11,6 +11,7 @@ QtcPlugin { Depends { name: "QmakeProjectManager" } Depends { name: "Debugger" } Depends { name: "QtSupport" } + Depends { name: "AnalyzerBase" } Depends { name: "Qt"; submodules: ["widgets", "xml", "network"] } cpp.includePaths: base.concat("../../shared") @@ -18,6 +19,8 @@ QtcPlugin { files: [ "ios.qrc", + "iosanalyzersupport.cpp", + "iosanalyzersupport.h", "iosbuildstep.cpp", "iosbuildstep.h", "iosbuildstep.ui", diff --git a/src/plugins/ios/ios_dependencies.pri b/src/plugins/ios/ios_dependencies.pri index 106d8ccbea..6e0f1ebc01 100644 --- a/src/plugins/ios/ios_dependencies.pri +++ b/src/plugins/ios/ios_dependencies.pri @@ -5,4 +5,5 @@ QTC_PLUGIN_DEPENDS += \ coreplugin \ debugger \ projectexplorer \ - qmakeprojectmanager + qmakeprojectmanager \ + analyzerbase diff --git a/src/plugins/ios/iosanalyzesupport.cpp b/src/plugins/ios/iosanalyzesupport.cpp new file mode 100644 index 0000000000..3e3a608464 --- /dev/null +++ b/src/plugins/ios/iosanalyzesupport.cpp @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iosanalyzesupport.h" + +#include "iosrunner.h" +#include "iosmanager.h" +#include "iosdevice.h" + +#include <debugger/debuggerengine.h> +#include <debugger/debuggerplugin.h> +#include <debugger/debuggerkitinformation.h> +#include <debugger/debuggerrunner.h> +#include <debugger/debuggerstartparameters.h> +#include <debugger/debuggerrunconfigurationaspect.h> +#include <projectexplorer/toolchain.h> +#include <projectexplorer/target.h> +#include <projectexplorer/taskhub.h> +#include <qmakeprojectmanager/qmakebuildconfiguration.h> +#include <qmakeprojectmanager/qmakenodes.h> +#include <qmakeprojectmanager/qmakeproject.h> +#include <qtsupport/qtkitinformation.h> +#include <utils/fileutils.h> +#include <analyzerbase/ianalyzertool.h> +#include <analyzerbase/analyzermanager.h> +#include <analyzerbase/analyzerruncontrol.h> +#include <analyzerbase/analyzerstartparameters.h> +#include <utils/outputformat.h> +#include <utils/qtcprocess.h> + +#include <QDir> +#include <QTcpServer> +#include <QSettings> + +#include <stdio.h> +#include <fcntl.h> +#ifdef Q_OS_UNIX +#include <unistd.h> +#else +#include <io.h> +#endif + +using namespace Analyzer; +using namespace ProjectExplorer; +using namespace QmakeProjectManager; + +namespace Ios { +namespace Internal { + +RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runConfig, + QString *errorMessage) +{ + Q_UNUSED(errorMessage); + Target *target = runConfig->target(); + if (!target) + return 0; + ProjectExplorer::IDevice::ConstPtr device = DeviceKitInformation::device(target->kit()); + if (device.isNull()) + return 0; + AnalyzerStartParameters params; + params.runMode = QmlProfilerRunMode; + params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString(); + params.startMode = StartLocal; + params.debuggee = runConfig->exePath().toUserOutput(); + params.debuggeeArgs = Utils::QtcProcess::joinArgs(runConfig->commandLineArguments()); + params.analyzerHost = QLatin1String("localhost"); + if (device->type() == Core::Id(Ios::Constants::IOS_DEVICE_TYPE)) { + IosDevice::ConstPtr iosDevice = device.dynamicCast<const IosDevice>(); + if (iosDevice.isNull()) + return 0; + } + params.displayName = runConfig->appName(); + + AnalyzerRunControl *analyzerRunControl = AnalyzerManager::createRunControl(params, runConfig); + (void) new IosAnalyzeSupport(runConfig, analyzerRunControl, false, true); + return analyzerRunControl; +} + +IosAnalyzeSupport::IosAnalyzeSupport(IosRunConfiguration *runConfig, + AnalyzerRunControl *runControl, bool cppDebug, bool qmlDebug) + : QObject(runControl), m_runControl(runControl), + m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug)) +{ + connect(m_runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)), + m_runner, SLOT(start())); + connect(m_runControl, SIGNAL(finished()), + m_runner, SLOT(stop())); + connect(&m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)), + SLOT(qmlServerReady())); + + connect(m_runner, SIGNAL(gotServerPorts(int,int)), + SLOT(handleServerPorts(int,int))); + connect(m_runner, SIGNAL(gotInferiorPid(Q_PID, int)), + SLOT(handleGotInferiorPid(Q_PID, int))); + connect(m_runner, SIGNAL(finished(bool)), + SLOT(handleRemoteProcessFinished(bool))); + + connect(m_runner, SIGNAL(errorMsg(QString)), + SLOT(handleRemoteErrorOutput(QString))); + connect(m_runner, SIGNAL(appOutput(QString)), + SLOT(handleRemoteOutput(QString))); +} + +IosAnalyzeSupport::~IosAnalyzeSupport() +{ +} + +void IosAnalyzeSupport::qmlServerReady() +{ + m_runControl->notifyRemoteSetupDone(m_qmlPort); +} + +void IosAnalyzeSupport::handleServerPorts(int gdbServerPort, int qmlPort) +{ + Q_UNUSED(gdbServerPort); + m_qmlPort = qmlPort; +} + +void IosAnalyzeSupport::handleGotInferiorPid(Q_PID pid, int qmlPort) +{ + Q_UNUSED(pid); + m_qmlPort = qmlPort; +} + +void IosAnalyzeSupport::handleRemoteProcessFinished(bool cleanEnd) +{ + Q_UNUSED(cleanEnd) + if (m_runControl) { + m_runControl->logApplicationMessage(tr("Run ended."), Utils::NormalMessageFormat); + m_runControl->notifyRemoteFinished(); + } +} + +void IosAnalyzeSupport::handleRemoteOutput(const QString &output) +{ + if (m_runControl) { + m_runControl->logApplicationMessage(output, Utils::StdOutFormat); + m_outputParser.processOutput(output); + } +} + +void IosAnalyzeSupport::handleRemoteErrorOutput(const QString &output) +{ + if (m_runControl) + m_runControl->logApplicationMessage(output, Utils::StdErrFormat); +} + +} // namespace Internal +} // namespace Ios diff --git a/src/plugins/ios/iosanalyzesupport.h b/src/plugins/ios/iosanalyzesupport.h new file mode 100644 index 0000000000..ed363270bb --- /dev/null +++ b/src/plugins/ios/iosanalyzesupport.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#ifndef IOSANALYZESUPPORT_H +#define IOSANALYZESUPPORT_H + +#include "iosrunconfiguration.h" + +#include <qmldebug/qmloutputparser.h> + +#include <QProcess> +#include <QObject> + +namespace Analyzer { class AnalyzerRunControl; } + +namespace Ios { +namespace Internal { + +class IosRunConfiguration; +class IosRunner; + +class IosAnalyzeSupport : public QObject +{ + Q_OBJECT + +public: + static ProjectExplorer::RunControl *createAnalyzeRunControl(IosRunConfiguration *runConfig, + QString *errorMessage); + + IosAnalyzeSupport(IosRunConfiguration *runConfig, + Analyzer::AnalyzerRunControl *runControl, bool cppDebug, bool qmlDebug); + ~IosAnalyzeSupport(); + +private slots: + void qmlServerReady(); + void handleServerPorts(int gdbServerFd, int qmlPort); + void handleGotInferiorPid(Q_PID, int qmlPort); + void handleRemoteProcessFinished(bool cleanEnd); + + void handleRemoteOutput(const QString &output); + void handleRemoteErrorOutput(const QString &output); + +private: + Analyzer::AnalyzerRunControl *m_runControl; + IosRunner * const m_runner; + QmlDebug::QmlOutputParser m_outputParser; + int m_qmlPort; +}; + +} // namespace Internal +} // namespace Ios + +#endif // IOSANALYZESUPPORT_H diff --git a/src/plugins/ios/iosrunfactories.cpp b/src/plugins/ios/iosrunfactories.cpp index 9af86e8e28..c4d8609437 100644 --- a/src/plugins/ios/iosrunfactories.cpp +++ b/src/plugins/ios/iosrunfactories.cpp @@ -34,6 +34,7 @@ #include "iosrunconfiguration.h" #include "iosruncontrol.h" #include "iosmanager.h" +#include "iosanalyzesupport.h" #include <projectexplorer/project.h> #include <projectexplorer/projectexplorerconstants.h> @@ -155,7 +156,8 @@ IosRunControlFactory::IosRunControlFactory(QObject *parent) bool IosRunControlFactory::canRun(RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const { - if (mode != NormalRunMode && mode != DebugRunMode) + if (mode != NormalRunMode && mode != DebugRunMode && mode != QmlProfilerRunMode + && mode != DebugRunModeWithBreakOnMain) return false; return qobject_cast<IosRunConfiguration *>(runConfiguration); } @@ -176,6 +178,8 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, } if (mode == NormalRunMode) res = new Ios::Internal::IosRunControl(rc); + else if (mode == QmlProfilerRunMode) + res = IosAnalyzeSupport::createAnalyzeRunControl(rc, errorMessage); else res = IosDebugSupport::createDebugRunControl(rc, errorMessage); if (devId.isValid()) |