Commit 03acd1fb authored by Ulf Hermann's avatar Ulf Hermann

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: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
parent d4f5cab9
......@@ -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;
......
......@@ -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;
......
......@@ -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<AnalyzerRunControl> 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);
// Currently we support only QML profiling
QTC_ASSERT(d->qmlProfiling, return);
QTC_ASSERT(state() == GatheringResources, 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();
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment