From 03acd1fbf3748d02ac0f640053df6c8df964db7f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 19 Apr 2016 16:51:30 +0200 Subject: [PATCH] RemoteLinux: Prepare for other kinds of analyzers Rename the "GatheringPorts" stage to the more generic "GatheringResources", and don't do it by default on handleRemoteSetupRequested(). Also, drop a few asserts that tested specifically for QML Profiler. Change-Id: I53c3182d237f53e6dda20cd1c856e7e5f951e90e Reviewed-by: Christian Kandeler --- .../abstractremotelinuxrunsupport.cpp | 30 ++++++++-------- .../abstractremotelinuxrunsupport.h | 10 +++--- .../remotelinux/remotelinuxanalyzesupport.cpp | 34 ++++++++++--------- .../remotelinux/remotelinuxdebugsupport.cpp | 6 ++-- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp b/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp index 5277e73841a..3e6b966ad19 100644 --- a/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp @@ -83,26 +83,15 @@ AbstractRemoteLinuxRunSupport::State AbstractRemoteLinuxRunSupport::state() cons return d->state; } -void AbstractRemoteLinuxRunSupport::handleRemoteSetupRequested() +void AbstractRemoteLinuxRunSupport::handleResourcesError(const QString &message) { - QTC_ASSERT(d->state == Inactive, return); - d->state = GatheringPorts; - connect(&d->portsGatherer, &DeviceUsedPortsGatherer::error, - this, &AbstractRemoteLinuxRunSupport::handlePortsGathererError); - connect(&d->portsGatherer, &DeviceUsedPortsGatherer::portListReady, - this, &AbstractRemoteLinuxRunSupport::handlePortListReady); - d->portsGatherer.start(d->device); -} - -void AbstractRemoteLinuxRunSupport::handlePortsGathererError(const QString &message) -{ - QTC_ASSERT(d->state == GatheringPorts, return); + QTC_ASSERT(d->state == GatheringResources, return); handleAdapterSetupFailed(message); } -void AbstractRemoteLinuxRunSupport::handlePortListReady() +void AbstractRemoteLinuxRunSupport::handleResourcesAvailable() { - QTC_ASSERT(d->state == GatheringPorts, return); + QTC_ASSERT(d->state == GatheringResources, return); d->portList = d->device->freePorts(); startExecution(); @@ -138,6 +127,17 @@ bool AbstractRemoteLinuxRunSupport::setPort(Utils::Port &port) return true; } +void AbstractRemoteLinuxRunSupport::startPortsGathering() +{ + QTC_ASSERT(d->state == Inactive, return); + d->state = GatheringResources; + connect(&d->portsGatherer, &DeviceUsedPortsGatherer::error, + this, &AbstractRemoteLinuxRunSupport::handleResourcesError); + connect(&d->portsGatherer, &DeviceUsedPortsGatherer::portListReady, + this, &AbstractRemoteLinuxRunSupport::handleResourcesAvailable); + d->portsGatherer.start(d->device); +} + const IDevice::ConstPtr AbstractRemoteLinuxRunSupport::device() const { return d->device; diff --git a/src/plugins/remotelinux/abstractremotelinuxrunsupport.h b/src/plugins/remotelinux/abstractremotelinuxrunsupport.h index 71745b5f3e6..4678179ef0c 100644 --- a/src/plugins/remotelinux/abstractremotelinuxrunsupport.h +++ b/src/plugins/remotelinux/abstractremotelinuxrunsupport.h @@ -49,7 +49,7 @@ protected: enum State { Inactive, - GatheringPorts, + GatheringResources, StartingRunner, Running }; @@ -71,13 +71,15 @@ protected: void setFinished(); bool setPort(Utils::Port &port); + void startPortsGathering(); + const ProjectExplorer::IDevice::ConstPtr device() const; const ProjectExplorer::StandardRunnable &runnable() const; void reset(); protected slots: - virtual void handleRemoteSetupRequested(); + virtual void handleRemoteSetupRequested() = 0; virtual void handleAppRunnerError(const QString &error) = 0; virtual void handleRemoteOutput(const QByteArray &output) = 0; virtual void handleRemoteErrorOutput(const QByteArray &output) = 0; @@ -85,8 +87,8 @@ protected slots: virtual void handleProgressReport(const QString &progressOutput) = 0; private slots: - void handlePortsGathererError(const QString &message); - void handlePortListReady(); + void handleResourcesError(const QString &message); + void handleResourcesAvailable(); private: friend class Internal::AbstractRemoteLinuxRunSupportPrivate; diff --git a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp index a1d963786e3..996f5bc298c 100644 --- a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp +++ b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp @@ -57,12 +57,12 @@ class RemoteLinuxAnalyzeSupportPrivate public: RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, Core::Id runMode) : runControl(rc), - qmlProfiling(runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) + runMode(runMode) { } const QPointer runControl; - bool qmlProfiling; + Core::Id runMode; Utils::Port qmlPort; QmlDebug::QmlOutputParser outputParser; @@ -101,18 +101,18 @@ void RemoteLinuxAnalyzeSupport::handleRemoteSetupRequested() { QTC_ASSERT(state() == Inactive, return); - showMessage(tr("Checking available ports...") + QLatin1Char('\n'), Utils::NormalMessageFormat); - AbstractRemoteLinuxRunSupport::handleRemoteSetupRequested(); + if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { + showMessage(tr("Checking available ports...") + QLatin1Char('\n'), + Utils::NormalMessageFormat); + startPortsGathering(); + } } void RemoteLinuxAnalyzeSupport::startExecution() { - QTC_ASSERT(state() == GatheringPorts, return); + QTC_ASSERT(state() == GatheringResources, return); - // Currently we support only QML profiling - QTC_ASSERT(d->qmlProfiling, return); - - if (!setPort(d->qmlPort)) + if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE && !setPort(d->qmlPort)) return; setState(StartingRunner); @@ -132,11 +132,14 @@ void RemoteLinuxAnalyzeSupport::startExecution() this, &RemoteLinuxAnalyzeSupport::handleAppRunnerError); auto r = runnable(); - if (!r.commandLineArguments.isEmpty()) - r.commandLineArguments.append(QLatin1Char(' ')); - r.commandLineArguments += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, - d->qmlPort); - runner->start(device(), r); + + if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { + if (!r.commandLineArguments.isEmpty()) + r.commandLineArguments.append(QLatin1Char(' ')); + r.commandLineArguments += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, + d->qmlPort); + runner->start(device(), r); + } } void RemoteLinuxAnalyzeSupport::handleAppRunnerError(const QString &error) @@ -175,7 +178,7 @@ void RemoteLinuxAnalyzeSupport::handleRemoteOutput(const QByteArray &output) void RemoteLinuxAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output) { - QTC_ASSERT(state() != GatheringPorts, return); + QTC_ASSERT(state() != GatheringResources, return); if (!d->runControl) return; @@ -196,7 +199,6 @@ void RemoteLinuxAnalyzeSupport::handleAdapterSetupFailed(const QString &error) void RemoteLinuxAnalyzeSupport::handleRemoteProcessStarted() { - QTC_ASSERT(d->qmlProfiling, return); QTC_ASSERT(state() == StartingRunner, return); handleAdapterSetupDone(); diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp index 9981efbe278..18ad5493bd0 100644 --- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp @@ -103,12 +103,12 @@ void LinuxDeviceDebugSupport::handleRemoteSetupRequested() QTC_ASSERT(state() == Inactive, return); showMessage(tr("Checking available ports...") + QLatin1Char('\n'), LogStatus); - AbstractRemoteLinuxRunSupport::handleRemoteSetupRequested(); + startPortsGathering(); } void LinuxDeviceDebugSupport::startExecution() { - QTC_ASSERT(state() == GatheringPorts, return); + QTC_ASSERT(state() == GatheringResources, return); if (d->cppDebugging && !setPort(d->gdbServerPort)) return; @@ -202,7 +202,7 @@ void LinuxDeviceDebugSupport::handleRemoteOutput(const QByteArray &output) void LinuxDeviceDebugSupport::handleRemoteErrorOutput(const QByteArray &output) { - QTC_ASSERT(state() != GatheringPorts, return); + QTC_ASSERT(state() != GatheringResources, return); if (!d->runControl) return;