From 61b6aa5c843481aeff012048c09710170dfa75ad Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 28 Mar 2017 18:51:29 +0200 Subject: [PATCH] iOS: Adapt to introduction of ProjectExplorer::ToolRunner Change-Id: I53201edb58485c697c8c56db68ddefd3cf107193 Reviewed-by: Vikas Pachdha Reviewed-by: hjk --- src/plugins/ios/iosanalyzesupport.cpp | 46 ++++++++--------- src/plugins/ios/iosanalyzesupport.h | 13 +++-- src/plugins/ios/iosdebugsupport.cpp | 74 +++++++++++++-------------- src/plugins/ios/iosdebugsupport.h | 14 ++--- src/plugins/ios/iosruncontrol.cpp | 2 +- src/plugins/ios/iosrunfactories.cpp | 2 +- src/plugins/ios/iosrunner.cpp | 13 ++--- src/plugins/ios/iosrunner.h | 15 +++--- 8 files changed, 86 insertions(+), 93 deletions(-) diff --git a/src/plugins/ios/iosanalyzesupport.cpp b/src/plugins/ios/iosanalyzesupport.cpp index 7f04ece41c8..eb009e3e7b8 100644 --- a/src/plugins/ios/iosanalyzesupport.cpp +++ b/src/plugins/ios/iosanalyzesupport.cpp @@ -34,15 +34,14 @@ using namespace ProjectExplorer; namespace Ios { namespace Internal { -IosAnalyzeSupport::IosAnalyzeSupport(IosRunConfiguration *runConfig, - AnalyzerRunControl *runControl, bool cppDebug, bool qmlDebug) - : QObject(runControl), m_runControl(runControl), - m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug ? QmlDebug::QmlProfilerServices : +IosAnalyzeSupport::IosAnalyzeSupport(RunControl *runControl, bool cppDebug, bool qmlDebug) + : ToolRunner(runControl), + m_runner(new IosRunner(this, runControl, cppDebug, qmlDebug ? QmlDebug::QmlProfilerServices : QmlDebug::NoQmlDebugServices)) { - connect(m_runControl, &AnalyzerRunControl::starting, + connect(runControl, &RunControl::starting, m_runner, &IosRunner::start); - connect(m_runControl, &RunControl::finished, + connect(runControl, &RunControl::finished, m_runner, &IosRunner::stop); connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, this, &IosAnalyzeSupport::qmlServerReady); @@ -60,13 +59,9 @@ IosAnalyzeSupport::IosAnalyzeSupport(IosRunConfiguration *runConfig, this, &IosAnalyzeSupport::handleRemoteOutput); } -IosAnalyzeSupport::~IosAnalyzeSupport() -{ -} - void IosAnalyzeSupport::qmlServerReady() { - m_runControl->notifyRemoteSetupDone(m_qmlPort); + runControl()->notifyRemoteSetupDone(m_qmlPort); } void IosAnalyzeSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort) @@ -83,29 +78,28 @@ void IosAnalyzeSupport::handleGotInferiorPid(qint64 pid, Utils::Port qmlPort) void IosAnalyzeSupport::handleRemoteProcessFinished(bool cleanEnd) { - if (m_runControl) { - if (!cleanEnd) - m_runControl->appendMessage(tr("Run ended with error."), Utils::ErrorMessageFormat); - else - m_runControl->appendMessage(tr("Run ended."), Utils::NormalMessageFormat); - m_runControl->notifyRemoteFinished(); - } + if (!cleanEnd) + runControl()->appendMessage(tr("Run ended with error."), Utils::ErrorMessageFormat); + else + appendMessage(tr("Run ended."), Utils::NormalMessageFormat); + runControl()->notifyRemoteFinished(); } void IosAnalyzeSupport::handleRemoteOutput(const QString &output) { - if (m_runControl) { - m_runControl->appendMessage(output, Utils::StdOutFormat); - m_outputParser.processOutput(output); - } + appendMessage(output, Utils::StdOutFormat); + m_outputParser.processOutput(output); } void IosAnalyzeSupport::handleRemoteErrorOutput(const QString &output) { - if (m_runControl) { - m_runControl->appendMessage(output, Utils::StdErrFormat); - m_outputParser.processOutput(output); - } + appendMessage(output, Utils::StdErrFormat); + m_outputParser.processOutput(output); +} + +AnalyzerRunControl *IosAnalyzeSupport::runControl() +{ + return qobject_cast(ToolRunner::runControl()); } } // namespace Internal diff --git a/src/plugins/ios/iosanalyzesupport.h b/src/plugins/ios/iosanalyzesupport.h index fa63ae6beeb..8beec305716 100644 --- a/src/plugins/ios/iosanalyzesupport.h +++ b/src/plugins/ios/iosanalyzesupport.h @@ -26,9 +26,10 @@ #pragma once #include -#include -#include +#include + +#include namespace Debugger { class AnalyzerRunControl; } @@ -38,14 +39,12 @@ namespace Internal { class IosRunConfiguration; class IosRunner; -class IosAnalyzeSupport : public QObject +class IosAnalyzeSupport : public ProjectExplorer::ToolRunner { Q_OBJECT public: - IosAnalyzeSupport(IosRunConfiguration *runConfig, - Debugger::AnalyzerRunControl *runControl, bool cppDebug, bool qmlDebug); - ~IosAnalyzeSupport(); + IosAnalyzeSupport(ProjectExplorer::RunControl *runControl, bool cppDebug, bool qmlDebug); private: void qmlServerReady(); @@ -56,7 +55,7 @@ private: void handleRemoteOutput(const QString &output); void handleRemoteErrorOutput(const QString &output); - Debugger::AnalyzerRunControl *m_runControl; + Debugger::AnalyzerRunControl *runControl(); IosRunner * const m_runner; QmlDebug::QmlOutputParser m_outputParser; Utils::Port m_qmlPort; diff --git a/src/plugins/ios/iosdebugsupport.cpp b/src/plugins/ios/iosdebugsupport.cpp index b715ab0b29b..5e41e2459d7 100644 --- a/src/plugins/ios/iosdebugsupport.cpp +++ b/src/plugins/ios/iosdebugsupport.cpp @@ -60,7 +60,7 @@ using namespace ProjectExplorer; namespace Ios { namespace Internal { -RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfig, +RunControl *IosDebugSupport::createDebugRunControl(RunConfiguration *runConfig, QString *errorMessage) { Target *target = runConfig->target(); @@ -104,7 +104,9 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi params.startMode = AttachExternal; params.platform = QLatin1String("ios-simulator"); } - params.displayName = runConfig->applicationName(); + + auto iosRunConfig = qobject_cast(runConfig); + params.displayName = iosRunConfig->applicationName(); params.remoteSetupNeeded = true; params.continueAfterAttach = true; @@ -112,7 +114,7 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi bool cppDebug = aspect->useCppDebugger(); bool qmlDebug = aspect->useQmlDebugger(); if (cppDebug) { - params.inferior.executable = runConfig->localExecutable().toString(); + params.inferior.executable = iosRunConfig->localExecutable().toString(); params.remoteChannel = QLatin1String("connect://localhost:0"); Utils::FileName xcodeInfo = IosConfigurations::developerPath().parentDir() @@ -125,7 +127,7 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi if (version.value(0).toInt() == 5 && version.value(1, QString::number(1)).toInt() == 0) buggyLldb = true; } - QString bundlePath = runConfig->bundleDirectory().toString(); + QString bundlePath = iosRunConfig->bundleDirectory().toString(); bundlePath.chop(4); Utils::FileName dsymPath = Utils::FileName::fromString( bundlePath.append(QLatin1String(".dSYM"))); @@ -136,7 +138,7 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi "To create one, add a dsymutil deploystep."), ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT); } else if (dsymPath.toFileInfo().lastModified() - < QFileInfo(runConfig->localExecutable().toUserOutput()).lastModified()) { + < QFileInfo(iosRunConfig->localExecutable().toUserOutput()).lastModified()) { TaskHub::addTask(Task::Warning, tr("The dSYM %1 seems to be outdated, it might confuse the debugger.") .arg(dsymPath.toUserOutput()), @@ -153,38 +155,33 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi params.startMode = AttachToRemoteServer; } - DebuggerRunControl *debuggerRunControl = createDebuggerRunControl(params, runConfig, errorMessage); - if (debuggerRunControl) - new IosDebugSupport(runConfig, debuggerRunControl, cppDebug, qmlDebug); - return debuggerRunControl; + RunControl *runControl = createDebuggerRunControl(params, runConfig, errorMessage); + if (runControl) + new IosDebugSupport(runControl, cppDebug, qmlDebug); + return runControl; } -IosDebugSupport::IosDebugSupport(IosRunConfiguration *runConfig, - DebuggerRunControl *runControl, bool cppDebug, bool qmlDebug) - : QObject(runControl), m_runControl(runControl), - m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug ? QmlDebug::QmlDebuggerServices : - QmlDebug::NoQmlDebugServices)) +IosDebugSupport::IosDebugSupport(RunControl *runControl, bool cppDebug, bool qmlDebug) + : ToolRunner(runControl), + m_runner(new IosRunner(this, runControl, cppDebug, + qmlDebug ? QmlDebug::QmlDebuggerServices : QmlDebug::NoQmlDebugServices)) { - connect(m_runControl, &DebuggerRunControl::requestRemoteSetup, + connect(this->runControl(), &DebuggerRunControl::requestRemoteSetup, m_runner, &IosRunner::start); - connect(m_runControl, &RunControl::finished, + connect(runControl, &RunControl::finished, m_runner, &IosRunner::stop); connect(m_runner, &IosRunner::gotServerPorts, - this, &IosDebugSupport::handleServerPorts); + this, &IosDebugSupport::handleServerPorts); connect(m_runner, &IosRunner::gotInferiorPid, - this, &IosDebugSupport::handleGotInferiorPid); + this, &IosDebugSupport::handleGotInferiorPid); connect(m_runner, &IosRunner::finished, - this, &IosDebugSupport::handleRemoteProcessFinished); + this, &IosDebugSupport::handleRemoteProcessFinished); connect(m_runner, &IosRunner::errorMsg, - this, &IosDebugSupport::handleRemoteErrorOutput); + this, &IosDebugSupport::handleRemoteErrorOutput); connect(m_runner, &IosRunner::appOutput, - this, &IosDebugSupport::handleRemoteOutput); -} - -IosDebugSupport::~IosDebugSupport() -{ + this, &IosDebugSupport::handleRemoteOutput); } void IosDebugSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort) @@ -196,7 +193,7 @@ void IosDebugSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port q || (m_runner && !m_runner->cppDebug() && qmlPort.isValid()); if (!result.success) result.reason = tr("Could not get debug server file descriptor."); - m_runControl->notifyEngineRemoteSetupFinished(result); + runControl()->notifyEngineRemoteSetupFinished(result); } void IosDebugSupport::handleGotInferiorPid(qint64 pid, Utils::Port qmlPort) @@ -207,30 +204,31 @@ void IosDebugSupport::handleGotInferiorPid(qint64 pid, Utils::Port qmlPort) result.success = pid > 0; if (!result.success) result.reason = tr("Got an invalid process id."); - m_runControl->notifyEngineRemoteSetupFinished(result); + runControl()->notifyEngineRemoteSetupFinished(result); } void IosDebugSupport::handleRemoteProcessFinished(bool cleanEnd) { - if (m_runControl) { - if (!cleanEnd) - m_runControl->appendMessage(tr("Run ended with error."), Utils::DebugFormat); - else - m_runControl->appendMessage(tr("Run ended."), Utils::DebugFormat); - m_runControl->abortDebugger(); - } + if (!cleanEnd) + appendMessage(tr("Run ended with error."), Utils::DebugFormat); + else + appendMessage(tr("Run ended."), Utils::DebugFormat); + runControl()->abortDebugger(); } void IosDebugSupport::handleRemoteOutput(const QString &output) { - if (m_runControl) - m_runControl->showMessage(output, AppOutput); + runControl()->showMessage(output, AppOutput); } void IosDebugSupport::handleRemoteErrorOutput(const QString &output) { - if (m_runControl) - m_runControl->showMessage(output, AppError); + runControl()->showMessage(output, AppError); +} + +DebuggerRunControl *IosDebugSupport::runControl() +{ + return qobject_cast(ToolRunner::runControl()) ; } } // namespace Internal diff --git a/src/plugins/ios/iosdebugsupport.h b/src/plugins/ios/iosdebugsupport.h index 1d9560cd465..24648cf4e5c 100644 --- a/src/plugins/ios/iosdebugsupport.h +++ b/src/plugins/ios/iosdebugsupport.h @@ -26,7 +26,8 @@ #pragma once #include "iosrunconfiguration.h" -#include + +#include namespace Debugger { class DebuggerRunControl; } namespace ProjectExplorer { class RunControl; } @@ -37,17 +38,15 @@ namespace Internal { class IosRunConfiguration; class IosRunner; -class IosDebugSupport : public QObject +class IosDebugSupport : public ProjectExplorer::ToolRunner { Q_OBJECT public: - static ProjectExplorer::RunControl *createDebugRunControl(IosRunConfiguration *runConfig, + static ProjectExplorer::RunControl *createDebugRunControl(ProjectExplorer::RunConfiguration *runConfig, QString *errorMessage); - IosDebugSupport(IosRunConfiguration *runConfig, - Debugger::DebuggerRunControl *runControl, bool cppDebug, bool qmlDebug); - ~IosDebugSupport(); + IosDebugSupport(ProjectExplorer::RunControl *runControl, bool cppDebug, bool qmlDebug); private: void handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort); @@ -57,7 +56,8 @@ private: void handleRemoteOutput(const QString &output); void handleRemoteErrorOutput(const QString &output); - Debugger::DebuggerRunControl *m_runControl; + Debugger::DebuggerRunControl *runControl(); + IosRunner * const m_runner; const QString m_dumperLib; }; diff --git a/src/plugins/ios/iosruncontrol.cpp b/src/plugins/ios/iosruncontrol.cpp index 30311f1300c..d181edee425 100644 --- a/src/plugins/ios/iosruncontrol.cpp +++ b/src/plugins/ios/iosruncontrol.cpp @@ -39,7 +39,7 @@ namespace Internal { IosRunControl::IosRunControl(IosRunConfiguration *rc) : RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE) - , m_runner(new IosRunner(this, rc, false, QmlDebug::NoQmlDebugServices)) + , m_runner(new IosRunner(this, this, false, QmlDebug::NoQmlDebugServices)) { setIcon(Utils::Icons::RUN_SMALL_TOOLBAR); } diff --git a/src/plugins/ios/iosrunfactories.cpp b/src/plugins/ios/iosrunfactories.cpp index 9df208f8c2b..ba4943ae0a1 100644 --- a/src/plugins/ios/iosrunfactories.cpp +++ b/src/plugins/ios/iosrunfactories.cpp @@ -199,7 +199,7 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, runControl->setRunnable(runnable); runControl->setConnection(connection); runControl->setDisplayName(iosRunConfig->applicationName()); - (void) new IosAnalyzeSupport(iosRunConfig, runControl, false, true); + (void) new IosAnalyzeSupport(runControl, false, true); return runControl; } else diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index d978fd58405..c82183dfbe9 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -51,14 +51,15 @@ using namespace ProjectExplorer; namespace Ios { namespace Internal { -IosRunner::IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool cppDebug, +IosRunner::IosRunner(QObject *parent, RunControl *runControl, 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_qmlDebugServices(qmlDebugServices), m_cleanExit(false), - m_pid(0) + : QObject(parent), + m_cppDebug(cppDebug), m_qmlDebugServices(qmlDebugServices) { + auto runConfig = qobject_cast(runControl->runConfiguration()); + m_bundleDir = runConfig->bundleDirectory().toString(); + m_arguments = QStringList(runConfig->commandLineArguments()); + m_device = DeviceKitInformation::device(runConfig->target()->kit()); m_deviceType = runConfig->deviceType(); } diff --git a/src/plugins/ios/iosrunner.h b/src/plugins/ios/iosrunner.h index 2d41ff45457..315d9a5a274 100644 --- a/src/plugins/ios/iosrunner.h +++ b/src/plugins/ios/iosrunner.h @@ -30,10 +30,12 @@ #include "iossimulator.h" #include + #include +#include + #include -#include #include #include #include @@ -42,14 +44,13 @@ namespace Ios { namespace Internal { -class IosRunConfiguration; - class IosRunner : public QObject { Q_OBJECT public: - IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool cppDebug, + IosRunner(QObject *parent, ProjectExplorer::RunControl *runControl, + bool cppDebug, QmlDebug::QmlDebugServicesPreset qmlDebugServices); ~IosRunner(); @@ -85,7 +86,7 @@ private: void handleToolExited(Ios::IosToolHandler *handler, int code); void handleFinished(Ios::IosToolHandler *handler); - IosToolHandler *m_toolHandler; + IosToolHandler *m_toolHandler = nullptr; QString m_bundleDir; QStringList m_arguments; ProjectExplorer::IDevice::ConstPtr m_device; @@ -93,9 +94,9 @@ private: bool m_cppDebug; QmlDebug::QmlDebugServicesPreset m_qmlDebugServices; - bool m_cleanExit; + bool m_cleanExit = false; Utils::Port m_qmlPort; - qint64 m_pid; + qint64 m_pid = 0; }; } // namespace Internal