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 <christian.kandeler@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2016-04-19 16:51:30 +02:00
parent d4f5cab923
commit 03acd1fbf3
4 changed files with 42 additions and 38 deletions

View File

@@ -83,26 +83,15 @@ AbstractRemoteLinuxRunSupport::State AbstractRemoteLinuxRunSupport::state() cons
return d->state; return d->state;
} }
void AbstractRemoteLinuxRunSupport::handleRemoteSetupRequested() void AbstractRemoteLinuxRunSupport::handleResourcesError(const QString &message)
{ {
QTC_ASSERT(d->state == Inactive, return); QTC_ASSERT(d->state == GatheringResources, 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);
handleAdapterSetupFailed(message); 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(); d->portList = d->device->freePorts();
startExecution(); startExecution();
@@ -138,6 +127,17 @@ bool AbstractRemoteLinuxRunSupport::setPort(Utils::Port &port)
return true; 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 const IDevice::ConstPtr AbstractRemoteLinuxRunSupport::device() const
{ {
return d->device; return d->device;

View File

@@ -49,7 +49,7 @@ protected:
enum State enum State
{ {
Inactive, Inactive,
GatheringPorts, GatheringResources,
StartingRunner, StartingRunner,
Running Running
}; };
@@ -71,13 +71,15 @@ protected:
void setFinished(); void setFinished();
bool setPort(Utils::Port &port); bool setPort(Utils::Port &port);
void startPortsGathering();
const ProjectExplorer::IDevice::ConstPtr device() const; const ProjectExplorer::IDevice::ConstPtr device() const;
const ProjectExplorer::StandardRunnable &runnable() const; const ProjectExplorer::StandardRunnable &runnable() const;
void reset(); void reset();
protected slots: protected slots:
virtual void handleRemoteSetupRequested(); virtual void handleRemoteSetupRequested() = 0;
virtual void handleAppRunnerError(const QString &error) = 0; virtual void handleAppRunnerError(const QString &error) = 0;
virtual void handleRemoteOutput(const QByteArray &output) = 0; virtual void handleRemoteOutput(const QByteArray &output) = 0;
virtual void handleRemoteErrorOutput(const QByteArray &output) = 0; virtual void handleRemoteErrorOutput(const QByteArray &output) = 0;
@@ -85,8 +87,8 @@ protected slots:
virtual void handleProgressReport(const QString &progressOutput) = 0; virtual void handleProgressReport(const QString &progressOutput) = 0;
private slots: private slots:
void handlePortsGathererError(const QString &message); void handleResourcesError(const QString &message);
void handlePortListReady(); void handleResourcesAvailable();
private: private:
friend class Internal::AbstractRemoteLinuxRunSupportPrivate; friend class Internal::AbstractRemoteLinuxRunSupportPrivate;

View File

@@ -57,12 +57,12 @@ class RemoteLinuxAnalyzeSupportPrivate
public: public:
RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, Core::Id runMode) RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, Core::Id runMode)
: runControl(rc), : runControl(rc),
qmlProfiling(runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) runMode(runMode)
{ {
} }
const QPointer<AnalyzerRunControl> runControl; const QPointer<AnalyzerRunControl> runControl;
bool qmlProfiling; Core::Id runMode;
Utils::Port qmlPort; Utils::Port qmlPort;
QmlDebug::QmlOutputParser outputParser; QmlDebug::QmlOutputParser outputParser;
@@ -101,18 +101,18 @@ void RemoteLinuxAnalyzeSupport::handleRemoteSetupRequested()
{ {
QTC_ASSERT(state() == Inactive, return); QTC_ASSERT(state() == Inactive, return);
showMessage(tr("Checking available ports...") + QLatin1Char('\n'), Utils::NormalMessageFormat); if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
AbstractRemoteLinuxRunSupport::handleRemoteSetupRequested(); showMessage(tr("Checking available ports...") + QLatin1Char('\n'),
Utils::NormalMessageFormat);
startPortsGathering();
}
} }
void RemoteLinuxAnalyzeSupport::startExecution() void RemoteLinuxAnalyzeSupport::startExecution()
{ {
QTC_ASSERT(state() == GatheringPorts, return); QTC_ASSERT(state() == GatheringResources, return);
// Currently we support only QML profiling if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE && !setPort(d->qmlPort))
QTC_ASSERT(d->qmlProfiling, return);
if (!setPort(d->qmlPort))
return; return;
setState(StartingRunner); setState(StartingRunner);
@@ -132,11 +132,14 @@ void RemoteLinuxAnalyzeSupport::startExecution()
this, &RemoteLinuxAnalyzeSupport::handleAppRunnerError); this, &RemoteLinuxAnalyzeSupport::handleAppRunnerError);
auto r = runnable(); auto r = runnable();
if (!r.commandLineArguments.isEmpty())
r.commandLineArguments.append(QLatin1Char(' ')); if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
r.commandLineArguments += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, if (!r.commandLineArguments.isEmpty())
d->qmlPort); r.commandLineArguments.append(QLatin1Char(' '));
runner->start(device(), r); r.commandLineArguments += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices,
d->qmlPort);
runner->start(device(), r);
}
} }
void RemoteLinuxAnalyzeSupport::handleAppRunnerError(const QString &error) void RemoteLinuxAnalyzeSupport::handleAppRunnerError(const QString &error)
@@ -175,7 +178,7 @@ void RemoteLinuxAnalyzeSupport::handleRemoteOutput(const QByteArray &output)
void RemoteLinuxAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output) void RemoteLinuxAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output)
{ {
QTC_ASSERT(state() != GatheringPorts, return); QTC_ASSERT(state() != GatheringResources, return);
if (!d->runControl) if (!d->runControl)
return; return;
@@ -196,7 +199,6 @@ void RemoteLinuxAnalyzeSupport::handleAdapterSetupFailed(const QString &error)
void RemoteLinuxAnalyzeSupport::handleRemoteProcessStarted() void RemoteLinuxAnalyzeSupport::handleRemoteProcessStarted()
{ {
QTC_ASSERT(d->qmlProfiling, return);
QTC_ASSERT(state() == StartingRunner, return); QTC_ASSERT(state() == StartingRunner, return);
handleAdapterSetupDone(); handleAdapterSetupDone();

View File

@@ -103,12 +103,12 @@ void LinuxDeviceDebugSupport::handleRemoteSetupRequested()
QTC_ASSERT(state() == Inactive, return); QTC_ASSERT(state() == Inactive, return);
showMessage(tr("Checking available ports...") + QLatin1Char('\n'), LogStatus); showMessage(tr("Checking available ports...") + QLatin1Char('\n'), LogStatus);
AbstractRemoteLinuxRunSupport::handleRemoteSetupRequested(); startPortsGathering();
} }
void LinuxDeviceDebugSupport::startExecution() void LinuxDeviceDebugSupport::startExecution()
{ {
QTC_ASSERT(state() == GatheringPorts, return); QTC_ASSERT(state() == GatheringResources, return);
if (d->cppDebugging && !setPort(d->gdbServerPort)) if (d->cppDebugging && !setPort(d->gdbServerPort))
return; return;
@@ -202,7 +202,7 @@ void LinuxDeviceDebugSupport::handleRemoteOutput(const QByteArray &output)
void LinuxDeviceDebugSupport::handleRemoteErrorOutput(const QByteArray &output) void LinuxDeviceDebugSupport::handleRemoteErrorOutput(const QByteArray &output)
{ {
QTC_ASSERT(state() != GatheringPorts, return); QTC_ASSERT(state() != GatheringResources, return);
if (!d->runControl) if (!d->runControl)
return; return;