From f421176f2238e13a19816d61a09767cf60fb2066 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 20 Apr 2016 12:03:58 +0200 Subject: [PATCH] RemoteLinux: Improve API for retrieving ports and fifos Change-Id: I8aa808d5ffe12954a44031ec2f3d1c5ef8185eef Reviewed-by: Christian Kandeler --- .../abstractremotelinuxrunsupport.cpp | 18 ++++-------------- .../abstractremotelinuxrunsupport.h | 5 +++-- .../remotelinux/remotelinuxanalyzesupport.cpp | 17 +++++++++++++---- .../remotelinux/remotelinuxdebugsupport.cpp | 16 +++++++++++++--- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp b/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp index 8dc59697575..ce0d0e4b84b 100644 --- a/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp @@ -119,24 +119,14 @@ void AbstractRemoteLinuxRunSupport::setFinished() d->state = Inactive; } -bool AbstractRemoteLinuxRunSupport::setPort(Utils::Port &port) +Utils::Port AbstractRemoteLinuxRunSupport::findPort() const { - port = d->portsGatherer.getNextFreePort(&d->portList); - if (!port.isValid()) { - handleAdapterSetupFailed(tr("Not enough free ports on device for debugging.")); - return false; - } - return true; + return d->portsGatherer.getNextFreePort(&d->portList); } -bool AbstractRemoteLinuxRunSupport::setFifo(QString &fifo) +QString AbstractRemoteLinuxRunSupport::fifo() const { - if (d->fifo.isEmpty()) { - handleAdapterSetupFailed(tr("FIFO for profiling data could not be created.")); - return false; - } - fifo = d->fifo; - return true; + return d->fifo; } void AbstractRemoteLinuxRunSupport::startPortsGathering() diff --git a/src/plugins/remotelinux/abstractremotelinuxrunsupport.h b/src/plugins/remotelinux/abstractremotelinuxrunsupport.h index 4db8e23477b..d80d08fcf25 100644 --- a/src/plugins/remotelinux/abstractremotelinuxrunsupport.h +++ b/src/plugins/remotelinux/abstractremotelinuxrunsupport.h @@ -69,11 +69,12 @@ protected: virtual void handleAdapterSetupDone(); void setFinished(); - bool setPort(Utils::Port &port); - bool setFifo(QString &fifo); void startPortsGathering(); + Utils::Port findPort() const; + void createRemoteFifo(); + QString fifo() const; const ProjectExplorer::IDevice::ConstPtr device() const; const ProjectExplorer::StandardRunnable &runnable() const; diff --git a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp index 4b41e81c362..0bc847b8604 100644 --- a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp +++ b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp @@ -128,10 +128,19 @@ void RemoteLinuxAnalyzeSupport::startExecution() { QTC_ASSERT(state() == GatheringResources, return); - if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE && !setPort(d->qmlPort)) - return; - if (d->runMode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE && !setFifo(d->remoteFifo)) - return; + if (d->runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { + d->qmlPort = findPort(); + if (!d->qmlPort.isValid()) { + 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); diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp index 18ad5493bd0..94902048e14 100644 --- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp @@ -110,10 +110,20 @@ void LinuxDeviceDebugSupport::startExecution() { QTC_ASSERT(state() == GatheringResources, return); - if (d->cppDebugging && !setPort(d->gdbServerPort)) - return; - if (d->qmlDebugging && !setPort(d->qmlPort)) + if (d->cppDebugging) { + d->gdbServerPort = findPort(); + if (!d->gdbServerPort.isValid()) { + handleAdapterSetupFailed(tr("Not enough free ports on device for C++ debugging.")); 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); d->gdbserverOutput.clear();