RemoteLinux: Improve API for retrieving ports and fifos

Change-Id: I8aa808d5ffe12954a44031ec2f3d1c5ef8185eef
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2016-04-20 12:03:58 +02:00
parent 4d396052b6
commit f421176f22
4 changed files with 33 additions and 23 deletions

View File

@@ -119,24 +119,14 @@ void AbstractRemoteLinuxRunSupport::setFinished()
d->state = Inactive; d->state = Inactive;
} }
bool AbstractRemoteLinuxRunSupport::setPort(Utils::Port &port) Utils::Port AbstractRemoteLinuxRunSupport::findPort() const
{ {
port = d->portsGatherer.getNextFreePort(&d->portList); return d->portsGatherer.getNextFreePort(&d->portList);
if (!port.isValid()) {
handleAdapterSetupFailed(tr("Not enough free ports on device for debugging."));
return false;
}
return true;
} }
bool AbstractRemoteLinuxRunSupport::setFifo(QString &fifo) QString AbstractRemoteLinuxRunSupport::fifo() const
{ {
if (d->fifo.isEmpty()) { return d->fifo;
handleAdapterSetupFailed(tr("FIFO for profiling data could not be created."));
return false;
}
fifo = d->fifo;
return true;
} }
void AbstractRemoteLinuxRunSupport::startPortsGathering() void AbstractRemoteLinuxRunSupport::startPortsGathering()

View File

@@ -69,11 +69,12 @@ protected:
virtual void handleAdapterSetupDone(); virtual void handleAdapterSetupDone();
void setFinished(); void setFinished();
bool setPort(Utils::Port &port);
bool setFifo(QString &fifo);
void startPortsGathering(); void startPortsGathering();
Utils::Port findPort() const;
void createRemoteFifo(); void createRemoteFifo();
QString fifo() const;
const ProjectExplorer::IDevice::ConstPtr device() const; const ProjectExplorer::IDevice::ConstPtr device() const;
const ProjectExplorer::StandardRunnable &runnable() const; const ProjectExplorer::StandardRunnable &runnable() const;

View File

@@ -128,10 +128,19 @@ void RemoteLinuxAnalyzeSupport::startExecution()
{ {
QTC_ASSERT(state() == GatheringResources, return); QTC_ASSERT(state() == GatheringResources, return);
if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE && !setPort(d->qmlPort)) if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
return; d->qmlPort = findPort();
if (d->runMode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE && !setFifo(d->remoteFifo)) if (!d->qmlPort.isValid()) {
return; handleAdapterSetupFailed(tr("Not enough free ports on device for profiling."));
return;
}
} else if (d->runMode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE) {
d->remoteFifo = fifo();
if (d->remoteFifo.isEmpty()) {
handleAdapterSetupFailed(tr("FIFO for profiling data could not be created."));
return;
}
}
setState(StartingRunner); setState(StartingRunner);

View File

@@ -110,10 +110,20 @@ void LinuxDeviceDebugSupport::startExecution()
{ {
QTC_ASSERT(state() == GatheringResources, return); QTC_ASSERT(state() == GatheringResources, return);
if (d->cppDebugging && !setPort(d->gdbServerPort)) if (d->cppDebugging) {
return; d->gdbServerPort = findPort();
if (d->qmlDebugging && !setPort(d->qmlPort)) if (!d->gdbServerPort.isValid()) {
handleAdapterSetupFailed(tr("Not enough free ports on device for C++ debugging."));
return; return;
}
}
if (d->qmlDebugging) {
d->qmlPort = findPort();
if (!d->qmlPort.isValid()) {
handleAdapterSetupFailed(tr("Not enough free ports on device for QML debugging."));
return;
}
}
setState(StartingRunner); setState(StartingRunner);
d->gdbserverOutput.clear(); d->gdbserverOutput.clear();