iOS: Adapt to introduction of ProjectExplorer::ToolRunner

Change-Id: I53201edb58485c697c8c56db68ddefd3cf107193
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2017-03-28 18:51:29 +02:00
parent eee51e8c1d
commit 61b6aa5c84
8 changed files with 86 additions and 93 deletions

View File

@@ -34,15 +34,14 @@ using namespace ProjectExplorer;
namespace Ios { namespace Ios {
namespace Internal { namespace Internal {
IosAnalyzeSupport::IosAnalyzeSupport(IosRunConfiguration *runConfig, IosAnalyzeSupport::IosAnalyzeSupport(RunControl *runControl, bool cppDebug, bool qmlDebug)
AnalyzerRunControl *runControl, bool cppDebug, bool qmlDebug) : ToolRunner(runControl),
: QObject(runControl), m_runControl(runControl), m_runner(new IosRunner(this, runControl, cppDebug, qmlDebug ? QmlDebug::QmlProfilerServices :
m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug ? QmlDebug::QmlProfilerServices :
QmlDebug::NoQmlDebugServices)) QmlDebug::NoQmlDebugServices))
{ {
connect(m_runControl, &AnalyzerRunControl::starting, connect(runControl, &RunControl::starting,
m_runner, &IosRunner::start); m_runner, &IosRunner::start);
connect(m_runControl, &RunControl::finished, connect(runControl, &RunControl::finished,
m_runner, &IosRunner::stop); m_runner, &IosRunner::stop);
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
this, &IosAnalyzeSupport::qmlServerReady); this, &IosAnalyzeSupport::qmlServerReady);
@@ -60,13 +59,9 @@ IosAnalyzeSupport::IosAnalyzeSupport(IosRunConfiguration *runConfig,
this, &IosAnalyzeSupport::handleRemoteOutput); this, &IosAnalyzeSupport::handleRemoteOutput);
} }
IosAnalyzeSupport::~IosAnalyzeSupport()
{
}
void IosAnalyzeSupport::qmlServerReady() void IosAnalyzeSupport::qmlServerReady()
{ {
m_runControl->notifyRemoteSetupDone(m_qmlPort); runControl()->notifyRemoteSetupDone(m_qmlPort);
} }
void IosAnalyzeSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port 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) void IosAnalyzeSupport::handleRemoteProcessFinished(bool cleanEnd)
{ {
if (m_runControl) {
if (!cleanEnd) if (!cleanEnd)
m_runControl->appendMessage(tr("Run ended with error."), Utils::ErrorMessageFormat); runControl()->appendMessage(tr("Run ended with error."), Utils::ErrorMessageFormat);
else else
m_runControl->appendMessage(tr("Run ended."), Utils::NormalMessageFormat); appendMessage(tr("Run ended."), Utils::NormalMessageFormat);
m_runControl->notifyRemoteFinished(); runControl()->notifyRemoteFinished();
}
} }
void IosAnalyzeSupport::handleRemoteOutput(const QString &output) void IosAnalyzeSupport::handleRemoteOutput(const QString &output)
{ {
if (m_runControl) { appendMessage(output, Utils::StdOutFormat);
m_runControl->appendMessage(output, Utils::StdOutFormat);
m_outputParser.processOutput(output); m_outputParser.processOutput(output);
} }
}
void IosAnalyzeSupport::handleRemoteErrorOutput(const QString &output) void IosAnalyzeSupport::handleRemoteErrorOutput(const QString &output)
{ {
if (m_runControl) { appendMessage(output, Utils::StdErrFormat);
m_runControl->appendMessage(output, Utils::StdErrFormat);
m_outputParser.processOutput(output); m_outputParser.processOutput(output);
} }
AnalyzerRunControl *IosAnalyzeSupport::runControl()
{
return qobject_cast<AnalyzerRunControl *>(ToolRunner::runControl());
} }
} // namespace Internal } // namespace Internal

View File

@@ -26,9 +26,10 @@
#pragma once #pragma once
#include <qmldebug/qmloutputparser.h> #include <qmldebug/qmloutputparser.h>
#include <utils/port.h>
#include <QObject> #include <projectexplorer/runconfiguration.h>
#include <utils/port.h>
namespace Debugger { class AnalyzerRunControl; } namespace Debugger { class AnalyzerRunControl; }
@@ -38,14 +39,12 @@ namespace Internal {
class IosRunConfiguration; class IosRunConfiguration;
class IosRunner; class IosRunner;
class IosAnalyzeSupport : public QObject class IosAnalyzeSupport : public ProjectExplorer::ToolRunner
{ {
Q_OBJECT Q_OBJECT
public: public:
IosAnalyzeSupport(IosRunConfiguration *runConfig, IosAnalyzeSupport(ProjectExplorer::RunControl *runControl, bool cppDebug, bool qmlDebug);
Debugger::AnalyzerRunControl *runControl, bool cppDebug, bool qmlDebug);
~IosAnalyzeSupport();
private: private:
void qmlServerReady(); void qmlServerReady();
@@ -56,7 +55,7 @@ private:
void handleRemoteOutput(const QString &output); void handleRemoteOutput(const QString &output);
void handleRemoteErrorOutput(const QString &output); void handleRemoteErrorOutput(const QString &output);
Debugger::AnalyzerRunControl *m_runControl; Debugger::AnalyzerRunControl *runControl();
IosRunner * const m_runner; IosRunner * const m_runner;
QmlDebug::QmlOutputParser m_outputParser; QmlDebug::QmlOutputParser m_outputParser;
Utils::Port m_qmlPort; Utils::Port m_qmlPort;

View File

@@ -60,7 +60,7 @@ using namespace ProjectExplorer;
namespace Ios { namespace Ios {
namespace Internal { namespace Internal {
RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfig, RunControl *IosDebugSupport::createDebugRunControl(RunConfiguration *runConfig,
QString *errorMessage) QString *errorMessage)
{ {
Target *target = runConfig->target(); Target *target = runConfig->target();
@@ -104,7 +104,9 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi
params.startMode = AttachExternal; params.startMode = AttachExternal;
params.platform = QLatin1String("ios-simulator"); params.platform = QLatin1String("ios-simulator");
} }
params.displayName = runConfig->applicationName();
auto iosRunConfig = qobject_cast<IosRunConfiguration *>(runConfig);
params.displayName = iosRunConfig->applicationName();
params.remoteSetupNeeded = true; params.remoteSetupNeeded = true;
params.continueAfterAttach = true; params.continueAfterAttach = true;
@@ -112,7 +114,7 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi
bool cppDebug = aspect->useCppDebugger(); bool cppDebug = aspect->useCppDebugger();
bool qmlDebug = aspect->useQmlDebugger(); bool qmlDebug = aspect->useQmlDebugger();
if (cppDebug) { if (cppDebug) {
params.inferior.executable = runConfig->localExecutable().toString(); params.inferior.executable = iosRunConfig->localExecutable().toString();
params.remoteChannel = QLatin1String("connect://localhost:0"); params.remoteChannel = QLatin1String("connect://localhost:0");
Utils::FileName xcodeInfo = IosConfigurations::developerPath().parentDir() 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) if (version.value(0).toInt() == 5 && version.value(1, QString::number(1)).toInt() == 0)
buggyLldb = true; buggyLldb = true;
} }
QString bundlePath = runConfig->bundleDirectory().toString(); QString bundlePath = iosRunConfig->bundleDirectory().toString();
bundlePath.chop(4); bundlePath.chop(4);
Utils::FileName dsymPath = Utils::FileName::fromString( Utils::FileName dsymPath = Utils::FileName::fromString(
bundlePath.append(QLatin1String(".dSYM"))); bundlePath.append(QLatin1String(".dSYM")));
@@ -136,7 +138,7 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi
"To create one, add a dsymutil deploystep."), "To create one, add a dsymutil deploystep."),
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT); ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
} else if (dsymPath.toFileInfo().lastModified() } else if (dsymPath.toFileInfo().lastModified()
< QFileInfo(runConfig->localExecutable().toUserOutput()).lastModified()) { < QFileInfo(iosRunConfig->localExecutable().toUserOutput()).lastModified()) {
TaskHub::addTask(Task::Warning, TaskHub::addTask(Task::Warning,
tr("The dSYM %1 seems to be outdated, it might confuse the debugger.") tr("The dSYM %1 seems to be outdated, it might confuse the debugger.")
.arg(dsymPath.toUserOutput()), .arg(dsymPath.toUserOutput()),
@@ -153,21 +155,20 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi
params.startMode = AttachToRemoteServer; params.startMode = AttachToRemoteServer;
} }
DebuggerRunControl *debuggerRunControl = createDebuggerRunControl(params, runConfig, errorMessage); RunControl *runControl = createDebuggerRunControl(params, runConfig, errorMessage);
if (debuggerRunControl) if (runControl)
new IosDebugSupport(runConfig, debuggerRunControl, cppDebug, qmlDebug); new IosDebugSupport(runControl, cppDebug, qmlDebug);
return debuggerRunControl; return runControl;
} }
IosDebugSupport::IosDebugSupport(IosRunConfiguration *runConfig, IosDebugSupport::IosDebugSupport(RunControl *runControl, bool cppDebug, bool qmlDebug)
DebuggerRunControl *runControl, bool cppDebug, bool qmlDebug) : ToolRunner(runControl),
: QObject(runControl), m_runControl(runControl), m_runner(new IosRunner(this, runControl, cppDebug,
m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug ? QmlDebug::QmlDebuggerServices : qmlDebug ? QmlDebug::QmlDebuggerServices : QmlDebug::NoQmlDebugServices))
QmlDebug::NoQmlDebugServices))
{ {
connect(m_runControl, &DebuggerRunControl::requestRemoteSetup, connect(this->runControl(), &DebuggerRunControl::requestRemoteSetup,
m_runner, &IosRunner::start); m_runner, &IosRunner::start);
connect(m_runControl, &RunControl::finished, connect(runControl, &RunControl::finished,
m_runner, &IosRunner::stop); m_runner, &IosRunner::stop);
connect(m_runner, &IosRunner::gotServerPorts, connect(m_runner, &IosRunner::gotServerPorts,
@@ -183,10 +184,6 @@ IosDebugSupport::IosDebugSupport(IosRunConfiguration *runConfig,
this, &IosDebugSupport::handleRemoteOutput); this, &IosDebugSupport::handleRemoteOutput);
} }
IosDebugSupport::~IosDebugSupport()
{
}
void IosDebugSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort) void IosDebugSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort)
{ {
RemoteSetupResult result; RemoteSetupResult result;
@@ -196,7 +193,7 @@ void IosDebugSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port q
|| (m_runner && !m_runner->cppDebug() && qmlPort.isValid()); || (m_runner && !m_runner->cppDebug() && qmlPort.isValid());
if (!result.success) if (!result.success)
result.reason = tr("Could not get debug server file descriptor."); 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) void IosDebugSupport::handleGotInferiorPid(qint64 pid, Utils::Port qmlPort)
@@ -207,30 +204,31 @@ void IosDebugSupport::handleGotInferiorPid(qint64 pid, Utils::Port qmlPort)
result.success = pid > 0; result.success = pid > 0;
if (!result.success) if (!result.success)
result.reason = tr("Got an invalid process id."); result.reason = tr("Got an invalid process id.");
m_runControl->notifyEngineRemoteSetupFinished(result); runControl()->notifyEngineRemoteSetupFinished(result);
} }
void IosDebugSupport::handleRemoteProcessFinished(bool cleanEnd) void IosDebugSupport::handleRemoteProcessFinished(bool cleanEnd)
{ {
if (m_runControl) {
if (!cleanEnd) if (!cleanEnd)
m_runControl->appendMessage(tr("Run ended with error."), Utils::DebugFormat); appendMessage(tr("Run ended with error."), Utils::DebugFormat);
else else
m_runControl->appendMessage(tr("Run ended."), Utils::DebugFormat); appendMessage(tr("Run ended."), Utils::DebugFormat);
m_runControl->abortDebugger(); runControl()->abortDebugger();
}
} }
void IosDebugSupport::handleRemoteOutput(const QString &output) void IosDebugSupport::handleRemoteOutput(const QString &output)
{ {
if (m_runControl) runControl()->showMessage(output, AppOutput);
m_runControl->showMessage(output, AppOutput);
} }
void IosDebugSupport::handleRemoteErrorOutput(const QString &output) void IosDebugSupport::handleRemoteErrorOutput(const QString &output)
{ {
if (m_runControl) runControl()->showMessage(output, AppError);
m_runControl->showMessage(output, AppError); }
DebuggerRunControl *IosDebugSupport::runControl()
{
return qobject_cast<DebuggerRunControl *>(ToolRunner::runControl()) ;
} }
} // namespace Internal } // namespace Internal

View File

@@ -26,7 +26,8 @@
#pragma once #pragma once
#include "iosrunconfiguration.h" #include "iosrunconfiguration.h"
#include <QProcess>
#include <projectexplorer/runconfiguration.h>
namespace Debugger { class DebuggerRunControl; } namespace Debugger { class DebuggerRunControl; }
namespace ProjectExplorer { class RunControl; } namespace ProjectExplorer { class RunControl; }
@@ -37,17 +38,15 @@ namespace Internal {
class IosRunConfiguration; class IosRunConfiguration;
class IosRunner; class IosRunner;
class IosDebugSupport : public QObject class IosDebugSupport : public ProjectExplorer::ToolRunner
{ {
Q_OBJECT Q_OBJECT
public: public:
static ProjectExplorer::RunControl *createDebugRunControl(IosRunConfiguration *runConfig, static ProjectExplorer::RunControl *createDebugRunControl(ProjectExplorer::RunConfiguration *runConfig,
QString *errorMessage); QString *errorMessage);
IosDebugSupport(IosRunConfiguration *runConfig, IosDebugSupport(ProjectExplorer::RunControl *runControl, bool cppDebug, bool qmlDebug);
Debugger::DebuggerRunControl *runControl, bool cppDebug, bool qmlDebug);
~IosDebugSupport();
private: private:
void handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort); void handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort);
@@ -57,7 +56,8 @@ private:
void handleRemoteOutput(const QString &output); void handleRemoteOutput(const QString &output);
void handleRemoteErrorOutput(const QString &output); void handleRemoteErrorOutput(const QString &output);
Debugger::DebuggerRunControl *m_runControl; Debugger::DebuggerRunControl *runControl();
IosRunner * const m_runner; IosRunner * const m_runner;
const QString m_dumperLib; const QString m_dumperLib;
}; };

View File

@@ -39,7 +39,7 @@ namespace Internal {
IosRunControl::IosRunControl(IosRunConfiguration *rc) IosRunControl::IosRunControl(IosRunConfiguration *rc)
: RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE) : 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); setIcon(Utils::Icons::RUN_SMALL_TOOLBAR);
} }

View File

@@ -199,7 +199,7 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig,
runControl->setRunnable(runnable); runControl->setRunnable(runnable);
runControl->setConnection(connection); runControl->setConnection(connection);
runControl->setDisplayName(iosRunConfig->applicationName()); runControl->setDisplayName(iosRunConfig->applicationName());
(void) new IosAnalyzeSupport(iosRunConfig, runControl, false, true); (void) new IosAnalyzeSupport(runControl, false, true);
return runControl; return runControl;
} }
else else

View File

@@ -51,14 +51,15 @@ using namespace ProjectExplorer;
namespace Ios { namespace Ios {
namespace Internal { namespace Internal {
IosRunner::IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool cppDebug, IosRunner::IosRunner(QObject *parent, RunControl *runControl, bool cppDebug,
QmlDebug::QmlDebugServicesPreset qmlDebugServices) QmlDebug::QmlDebugServicesPreset qmlDebugServices)
: QObject(parent), m_toolHandler(0), m_bundleDir(runConfig->bundleDirectory().toString()), : QObject(parent),
m_arguments(runConfig->commandLineArguments()), m_cppDebug(cppDebug), m_qmlDebugServices(qmlDebugServices)
m_device(DeviceKitInformation::device(runConfig->target()->kit())),
m_cppDebug(cppDebug), m_qmlDebugServices(qmlDebugServices), m_cleanExit(false),
m_pid(0)
{ {
auto runConfig = qobject_cast<IosRunConfiguration *>(runControl->runConfiguration());
m_bundleDir = runConfig->bundleDirectory().toString();
m_arguments = QStringList(runConfig->commandLineArguments());
m_device = DeviceKitInformation::device(runConfig->target()->kit());
m_deviceType = runConfig->deviceType(); m_deviceType = runConfig->deviceType();
} }

View File

@@ -30,10 +30,12 @@
#include "iossimulator.h" #include "iossimulator.h"
#include <debugger/debuggerconstants.h> #include <debugger/debuggerconstants.h>
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/runconfiguration.h>
#include <qmldebug/qmldebugcommandlinearguments.h> #include <qmldebug/qmldebugcommandlinearguments.h>
#include <QObject>
#include <QTimer> #include <QTimer>
#include <QThread> #include <QThread>
#include <QProcess> #include <QProcess>
@@ -42,14 +44,13 @@
namespace Ios { namespace Ios {
namespace Internal { namespace Internal {
class IosRunConfiguration;
class IosRunner : public QObject class IosRunner : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool cppDebug, IosRunner(QObject *parent, ProjectExplorer::RunControl *runControl,
bool cppDebug,
QmlDebug::QmlDebugServicesPreset qmlDebugServices); QmlDebug::QmlDebugServicesPreset qmlDebugServices);
~IosRunner(); ~IosRunner();
@@ -85,7 +86,7 @@ private:
void handleToolExited(Ios::IosToolHandler *handler, int code); void handleToolExited(Ios::IosToolHandler *handler, int code);
void handleFinished(Ios::IosToolHandler *handler); void handleFinished(Ios::IosToolHandler *handler);
IosToolHandler *m_toolHandler; IosToolHandler *m_toolHandler = nullptr;
QString m_bundleDir; QString m_bundleDir;
QStringList m_arguments; QStringList m_arguments;
ProjectExplorer::IDevice::ConstPtr m_device; ProjectExplorer::IDevice::ConstPtr m_device;
@@ -93,9 +94,9 @@ private:
bool m_cppDebug; bool m_cppDebug;
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices; QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
bool m_cleanExit; bool m_cleanExit = false;
Utils::Port m_qmlPort; Utils::Port m_qmlPort;
qint64 m_pid; qint64 m_pid = 0;
}; };
} // namespace Internal } // namespace Internal