aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/qmldebug/qmldebugcommandlinearguments.h9
-rw-r--r--src/libs/qmldebug/qmloutputparser.cpp2
-rw-r--r--src/libs/qmldebug/qmloutputparser.h3
-rw-r--r--src/libs/utils/port.h19
-rw-r--r--src/libs/utils/portlist.cpp27
-rw-r--r--src/libs/utils/portlist.h9
-rw-r--r--src/plugins/android/androidanalyzesupport.cpp4
-rw-r--r--src/plugins/android/androidanalyzesupport.h2
-rw-r--r--src/plugins/android/androiddebugsupport.cpp2
-rw-r--r--src/plugins/android/androiddebugsupport.h2
-rw-r--r--src/plugins/android/androidrunner.cpp22
-rw-r--r--src/plugins/android/androidrunner.h6
-rw-r--r--src/plugins/debugger/analyzer/analyzerruncontrol.h3
-rw-r--r--src/plugins/debugger/analyzer/analyzerstartparameters.h3
-rw-r--r--src/plugins/debugger/debuggerengine.cpp11
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp8
-rw-r--r--src/plugins/debugger/debuggerruncontrol.cpp2
-rw-r--r--src/plugins/debugger/debuggerstartparameters.h8
-rw-r--r--src/plugins/debugger/gdb/startgdbserverdialog.cpp6
-rw-r--r--src/plugins/debugger/qml/qmlengine.cpp12
-rw-r--r--src/plugins/debugger/qml/qmlengine.h4
-rw-r--r--src/plugins/ios/iosanalyzesupport.cpp4
-rw-r--r--src/plugins/ios/iosanalyzesupport.h7
-rw-r--r--src/plugins/ios/iosdebugsupport.cpp7
-rw-r--r--src/plugins/ios/iosdebugsupport.h4
-rw-r--r--src/plugins/ios/iosdevice.cpp8
-rw-r--r--src/plugins/ios/iosdevice.h2
-rw-r--r--src/plugins/ios/iosrunner.cpp15
-rw-r--r--src/plugins/ios/iosrunner.h8
-rw-r--r--src/plugins/ios/iossimulator.cpp5
-rw-r--r--src/plugins/ios/iossimulator.h2
-rw-r--r--src/plugins/ios/iostoolhandler.cpp14
-rw-r--r--src/plugins/ios/iostoolhandler.h4
-rw-r--r--src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp15
-rw-r--r--src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h9
-rw-r--r--src/plugins/projectexplorer/devicesupport/idevice.h3
-rw-r--r--src/plugins/qmlprofiler/localqmlprofilerrunner.cpp13
-rw-r--r--src/plugins/qmlprofiler/localqmlprofilerrunner.h5
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp12
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerclientmanager.h5
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp16
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerruncontrol.h6
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.cpp2
-rw-r--r--src/plugins/qnx/qnxabstractrunsupport.cpp4
-rw-r--r--src/plugins/qnx/qnxabstractrunsupport.h2
-rw-r--r--src/plugins/qnx/qnxanalyzesupport.cpp6
-rw-r--r--src/plugins/qnx/qnxanalyzesupport.h2
-rw-r--r--src/plugins/qnx/qnxattachdebugsupport.cpp12
-rw-r--r--src/plugins/qnx/qnxattachdebugsupport.h3
-rw-r--r--src/plugins/qnx/qnxdebugsupport.cpp2
-rw-r--r--src/plugins/qnx/qnxdebugsupport.h4
-rw-r--r--src/plugins/qnx/qnxdeviceconfiguration.cpp7
-rw-r--r--src/plugins/qnx/qnxruncontrolfactory.cpp4
-rw-r--r--src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp4
-rw-r--r--src/plugins/remotelinux/abstractremotelinuxrunsupport.h3
-rw-r--r--src/plugins/remotelinux/linuxdevice.cpp7
-rw-r--r--src/plugins/remotelinux/linuxdevicetester.cpp5
-rw-r--r--src/plugins/remotelinux/remotelinuxanalyzesupport.cpp9
-rw-r--r--src/plugins/remotelinux/remotelinuxdebugsupport.cpp9
-rw-r--r--src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp2
-rw-r--r--src/plugins/winrt/winrtdebugsupport.cpp9
-rw-r--r--src/plugins/winrt/winrtdebugsupport.h2
62 files changed, 239 insertions, 187 deletions
diff --git a/src/libs/qmldebug/qmldebugcommandlinearguments.h b/src/libs/qmldebug/qmldebugcommandlinearguments.h
index 4be2cbf386e..f1d3d8933e9 100644
--- a/src/libs/qmldebug/qmldebugcommandlinearguments.h
+++ b/src/libs/qmldebug/qmldebugcommandlinearguments.h
@@ -25,6 +25,7 @@
#pragma once
+#include <utils/port.h>
#include <QString>
namespace QmlDebug {
@@ -63,11 +64,13 @@ static inline QString qmlDebugCommandLineArguments(QmlDebugServicesPreset servic
.arg(QLatin1String(block ? ",block" : "")).arg(qmlDebugServices(services));
}
-static inline QString qmlDebugTcpArguments(QmlDebugServicesPreset services, quint16 port = 0,
+static inline QString qmlDebugTcpArguments(QmlDebugServicesPreset services,
+ Utils::Port port = Utils::Port(),
bool block = true)
{
- return qmlDebugCommandLineArguments(services, port ? QString::fromLatin1("port:%1").arg(port) :
- QStringLiteral("port:%qml_port%"), block);
+ return qmlDebugCommandLineArguments(services, port.isValid() ?
+ QString::fromLatin1("port:%1").arg(port.number()) :
+ QStringLiteral("port:%qml_port%"), block);
}
static inline QString qmlDebugNativeArguments(QmlDebugServicesPreset services, bool block = true)
diff --git a/src/libs/qmldebug/qmloutputparser.cpp b/src/libs/qmldebug/qmloutputparser.cpp
index 03773aa57fc..9e6102598b7 100644
--- a/src/libs/qmldebug/qmloutputparser.cpp
+++ b/src/libs/qmldebug/qmloutputparser.cpp
@@ -84,7 +84,7 @@ void QmlOutputParser::processOutput(const QString &output)
bool canConvert;
quint16 port = waitingTcp.cap(1).toUShort(&canConvert);
if (canConvert)
- emit waitingForConnectionOnPort(port);
+ emit waitingForConnectionOnPort(Utils::Port(port));
continue;
}
} else if (status.startsWith(unableToListen)) {
diff --git a/src/libs/qmldebug/qmloutputparser.h b/src/libs/qmldebug/qmloutputparser.h
index a9e08f08e64..60db2e4d52f 100644
--- a/src/libs/qmldebug/qmloutputparser.h
+++ b/src/libs/qmldebug/qmloutputparser.h
@@ -27,6 +27,7 @@
#include "qmldebug_global.h"
+#include <utils/port.h>
#include <QObject>
namespace QmlDebug {
@@ -41,7 +42,7 @@ public:
void processOutput(const QString &output);
signals:
- void waitingForConnectionOnPort(quint16 port);
+ void waitingForConnectionOnPort(Utils::Port port);
void connectionEstablishedMessage();
void connectingToSocketMessage();
void errorMessage(const QString &detailedError);
diff --git a/src/libs/utils/port.h b/src/libs/utils/port.h
index 779d5b7524e..c5faad58345 100644
--- a/src/libs/utils/port.h
+++ b/src/libs/utils/port.h
@@ -26,6 +26,7 @@
#pragma once
#include "utils_global.h"
+#include "qtcassert.h"
namespace Utils {
@@ -34,12 +35,28 @@ class QTCREATOR_UTILS_EXPORT Port
public:
Port() : m_port(-1) {}
explicit Port(quint16 port) : m_port(port) {}
+ explicit Port(int port) :
+ m_port((port < 0 || port > std::numeric_limits<quint16>::max()) ? -1 : port)
+ {
+ }
- quint16 number() const { return quint16(m_port); }
+ explicit Port(uint port) :
+ m_port(port > std::numeric_limits<quint16>::max() ? -1 : port)
+ {
+ }
+
+ quint16 number() const { QTC_ASSERT(isValid(), return 0); return quint16(m_port); }
bool isValid() const { return m_port != -1; }
private:
int m_port;
};
+inline bool operator<(const Port &p1, const Port &p2) { return p1.number() < p2.number(); }
+inline bool operator<=(const Port &p1, const Port &p2) { return p1.number() <= p2.number(); }
+inline bool operator>(const Port &p1, const Port &p2) { return p1.number() > p2.number(); }
+inline bool operator>=(const Port &p1, const Port &p2) { return p1.number() >= p2.number(); }
+inline bool operator==(const Port &p1, const Port &p2) { return p1.number() == p2.number(); }
+inline bool operator!=(const Port &p1, const Port &p2) { return p1.number() != p2.number(); }
+
} // Utils
diff --git a/src/libs/utils/portlist.cpp b/src/libs/utils/portlist.cpp
index 63033b675ea..d78cd24b237 100644
--- a/src/libs/utils/portlist.cpp
+++ b/src/libs/utils/portlist.cpp
@@ -35,7 +35,7 @@ namespace Utils {
namespace Internal {
namespace {
-typedef QPair<int, int> Range;
+typedef QPair<Port, Port> Range;
class PortsSpecParser
{
@@ -82,19 +82,19 @@ private:
void parseElem()
{
- const int startPort = parsePort();
+ const Port startPort = parsePort();
if (atEnd() || nextChar() != '-') {
m_portList.addPort(startPort);
return;
}
++m_pos;
- const int endPort = parsePort();
+ const Port endPort = parsePort();
if (endPort < startPort)
throw ParseException("Invalid range (end < start).");
m_portList.addRange(startPort, endPort);
}
- int parsePort()
+ Port parsePort()
{
if (atEnd())
throw ParseException("Empty port string.");
@@ -108,7 +108,7 @@ private:
} while (!atEnd());
if (port == 0 || port >= 2 << 16)
throw ParseException("Invalid port value.");
- return port;
+ return Port(port);
}
bool atEnd() const { return m_pos == m_portsSpec.length(); }
@@ -153,16 +153,16 @@ PortList PortList::fromString(const QString &portsSpec)
return Internal::PortsSpecParser(portsSpec).parse();
}
-void PortList::addPort(int port) { addRange(port, port); }
+void PortList::addPort(Port port) { addRange(port, port); }
-void PortList::addRange(int startPort, int endPort)
+void PortList::addRange(Port startPort, Port endPort)
{
d->ranges << Internal::Range(startPort, endPort);
}
bool PortList::hasMore() const { return !d->ranges.isEmpty(); }
-bool PortList::contains(int port) const
+bool PortList::contains(Port port) const
{
foreach (const Internal::Range &r, d->ranges) {
if (port >= r.first && port <= r.second)
@@ -175,16 +175,17 @@ int PortList::count() const
{
int n = 0;
foreach (const Internal::Range &r, d->ranges)
- n += r.second - r.first + 1;
+ n += r.second.number() - r.first.number() + 1;
return n;
}
-int PortList::getNext()
+Port PortList::getNext()
{
Q_ASSERT(!d->ranges.isEmpty());
Internal::Range &firstRange = d->ranges.first();
- const int next = firstRange.first++;
+ const Port next = firstRange.first;
+ firstRange.first = Port(firstRange.first.number() + 1);
if (firstRange.first > firstRange.second)
d->ranges.removeFirst();
return next;
@@ -194,9 +195,9 @@ QString PortList::toString() const
{
QString stringRep;
foreach (const Internal::Range &range, d->ranges) {
- stringRep += QString::number(range.first);
+ stringRep += QString::number(range.first.number());
if (range.second != range.first)
- stringRep += QLatin1Char('-') + QString::number(range.second);
+ stringRep += QLatin1Char('-') + QString::number(range.second.number());
stringRep += QLatin1Char(',');
}
if (!stringRep.isEmpty())
diff --git a/src/libs/utils/portlist.h b/src/libs/utils/portlist.h
index 21e05a43e5a..49adf3ae0ba 100644
--- a/src/libs/utils/portlist.h
+++ b/src/libs/utils/portlist.h
@@ -26,6 +26,7 @@
#pragma once
#include "utils_global.h"
+#include "port.h"
QT_FORWARD_DECLARE_CLASS(QString)
@@ -40,12 +41,12 @@ public:
PortList &operator=(const PortList &other);
~PortList();
- void addPort(int port);
- void addRange(int startPort, int endPort);
+ void addPort(Port port);
+ void addRange(Port startPort, Port endPort);
bool hasMore() const;
- bool contains(int port) const;
+ bool contains(Port port) const;
int count() const;
- int getNext();
+ Port getNext();
QString toString() const;
static PortList fromString(const QString &portsSpec);
diff --git a/src/plugins/android/androidanalyzesupport.cpp b/src/plugins/android/androidanalyzesupport.cpp
index 820e9ab00de..06581745ed3 100644
--- a/src/plugins/android/androidanalyzesupport.cpp
+++ b/src/plugins/android/androidanalyzesupport.cpp
@@ -79,12 +79,12 @@ AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
[runner]() { runner->start(); });
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
- [this, runControl](quint16) {
+ [this, runControl](Utils::Port) {
runControl->notifyRemoteSetupDone(m_qmlPort);
});
connect(runner, &AndroidRunner::remoteProcessStarted,
- [this](int, int qmlPort) {
+ [this](Utils::Port, Utils::Port qmlPort) {
m_qmlPort = qmlPort;
});
diff --git a/src/plugins/android/androidanalyzesupport.h b/src/plugins/android/androidanalyzesupport.h
index 54460cdb1df..83055c52369 100644
--- a/src/plugins/android/androidanalyzesupport.h
+++ b/src/plugins/android/androidanalyzesupport.h
@@ -49,7 +49,7 @@ public:
private:
QmlDebug::QmlOutputParser m_outputParser;
- int m_qmlPort;
+ Utils::Port m_qmlPort;
};
} // namespace Internal
diff --git a/src/plugins/android/androiddebugsupport.cpp b/src/plugins/android/androiddebugsupport.cpp
index 57cf87cb8d7..0cb13ee45cd 100644
--- a/src/plugins/android/androiddebugsupport.cpp
+++ b/src/plugins/android/androiddebugsupport.cpp
@@ -171,7 +171,7 @@ AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
});
}
-void AndroidDebugSupport::handleRemoteProcessStarted(int gdbServerPort, int qmlPort)
+void AndroidDebugSupport::handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlPort)
{
disconnect(m_runner, &AndroidRunner::remoteProcessStarted,
this, &AndroidDebugSupport::handleRemoteProcessStarted);
diff --git a/src/plugins/android/androiddebugsupport.h b/src/plugins/android/androiddebugsupport.h
index 368b66c11c6..1b55002a866 100644
--- a/src/plugins/android/androiddebugsupport.h
+++ b/src/plugins/android/androiddebugsupport.h
@@ -49,7 +49,7 @@ public:
QString *errorMessage);
private:
- void handleRemoteProcessStarted(int gdbServerPort, int qmlPort);
+ void handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlPort);
Debugger::DebuggerRunControl *m_runControl;
AndroidRunner * const m_runner;
diff --git a/src/plugins/android/androidrunner.cpp b/src/plugins/android/androidrunner.cpp
index 80c49b55646..03e8d6851dd 100644
--- a/src/plugins/android/androidrunner.cpp
+++ b/src/plugins/android/androidrunner.cpp
@@ -137,16 +137,16 @@ AndroidRunner::AndroidRunner(QObject *parent,
m_qmlDebugServices = QmlDebug::NoQmlDebugServices;
QString channel = runConfig->remoteChannel();
QTC_CHECK(channel.startsWith(QLatin1Char(':')));
- m_localGdbServerPort = channel.mid(1).toUShort();
- QTC_CHECK(m_localGdbServerPort);
+ m_localGdbServerPort = Utils::Port(channel.mid(1).toUShort());
+ QTC_CHECK(m_localGdbServerPort.isValid());
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) {
QTcpServer server;
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|| server.listen(QHostAddress::LocalHostIPv6),
qDebug() << tr("No free ports available on host for QML debugging."));
- m_qmlPort = server.serverPort();
+ m_qmlPort = Utils::Port(server.serverPort());
} else {
- m_qmlPort = 0;
+ m_qmlPort = Utils::Port();
}
ProjectExplorer::Target *target = runConfig->target();
m_androidRunnable.intentName = AndroidManager::intentName(target);
@@ -276,18 +276,18 @@ void AndroidRunner::checkPID()
if (m_useCppDebugger) {
// This will be funneled to the engine to actually start and attach
// gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below.
- QByteArray serverChannel = ':' + QByteArray::number(m_localGdbServerPort);
+ QByteArray serverChannel = ':' + QByteArray::number(m_localGdbServerPort.number());
emit remoteServerRunning(serverChannel, m_processPID);
} else if (m_qmlDebugServices == QmlDebug::QmlDebuggerServices) {
// This will be funneled to the engine to actually start and attach
// gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below.
- QByteArray serverChannel = QByteArray::number(m_qmlPort);
+ QByteArray serverChannel = QByteArray::number(m_qmlPort.number());
emit remoteServerRunning(serverChannel, m_processPID);
} else if (m_qmlDebugServices == QmlDebug::QmlProfilerServices) {
- emit remoteProcessStarted(-1, m_qmlPort);
+ emit remoteProcessStarted(Utils::Port(), m_qmlPort);
} else {
// Start without debugging.
- emit remoteProcessStarted(-1, -1);
+ emit remoteProcessStarted(Utils::Port(), Utils::Port());
}
m_wasStarted = true;
logcatReadStandardOutput();
@@ -348,7 +348,7 @@ void AndroidRunner::asyncStart()
if (m_useCppDebugger) {
QProcess adb;
adb.start(m_adb, selector() << _("forward")
- << QString::fromLatin1("tcp:%1").arg(m_localGdbServerPort)
+ << QString::fromLatin1("tcp:%1").arg(m_localGdbServerPort.number())
<< _("localfilesystem:") + m_gdbserverSocket);
if (!adb.waitForStarted()) {
emit remoteProcessFinished(tr("Failed to forward C++ debugging ports. Reason: %1.").arg(adb.errorString()));
@@ -390,7 +390,7 @@ void AndroidRunner::asyncStart()
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) {
// currently forward to same port on device and host
- const QString port = QString::fromLatin1("tcp:%1").arg(m_qmlPort);
+ const QString port = QString::fromLatin1("tcp:%1").arg(m_qmlPort.number());
QProcess adb;
adb.start(m_adb, selector() << _("forward") << port << port);
if (!adb.waitForStarted()) {
@@ -405,7 +405,7 @@ void AndroidRunner::asyncStart()
args << _("-e") << _("qml_debug") << _("true")
<< _("-e") << _("qmljsdebugger")
<< QString::fromLatin1("port:%1,block,services:%2")
- .arg(m_qmlPort).arg(QmlDebug::qmlDebugServices(m_qmlDebugServices));
+ .arg(m_qmlPort.number()).arg(QmlDebug::qmlDebugServices(m_qmlDebugServices));
}
QProcess adb;
diff --git a/src/plugins/android/androidrunner.h b/src/plugins/android/androidrunner.h
index d32018c8698..c9a87f3579a 100644
--- a/src/plugins/android/androidrunner.h
+++ b/src/plugins/android/androidrunner.h
@@ -68,7 +68,7 @@ public slots:
signals:
void remoteServerRunning(const QByteArray &serverChannel, int pid);
- void remoteProcessStarted(int gdbServerPort, int qmlPort);
+ void remoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlPort);
void remoteProcessFinished(const QString &errString = QString());
void remoteOutput(const QString &output);
@@ -101,8 +101,8 @@ private:
qint64 m_processPID;
bool m_useCppDebugger;
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
- ushort m_localGdbServerPort; // Local end of forwarded debug socket.
- quint16 m_qmlPort;
+ Utils::Port m_localGdbServerPort; // Local end of forwarded debug socket.
+ Utils::Port m_qmlPort;
QString m_pingFile;
QString m_pongFile;
QString m_gdbserverPath;
diff --git a/src/plugins/debugger/analyzer/analyzerruncontrol.h b/src/plugins/debugger/analyzer/analyzerruncontrol.h
index 12b5e4c6f06..a990bc86555 100644
--- a/src/plugins/debugger/analyzer/analyzerruncontrol.h
+++ b/src/plugins/debugger/analyzer/analyzerruncontrol.h
@@ -31,6 +31,7 @@
#include <projectexplorer/runconfiguration.h>
#include <utils/outputformat.h>
+#include <utils/port.h>
namespace Debugger {
@@ -51,7 +52,7 @@ public:
virtual void pause() {}
virtual void unpause() {}
- virtual void notifyRemoteSetupDone(quint16) {}
+ virtual void notifyRemoteSetupDone(Utils::Port) {}
virtual void notifyRemoteFinished() {}
signals:
diff --git a/src/plugins/debugger/analyzer/analyzerstartparameters.h b/src/plugins/debugger/analyzer/analyzerstartparameters.h
index 7f5d439d9bd..d12deea8507 100644
--- a/src/plugins/debugger/analyzer/analyzerstartparameters.h
+++ b/src/plugins/debugger/analyzer/analyzerstartparameters.h
@@ -29,6 +29,7 @@
#include <projectexplorer/runnables.h>
#include <ssh/sshconnection.h>
+#include <utils/port.h>
#include <QMetaType>
@@ -40,7 +41,7 @@ public:
QSsh::SshConnectionParameters connParams;
QString analyzerHost;
QString analyzerSocket;
- quint16 analyzerPort = 0;
+ Utils::Port analyzerPort;
};
DEBUGGER_EXPORT bool operator==(const AnalyzerConnection &c1, const AnalyzerConnection &c2);
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index 0f7f1ff0b80..11f85289180 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -896,26 +896,27 @@ void DebuggerEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &re
if (result.success) {
showMessage(_("NOTE: REMOTE SETUP DONE: GDB SERVER PORT: %1 QML PORT %2")
- .arg(result.gdbServerPort).arg(result.qmlServerPort));
+ .arg(result.gdbServerPort.number()).arg(result.qmlServerPort.number()));
if (d->remoteSetupState() != RemoteSetupCancelled)
d->setRemoteSetupState(RemoteSetupSucceeded);
- if (result.gdbServerPort != InvalidPid) {
+ if (result.gdbServerPort.isValid()) {
QString &rc = d->m_runParameters.remoteChannel;
const int sepIndex = rc.lastIndexOf(QLatin1Char(':'));
if (sepIndex != -1) {
rc.replace(sepIndex + 1, rc.count() - sepIndex - 1,
- QString::number(result.gdbServerPort));
+ QString::number(result.gdbServerPort.number()));
}
} else if (result.inferiorPid != InvalidPid && runParameters().startMode == AttachExternal) {
// e.g. iOS Simulator
runParameters().attachPID = result.inferiorPid;
}
- if (result.qmlServerPort != InvalidPort) {
+ if (result.qmlServerPort.isValid()) {
d->m_runParameters.qmlServerPort = result.qmlServerPort;
- d->m_runParameters.inferior.commandLineArguments.replace(_("%qml_port%"), QString::number(result.qmlServerPort));
+ d->m_runParameters.inferior.commandLineArguments.replace(
+ _("%qml_port%"), QString::number(result.qmlServerPort.number()));
}
} else {
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 10d11dd840a..ebe30a53a07 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -2112,8 +2112,10 @@ void DebuggerPluginPrivate::attachToQmlPort()
const QVariant qmlServerPort = configValue("LastQmlServerPort");
if (qmlServerPort.isValid())
dlg.setPort(qmlServerPort.toInt());
+ else if (rp.qmlServerPort.isValid())
+ dlg.setPort(rp.qmlServerPort.number());
else
- dlg.setPort(rp.qmlServerPort);
+ dlg.setPort(-1);
const Id kitId = Id::fromSetting(configValue("LastProfile"));
if (kitId.isValid())
@@ -2132,7 +2134,7 @@ void DebuggerPluginPrivate::attachToQmlPort()
rp.connParams = device->sshParameters();
rp.qmlServerAddress = device->qmlProfilerHost();
}
- rp.qmlServerPort = dlg.port();
+ rp.qmlServerPort = Utils::Port(dlg.port());
rp.startMode = AttachToRemoteProcess;
rp.closeMode = KillAtClose;
rp.languages = QmlLanguage;
@@ -2863,7 +2865,7 @@ static QString formatStartParameters(DebuggerRunParameters &sp)
}
if (!sp.qmlServerAddress.isEmpty())
str << "QML server: " << sp.qmlServerAddress << ':'
- << sp.qmlServerPort << '\n';
+ << (sp.qmlServerPort.isValid() ? sp.qmlServerPort.number() : -1) << '\n';
if (!sp.remoteChannel.isEmpty())
str << "Remote: " << sp.remoteChannel << '\n';
str << "Sysroot: " << sp.sysRoot << '\n';
diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp
index db98c715710..76959a74488 100644
--- a/src/plugins/debugger/debuggerruncontrol.cpp
+++ b/src/plugins/debugger/debuggerruncontrol.cpp
@@ -440,7 +440,7 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration *
return 0;
}
rp.qmlServerAddress = server.serverAddress().toString();
- rp.qmlServerPort = server.serverPort();
+ rp.qmlServerPort = Utils::Port(server.serverPort());
// Makes sure that all bindings go through the JavaScript engine, so that
// breakpoints are actually hit!
diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h
index d1465a37d15..27ebf7bd40c 100644
--- a/src/plugins/debugger/debuggerstartparameters.h
+++ b/src/plugins/debugger/debuggerstartparameters.h
@@ -30,6 +30,7 @@
#include <ssh/sshconnection.h>
#include <utils/environment.h>
+#include <utils/port.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/runnables.h>
@@ -44,14 +45,13 @@ namespace Debugger {
// Note: This is part of the "soft interface" of the debugger plugin.
// Do not add anything that needs implementation in a .cpp file.
-const int InvalidPort = -1;
const qint64 InvalidPid = -1;
class DEBUGGER_EXPORT RemoteSetupResult
{
public:
- int gdbServerPort = InvalidPort;
- int qmlServerPort = InvalidPort;
+ Utils::Port gdbServerPort;
+ Utils::Port qmlServerPort;
qint64 inferiorPid = InvalidPid;
bool success = false;
QString reason;
@@ -73,7 +73,7 @@ public:
// Used by Qml debugging.
QString qmlServerAddress;
- int qmlServerPort = InvalidPort;
+ Utils::Port qmlServerPort;
// Used by general remote debugging.
QString remoteChannel;
diff --git a/src/plugins/debugger/gdb/startgdbserverdialog.cpp b/src/plugins/debugger/gdb/startgdbserverdialog.cpp
index cb17291f4ef..6a1da0cb86e 100644
--- a/src/plugins/debugger/gdb/startgdbserverdialog.cpp
+++ b/src/plugins/debugger/gdb/startgdbserverdialog.cpp
@@ -108,8 +108,8 @@ void GdbServerStarter::run()
void GdbServerStarter::portListReady()
{
PortList ports = d->device->freePorts();
- const int port = d->gatherer.getNextFreePort(&ports);
- if (port == -1) {
+ const Port port = d->gatherer.getNextFreePort(&ports);
+ if (!port.isValid()) {
QTC_ASSERT(false, /**/);
emit logMessage(tr("Process aborted"));
return;
@@ -130,7 +130,7 @@ void GdbServerStarter::portListReady()
if (gdbServerPath.isEmpty())
gdbServerPath = "gdbserver";
QByteArray cmd = gdbServerPath + " --attach :"
- + QByteArray::number(port) + ' ' + QByteArray::number(d->process.pid);
+ + QByteArray::number(port.number()) + ' ' + QByteArray::number(d->process.pid);
logMessage(tr("Running command: %1").arg(QString::fromLatin1(cmd)));
d->runner.run(cmd, d->device->sshParameters());
}
diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp
index b9691939e54..cdce030c800 100644
--- a/src/plugins/debugger/qml/qmlengine.cpp
+++ b/src/plugins/debugger/qml/qmlengine.cpp
@@ -347,7 +347,7 @@ void QmlEngine::connectionEstablished()
notifyEngineRunAndInferiorRunOk();
}
-void QmlEngine::tryToConnect(quint16 port)
+void QmlEngine::tryToConnect(Utils::Port port)
{
showMessage(QLatin1String("QML Debugger: No application output received in time, trying to connect ..."), LogStatus);
d->retryOnConnectFail = true;
@@ -366,7 +366,7 @@ void QmlEngine::tryToConnect(quint16 port)
}
}
-void QmlEngine::beginConnection(quint16 port)
+void QmlEngine::beginConnection(Utils::Port port)
{
d->noDebugOutputTimer.stop();
@@ -391,13 +391,13 @@ void QmlEngine::beginConnection(quint16 port)
* the connection will be closed again (instead of returning the "connection refused"
* error that we expect).
*/
- if (runParameters().qmlServerPort > 0)
+ if (runParameters().qmlServerPort.isValid())
port = runParameters().qmlServerPort;
if (!d->connection || d->connection->isConnected())
return;
- d->connection->connectToHost(host, port);
+ d->connection->connectToHost(host, port.number());
//A timeout to check the connection state
d->connectionTimer.start();
@@ -563,7 +563,7 @@ void QmlEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result)
DebuggerEngine::notifyEngineRemoteSetupFinished(result);
if (result.success) {
- if (result.qmlServerPort != InvalidPort)
+ if (result.qmlServerPort.isValid())
runParameters().qmlServerPort = result.qmlServerPort;
notifyEngineSetupOk();
@@ -587,7 +587,7 @@ void QmlEngine::notifyEngineRemoteServerRunning(const QByteArray &serverChannel,
bool ok = false;
quint16 qmlPort = serverChannel.toUInt(&ok);
if (ok)
- runParameters().qmlServerPort = qmlPort;
+ runParameters().qmlServerPort = Utils::Port(qmlPort);
else
qWarning() << tr("QML debugging port not set: Unable to convert %1 to unsigned int.").arg(QString::fromLatin1(serverChannel));
diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h
index 0e90d8573ca..5e534ab08e5 100644
--- a/src/plugins/debugger/qml/qmlengine.h
+++ b/src/plugins/debugger/qml/qmlengine.h
@@ -60,8 +60,8 @@ private slots:
void errorMessageBoxFinished(int result);
void updateCurrentContext();
- void tryToConnect(quint16 port = 0);
- void beginConnection(quint16 port = 0);
+ void tryToConnect(Utils::Port port = Utils::Port());
+ void beginConnection(Utils::Port port = Utils::Port());
void connectionEstablished();
void connectionStartupFailed();
void appStartupFailed(const QString &errorMessage);
diff --git a/src/plugins/ios/iosanalyzesupport.cpp b/src/plugins/ios/iosanalyzesupport.cpp
index c9e7020af35..9da560b617c 100644
--- a/src/plugins/ios/iosanalyzesupport.cpp
+++ b/src/plugins/ios/iosanalyzesupport.cpp
@@ -97,13 +97,13 @@ void IosAnalyzeSupport::qmlServerReady()
m_runControl->notifyRemoteSetupDone(m_qmlPort);
}
-void IosAnalyzeSupport::handleServerPorts(int gdbServerPort, int qmlPort)
+void IosAnalyzeSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort)
{
Q_UNUSED(gdbServerPort);
m_qmlPort = qmlPort;
}
-void IosAnalyzeSupport::handleGotInferiorPid(qint64 pid, int qmlPort)
+void IosAnalyzeSupport::handleGotInferiorPid(qint64 pid, Utils::Port qmlPort)
{
Q_UNUSED(pid);
m_qmlPort = qmlPort;
diff --git a/src/plugins/ios/iosanalyzesupport.h b/src/plugins/ios/iosanalyzesupport.h
index 2de2a1bb4e0..2da08d4c1ee 100644
--- a/src/plugins/ios/iosanalyzesupport.h
+++ b/src/plugins/ios/iosanalyzesupport.h
@@ -28,6 +28,7 @@
#include "iosrunconfiguration.h"
#include <qmldebug/qmloutputparser.h>
+#include <utils/port.h>
#include <QProcess>
#include <QObject>
@@ -51,8 +52,8 @@ public:
private:
void qmlServerReady();
- void handleServerPorts(int gdbServerFd, int qmlPort);
- void handleGotInferiorPid(qint64 pid, int qmlPort);
+ void handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort);
+ void handleGotInferiorPid(qint64 pid, Utils::Port qmlPort);
void handleRemoteProcessFinished(bool cleanEnd);
void handleRemoteOutput(const QString &output);
@@ -61,7 +62,7 @@ private:
Debugger::AnalyzerRunControl *m_runControl;
IosRunner * const m_runner;
QmlDebug::QmlOutputParser m_outputParser;
- int m_qmlPort;
+ Utils::Port m_qmlPort;
};
} // namespace Internal
diff --git a/src/plugins/ios/iosdebugsupport.cpp b/src/plugins/ios/iosdebugsupport.cpp
index 8adfb5e795f..0d42fb6d2e5 100644
--- a/src/plugins/ios/iosdebugsupport.cpp
+++ b/src/plugins/ios/iosdebugsupport.cpp
@@ -181,18 +181,19 @@ IosDebugSupport::~IosDebugSupport()
{
}
-void IosDebugSupport::handleServerPorts(int gdbServerPort, int qmlPort)
+void IosDebugSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort)
{
RemoteSetupResult result;
result.gdbServerPort = gdbServerPort;
result.qmlServerPort = qmlPort;
- result.success = gdbServerPort > 0 || (m_runner && !m_runner->cppDebug() && qmlPort > 0);
+ result.success = gdbServerPort.isValid()
+ || (m_runner && !m_runner->cppDebug() && qmlPort.isValid());
if (!result.success)
result.reason = tr("Could not get debug server file descriptor.");
m_runControl->notifyEngineRemoteSetupFinished(result);
}
-void IosDebugSupport::handleGotInferiorPid(qint64 pid, int qmlPort)
+void IosDebugSupport::handleGotInferiorPid(qint64 pid, Utils::Port qmlPort)
{
RemoteSetupResult result;
result.qmlServerPort = qmlPort;
diff --git a/src/plugins/ios/iosdebugsupport.h b/src/plugins/ios/iosdebugsupport.h
index a645f2f1a5b..1d9560cd465 100644
--- a/src/plugins/ios/iosdebugsupport.h
+++ b/src/plugins/ios/iosdebugsupport.h
@@ -50,8 +50,8 @@ public:
~IosDebugSupport();
private:
- void handleServerPorts(int gdbServerFd, int qmlPort);
- void handleGotInferiorPid(qint64, int qmlPort);
+ void handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort);
+ void handleGotInferiorPid(qint64, Utils::Port qmlPort);
void handleRemoteProcessFinished(bool cleanEnd);
void handleRemoteOutput(const QString &output);
diff --git a/src/plugins/ios/iosdevice.cpp b/src/plugins/ios/iosdevice.cpp
index 7be1c8d07be..c0e94038343 100644
--- a/src/plugins/ios/iosdevice.cpp
+++ b/src/plugins/ios/iosdevice.cpp
@@ -88,8 +88,8 @@ IosDevice::IosDevice()
setDisplayName(IosDevice::name());
setDeviceState(DeviceDisconnected);
Utils::PortList ports;
- ports.addRange(Constants::IOS_DEVICE_PORT_START,
- Constants::IOS_DEVICE_PORT_END);
+ ports.addRange(Utils::Port(Constants::IOS_DEVICE_PORT_START),
+ Utils::Port(Constants::IOS_DEVICE_PORT_END));
setFreePorts(ports);
}
@@ -200,12 +200,12 @@ QString IosDevice::osVersion() const
return m_extraInfo.value(QLatin1String("osVersion"));
}
-quint16 IosDevice::nextPort() const
+Utils::Port IosDevice::nextPort() const
{
// use qrand instead?
if (++m_lastPort >= Constants::IOS_DEVICE_PORT_END)
m_lastPort = Constants::IOS_DEVICE_PORT_START;
- return m_lastPort;
+ return Utils::Port(m_lastPort);
}
bool IosDevice::canAutoDetectPorts() const
diff --git a/src/plugins/ios/iosdevice.h b/src/plugins/ios/iosdevice.h
index 69c9e18e2e1..8c6921f232e 100644
--- a/src/plugins/ios/iosdevice.h
+++ b/src/plugins/ios/iosdevice.h
@@ -66,7 +66,7 @@ public:
QString uniqueDeviceID() const;
IosDevice(const QString &uid);
QString osVersion() const;
- quint16 nextPort() const;
+ Utils::Port nextPort() const;
bool canAutoDetectPorts() const override;
static QString name();
diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp
index 55ef3766ef2..59a2e1bec77 100644
--- a/src/plugins/ios/iosrunner.cpp
+++ b/src/plugins/ios/iosrunner.cpp
@@ -76,7 +76,7 @@ QString IosRunner::bundlePath()
QStringList IosRunner::extraArgs()
{
QStringList res = m_arguments;
- if (m_qmlPort != 0)
+ if (m_qmlPort.isValid())
res << QmlDebug::qmlDebugTcpArguments(m_qmlDebugServices, m_qmlPort);
return res;
}
@@ -113,7 +113,7 @@ void IosRunner::start()
emit finished(m_cleanExit);
}
m_cleanExit = false;
- m_qmlPort = 0;
+ m_qmlPort = Utils::Port();
if (!QFileInfo::exists(m_bundleDir)) {
TaskHub::addTask(Task::Warning,
tr("Could not find %1.").arg(m_bundleDir),
@@ -177,7 +177,8 @@ void IosRunner::handleDidStartApp(IosToolHandler *handler, const QString &bundle
}
void IosRunner::handleGotServerPorts(IosToolHandler *handler, const QString &bundlePath,
- const QString &deviceId, int gdbPort, int qmlPort)
+ const QString &deviceId, Utils::Port gdbPort,
+ Utils::Port qmlPort)
{
Q_UNUSED(bundlePath); Q_UNUSED(deviceId);
m_qmlPort = qmlPort;
@@ -200,8 +201,8 @@ void IosRunner::handleAppOutput(IosToolHandler *handler, const QString &output)
QRegExp qmlPortRe(QLatin1String("QML Debugger: Waiting for connection on port ([0-9]+)..."));
int index = qmlPortRe.indexIn(output);
QString res(output);
- if (index != -1 && m_qmlPort)
- res.replace(qmlPortRe.cap(1), QString::number(m_qmlPort));
+ if (index != -1 && m_qmlPort.isValid())
+ res.replace(qmlPortRe.cap(1), QString::number(m_qmlPort.number()));
emit appOutput(res);
}
@@ -222,8 +223,8 @@ void IosRunner::handleErrorMsg(IosToolHandler *handler, const QString &msg)
}
QRegExp qmlPortRe(QLatin1String("QML Debugger: Waiting for connection on port ([0-9]+)..."));
int index = qmlPortRe.indexIn(msg);
- if (index != -1 && m_qmlPort)
- res.replace(qmlPortRe.cap(1), QString::number(m_qmlPort));
+ if (index != -1 && m_qmlPort.isValid())
+ res.replace(qmlPortRe.cap(1), QString::number(m_qmlPort.number()));
emit errorMsg(res);
}
diff --git a/src/plugins/ios/iosrunner.h b/src/plugins/ios/iosrunner.h
index 95c1888cda7..b9e6ef4a4b8 100644
--- a/src/plugins/ios/iosrunner.h
+++ b/src/plugins/ios/iosrunner.h
@@ -66,8 +66,8 @@ public slots:
signals:
void didStartApp(Ios::IosToolHandler::OpStatus status);
- void gotServerPorts(int gdbPort, int qmlPort);
- void gotInferiorPid(qint64 pid, int);
+ void gotServerPorts(Utils::Port gdbPort, Utils::Port qmlPort);
+ void gotInferiorPid(qint64 pid, Utils::Port qmlPort);
void appOutput(const QString &output);
void errorMsg(const QString &msg);
void finished(bool cleanExit);
@@ -76,7 +76,7 @@ private:
void handleDidStartApp(Ios::IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, Ios::IosToolHandler::OpStatus status);
void handleGotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath,
- const QString &deviceId, int gdbPort, int qmlPort);
+ const QString &deviceId, Utils::Port gdbPort, Utils::Port qmlPort);
void handleGotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, qint64 pid);
void handleAppOutput(Ios::IosToolHandler *handler, const QString &output);
@@ -93,7 +93,7 @@ private:
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
bool m_cleanExit;
- quint16 m_qmlPort;
+ Utils::Port m_qmlPort;
qint64 m_pid;
};
diff --git a/src/plugins/ios/iossimulator.cpp b/src/plugins/ios/iossimulator.cpp
index a73a16712b2..9494b356bc9 100644
--- a/src/plugins/ios/iossimulator.cpp
+++ b/src/plugins/ios/iossimulator.cpp
@@ -28,6 +28,7 @@
#include "iostoolhandler.h"
#include <projectexplorer/kitinformation.h>
+#include <utils/port.h>
#include <QCoreApplication>
#include <QMapIterator>
@@ -171,7 +172,7 @@ QVariantMap IosSimulator::toMap() const
return res;
}
-quint16 IosSimulator::nextPort() const
+Utils::Port IosSimulator::nextPort() const
{
for (int i = 0; i < 100; ++i) {
// use qrand instead?
@@ -192,7 +193,7 @@ quint16 IosSimulator::nextPort() const
|| portVerifier.exitCode() != 0)
break;
}
- return m_lastPort;
+ return Utils::Port(m_lastPort);
}
bool IosSimulator::canAutoDetectPorts() const
diff --git a/src/plugins/ios/iossimulator.h b/src/plugins/ios/iossimulator.h
index 3e7e7444d1d..df02e6807a1 100644
--- a/src/plugins/ios/iossimulator.h
+++ b/src/plugins/ios/iossimulator.h
@@ -79,7 +79,7 @@ public:
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
void fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
- quint16 nextPort() const;
+ Utils::Port nextPort() const;
bool canAutoDetectPorts() const override;
ProjectExplorer::IDevice::Ptr clone() const override;
diff --git a/src/plugins/ios/iostoolhandler.cpp b/src/plugins/ios/iostoolhandler.cpp
index 9ac9ef4be9f..c304ec8ac1e 100644
--- a/src/plugins/ios/iostoolhandler.cpp
+++ b/src/plugins/ios/iostoolhandler.cpp
@@ -141,8 +141,8 @@ public:
IosToolHandler::OpStatus status);
void didStartApp(const QString &bundlePath, const QString &deviceId,
IosToolHandler::OpStatus status);
- void gotServerPorts(const QString &bundlePath, const QString &deviceId, int gdbPort,
- int qmlPort);
+ void gotServerPorts(const QString &bundlePath, const QString &deviceId, Utils::Port gdbPort,
+ Utils::Port qmlPort);
void gotInferiorPid(const QString &bundlePath, const QString &deviceId, qint64 pid);
void deviceInfo(const QString &deviceId, const IosToolHandler::Dict &info);
void appOutput(const QString &output);
@@ -306,8 +306,8 @@ void IosToolHandlerPrivate::didStartApp(const QString &bundlePath, const QString
emit q->didStartApp(q, bundlePath, deviceId, status);
}
-void IosToolHandlerPrivate::gotServerPorts(const QString &bundlePath,
- const QString &deviceId, int gdbPort, int qmlPort)
+void IosToolHandlerPrivate::gotServerPorts(const QString &bundlePath, const QString &deviceId,
+ Utils::Port gdbPort, Utils::Port qmlPort)
{
emit q->gotServerPorts(q, bundlePath, deviceId, gdbPort, qmlPort);
}
@@ -445,8 +445,10 @@ void IosToolHandlerPrivate::processXml()
} else if (elName == QLatin1String("server_ports")) {
stack.append(ParserState(ParserState::ServerPorts));
QXmlStreamAttributes attributes = outputParser.attributes();
- int gdbServerPort = attributes.value(QLatin1String("gdb_server")).toString().toInt();
- int qmlServerPort = attributes.value(QLatin1String("qml_server")).toString().toInt();
+ Utils::Port gdbServerPort(
+ attributes.value(QLatin1String("gdb_server")).toString().toInt());
+ Utils::Port qmlServerPort(
+ attributes.value(QLatin1String("qml_server")).toString().toInt());
gotServerPorts(bundlePath, deviceId, gdbServerPort, qmlServerPort);
} else {
qCWarning(toolHandlerLog) << "unexpected element " << elName;
diff --git a/src/plugins/ios/iostoolhandler.h b/src/plugins/ios/iostoolhandler.h
index a3eba3476ab..ce9cf31dac1 100644
--- a/src/plugins/ios/iostoolhandler.h
+++ b/src/plugins/ios/iostoolhandler.h
@@ -25,6 +25,8 @@
#pragma once
+#include <utils/port.h>
+
#include <QObject>
#include <QMap>
#include <QString>
@@ -72,7 +74,7 @@ signals:
void didStartApp(Ios::IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, Ios::IosToolHandler::OpStatus status);
void gotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath,
- const QString &deviceId, int gdbPort, int qmlPort);
+ const QString &deviceId, Utils::Port gdbPort, Utils::Port qmlPort);
void gotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, qint64 pid);
void deviceInfo(Ios::IosToolHandler *handler, const QString &deviceId,
diff --git a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp
index 7dc96f76623..60f4a39ca7b 100644
--- a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp
+++ b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp
@@ -25,6 +25,7 @@
#include "deviceusedportsgatherer.h"
+#include <utils/port.h>
#include <utils/portlist.h>
#include <utils/qtcassert.h>
#include <ssh/sshconnection.h>
@@ -42,7 +43,7 @@ class DeviceUsedPortsGathererPrivate
public:
SshConnection *connection;
SshRemoteProcess::Ptr process;
- QList<int> usedPorts;
+ QList<Port> usedPorts;
QByteArray remoteStdout;
QByteArray remoteStderr;
IDevice::ConstPtr device;
@@ -110,17 +111,17 @@ void DeviceUsedPortsGatherer::stop()
d->connection = 0;
}
-int DeviceUsedPortsGatherer::getNextFreePort(PortList *freePorts) const
+Port DeviceUsedPortsGatherer::getNextFreePort(PortList *freePorts) const
{
while (freePorts->hasMore()) {
- const int port = freePorts->getNext();
+ const Port port = freePorts->getNext();
if (!d->usedPorts.contains(port))
return port;
}
- return -1;
+ return Port();
}
-QList<int> DeviceUsedPortsGatherer::usedPorts() const
+QList<Port> DeviceUsedPortsGatherer::usedPorts() const
{
return d->usedPorts;
}
@@ -128,8 +129,8 @@ QList<int> DeviceUsedPortsGatherer::usedPorts() const
void DeviceUsedPortsGatherer::setupUsedPorts()
{
d->usedPorts.clear();
- const QList<int> usedPorts = d->device->portsGatheringMethod()->usedPorts(d->remoteStdout);
- foreach (const int port, usedPorts) {
+ const QList<Port> usedPorts = d->device->portsGatheringMethod()->usedPorts(d->remoteStdout);
+ foreach (const Port port, usedPorts) {
if (d->device->freePorts().contains(port))
d->usedPorts << port;
}
diff --git a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h
index f57e5951c05..e326557469c 100644
--- a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h
+++ b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h
@@ -27,7 +27,10 @@
#include "idevice.h"
-namespace Utils { class PortList; }
+namespace Utils {
+class Port;
+class PortList;
+} // namespace Utils
namespace ProjectExplorer {
namespace Internal { class DeviceUsedPortsGathererPrivate; }
@@ -42,8 +45,8 @@ public:
void start(const ProjectExplorer::IDevice::ConstPtr &device);
void stop();
- int getNextFreePort(Utils::PortList *freePorts) const; // returns -1 if no more are left
- QList<int> usedPorts() const;
+ Utils::Port getNextFreePort(Utils::PortList *freePorts) const; // returns -1 if no more are left
+ QList<Utils::Port> usedPorts() const;
signals:
void error(const QString &errMsg);
diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h
index 3ab1ff03cd6..ff30c66cf1d 100644
--- a/src/plugins/projectexplorer/devicesupport/idevice.h
+++ b/src/plugins/projectexplorer/devicesupport/idevice.h
@@ -44,6 +44,7 @@ namespace QSsh { class SshConnectionParameters; }
namespace Utils {
class Environment;
class PortList;
+class Port;
} // Utils
namespace ProjectExplorer {
@@ -103,7 +104,7 @@ public:
virtual ~PortsGatheringMethod() = default;
virtual QByteArray commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const = 0;
- virtual QList<int> usedPorts(const QByteArray &commandOutput) const = 0;
+ virtual QList<Utils::Port> usedPorts(const QByteArray &commandOutput) const = 0;
};
// See cpp file for documentation.
diff --git a/src/plugins/qmlprofiler/localqmlprofilerrunner.cpp b/src/plugins/qmlprofiler/localqmlprofilerrunner.cpp
index b79aa79e927..af137adcbf2 100644
--- a/src/plugins/qmlprofiler/localqmlprofilerrunner.cpp
+++ b/src/plugins/qmlprofiler/localqmlprofilerrunner.cpp
@@ -51,16 +51,16 @@ QString LocalQmlProfilerRunner::findFreeSocket()
}
}
-quint16 LocalQmlProfilerRunner::findFreePort(QString &host)
+Utils::Port LocalQmlProfilerRunner::findFreePort(QString &host)
{
QTcpServer server;
if (!server.listen(QHostAddress::LocalHost)
&& !server.listen(QHostAddress::LocalHostIPv6)) {
qWarning() << "Cannot open port on host for QML profiling.";
- return 0;
+ return Utils::Port();
}
host = server.serverAddress().toString();
- return server.serverPort();
+ return Utils::Port(server.serverPort());
}
LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuration,
@@ -102,9 +102,12 @@ void LocalQmlProfilerRunner::start()
runnable.runMode = ApplicationLauncher::Gui;
if (QmlProfilerPlugin::debugOutput) {
+ QString portOrSocket = m_configuration.socket.isEmpty() ?
+ QString::number(m_configuration.port.isValid() ?
+ m_configuration.port.number() : -1) :
+ m_configuration.socket;
qWarning("QmlProfiler: Launching %s:%s", qPrintable(m_configuration.debuggee.executable),
- qPrintable(m_configuration.socket.isEmpty() ?
- QString::number(m_configuration.port) : m_configuration.socket));
+ qPrintable(portOrSocket));
}
connect(&m_launcher, &ApplicationLauncher::processExited,
diff --git a/src/plugins/qmlprofiler/localqmlprofilerrunner.h b/src/plugins/qmlprofiler/localqmlprofilerrunner.h
index c634cc62bff..757f09f8aee 100644
--- a/src/plugins/qmlprofiler/localqmlprofilerrunner.h
+++ b/src/plugins/qmlprofiler/localqmlprofilerrunner.h
@@ -27,6 +27,7 @@
#include "qmlprofiler_global.h"
#include <utils/environment.h>
+#include <utils/port.h>
#include <projectexplorer/applicationlauncher.h>
#include <projectexplorer/runnables.h>
@@ -40,14 +41,14 @@ class QMLPROFILER_EXPORT LocalQmlProfilerRunner : public QObject
public:
struct Configuration {
ProjectExplorer::StandardRunnable debuggee;
- quint16 port;
+ Utils::Port port;
QString socket;
};
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerRunControl *engine);
~LocalQmlProfilerRunner();
- static quint16 findFreePort(QString &host);
+ static Utils::Port findFreePort(QString &host);
static QString findFreeSocket();
signals:
diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
index fba83df7b8d..cae8ea487e2 100644
--- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
@@ -55,7 +55,7 @@ public:
QString localSocket;
QString tcpHost;
- quint64 tcpPort;
+ Utils::Port tcpPort;
QString sysroot;
quint32 flushInterval;
bool aggregateTraces;
@@ -108,7 +108,7 @@ void QmlProfilerClientManager::setAggregateTraces(bool aggregateTraces)
d->aggregateTraces = aggregateTraces;
}
-void QmlProfilerClientManager::setTcpConnection(QString host, quint64 port)
+void QmlProfilerClientManager::setTcpConnection(QString host, Utils::Port port)
{
d->tcpHost = host;
d->tcpPort = port;
@@ -118,7 +118,7 @@ void QmlProfilerClientManager::setTcpConnection(QString host, quint64 port)
void QmlProfilerClientManager::setLocalSocket(QString file)
{
d->localSocket = file;
- d->tcpPort = 0;
+ d->tcpPort = Utils::Port();
connectLocalClient(file);
}
@@ -133,7 +133,7 @@ void QmlProfilerClientManager::discardPendingData()
clearBufferedData();
}
-void QmlProfilerClientManager::connectTcpClient(quint16 port)
+void QmlProfilerClientManager::connectTcpClient(Utils::Port port)
{
if (d->connection) {
if (port == d->tcpPort) {
@@ -147,7 +147,7 @@ void QmlProfilerClientManager::connectTcpClient(quint16 port)
createConnection();
d->connectionTimer.start();
d->tcpPort = port;
- d->connection->connectToHost(d->tcpHost, d->tcpPort);
+ d->connection->connectToHost(d->tcpHost, d->tcpPort.number());
}
void QmlProfilerClientManager::connectLocalClient(const QString &file)
@@ -269,7 +269,7 @@ void QmlProfilerClientManager::tryToConnect()
d->connection = 0;
connectTcpClient(d->tcpPort);
} else if (!d->connection->isConnecting()) {
- d->connection->connectToHost(d->tcpHost, d->tcpPort);
+ d->connection->connectToHost(d->tcpHost, d->tcpPort.number());
}
} else if (d->connectionAttempts == 50) {
d->connectionTimer.stop();
diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h
index d6536eb4b4a..cc1490b6843 100644
--- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h
+++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h
@@ -27,6 +27,7 @@
#include "qmlprofilerstatemanager.h"
#include <qmldebug/qmlprofilereventlocation.h>
+#include <utils/port.h>
#include <QObject>
#include <QStringList>
@@ -45,7 +46,7 @@ public:
~QmlProfilerClientManager();
void registerProfilerStateManager(QmlProfilerStateManager *profilerState);
- void setTcpConnection(QString host, quint64 port);
+ void setTcpConnection(QString host, Utils::Port port);
void setLocalSocket(QString file);
void clearBufferedData();
@@ -63,7 +64,7 @@ signals:
void connectionClosed();
public slots:
- void connectTcpClient(quint16 port);
+ void connectTcpClient(Utils::Port port);
void connectLocalClient(const QString &file);
void disconnectClient();
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
index ec78fe1c758..b3aaaa87739 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
@@ -86,15 +86,15 @@ QmlProfilerRunControl::QmlProfilerRunControl(RunConfiguration *runConfiguration,
d->m_noDebugOutputTimer.setSingleShot(true);
d->m_noDebugOutputTimer.setInterval(4000);
connect(&d->m_noDebugOutputTimer, &QTimer::timeout,
- this, [this](){processIsRunning(0);});
+ this, [this](){processIsRunning(Utils::Port());});
d->m_outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput());
connect(&d->m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
this, &QmlProfilerRunControl::processIsRunning);
connect(&d->m_outputParser, &QmlDebug::QmlOutputParser::noOutputMessage,
- this, [this](){processIsRunning(0);});
+ this, [this](){processIsRunning(Utils::Port());});
connect(&d->m_outputParser, &QmlDebug::QmlOutputParser::connectingToSocketMessage,
- this, [this](){processIsRunning(0);});
+ this, [this](){processIsRunning(Utils::Port());});
connect(&d->m_outputParser, &QmlDebug::QmlOutputParser::errorMessage,
this, &QmlProfilerRunControl::wrongSetupMessageBox);
}
@@ -114,7 +114,7 @@ void QmlProfilerRunControl::start()
QTC_ASSERT(connection().is<AnalyzerConnection>(), finished(); return);
auto conn = connection().as<AnalyzerConnection>();
- if (conn.analyzerPort != 0)
+ if (conn.analyzerPort.isValid())
emit processRunning(conn.analyzerPort);
else if (conn.analyzerSocket.isEmpty())
d->m_noDebugOutputTimer.start();
@@ -236,19 +236,19 @@ void QmlProfilerRunControl::wrongSetupMessageBoxFinished(int button)
}
}
-void QmlProfilerRunControl::notifyRemoteSetupDone(quint16 port)
+void QmlProfilerRunControl::notifyRemoteSetupDone(Utils::Port port)
{
d->m_noDebugOutputTimer.stop();
emit processRunning(port);
}
-void QmlProfilerRunControl::processIsRunning(quint16 port)
+void QmlProfilerRunControl::processIsRunning(Utils::Port port)
{
d->m_noDebugOutputTimer.stop();
- if (port == 0)
+ if (!port.isValid())
port = connection().as<AnalyzerConnection>().analyzerPort;
- if (port != 0)
+ if (port.isValid())
emit processRunning(port);
}
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h
index f012fab2240..c859ab3991e 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h
@@ -45,7 +45,7 @@ public:
void registerProfilerStateManager( QmlProfilerStateManager *profilerState );
- void notifyRemoteSetupDone(quint16 port) override;
+ void notifyRemoteSetupDone(Utils::Port port) override;
void start() override;
StopResult stop() override;
bool isRunning() const override;
@@ -54,12 +54,12 @@ public:
void logApplicationMessage(const QString &msg, Utils::OutputFormat format) override;
signals:
- void processRunning(quint16 port);
+ void processRunning(Utils::Port port);
private:
void wrongSetupMessageBox(const QString &errorMessage);
void wrongSetupMessageBoxFinished(int);
- void processIsRunning(quint16 port);
+ void processIsRunning(Utils::Port port);
void profilerStateChanged();
class QmlProfilerRunControlPrivate;
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp
index 7c9ad186067..3de6a1d905c 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp
@@ -564,7 +564,7 @@ void QmlProfilerTool::startRemoteTool(ProjectExplorer::RunConfiguration *rc)
connection.connParams = device->sshParameters();
connection.analyzerHost = device->qmlProfilerHost();
}
- connection.analyzerPort = port;
+ connection.analyzerPort = Utils::Port(port);
auto runControl = qobject_cast<QmlProfilerRunControl *>(createRunControl(rc));
runControl->setConnection(connection);
diff --git a/src/plugins/qnx/qnxabstractrunsupport.cpp b/src/plugins/qnx/qnxabstractrunsupport.cpp
index 16d87574e48..a7eba6235eb 100644
--- a/src/plugins/qnx/qnxabstractrunsupport.cpp
+++ b/src/plugins/qnx/qnxabstractrunsupport.cpp
@@ -117,10 +117,10 @@ void QnxAbstractRunSupport::handleError(const QString &)
{
}
-bool QnxAbstractRunSupport::setPort(int &port)
+bool QnxAbstractRunSupport::setPort(Utils::Port &port)
{
port = m_portsGatherer->getNextFreePort(&m_portList);
- if (port == -1) {
+ if (!port.isValid()) {
handleError(tr("Not enough free ports on device for debugging."));
return false;
}
diff --git a/src/plugins/qnx/qnxabstractrunsupport.h b/src/plugins/qnx/qnxabstractrunsupport.h
index d28ca70f30c..67cd7f6466a 100644
--- a/src/plugins/qnx/qnxabstractrunsupport.h
+++ b/src/plugins/qnx/qnxabstractrunsupport.h
@@ -56,7 +56,7 @@ public:
QnxAbstractRunSupport(QnxRunConfiguration *runConfig, QObject *parent = 0);
protected:
- bool setPort(int &port);
+ bool setPort(Utils::Port &port);
virtual void startExecution() = 0;
void setFinished();
diff --git a/src/plugins/qnx/qnxanalyzesupport.cpp b/src/plugins/qnx/qnxanalyzesupport.cpp
index 289d7d1756a..61a6c263910 100644
--- a/src/plugins/qnx/qnxanalyzesupport.cpp
+++ b/src/plugins/qnx/qnxanalyzesupport.cpp
@@ -97,7 +97,7 @@ void QnxAnalyzeSupport::startExecution()
if (state() == Inactive)
return;
- if (!setPort(m_qmlPort) && m_qmlPort == -1)
+ if (!setPort(m_qmlPort) && !m_qmlPort.isValid())
return;
setState(StartingRemoteProcess);
@@ -105,8 +105,8 @@ void QnxAnalyzeSupport::startExecution()
StandardRunnable r = m_runnable;
if (!r.commandLineArguments.isEmpty())
r.commandLineArguments += QLatin1Char(' ');
- r.commandLineArguments
- += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, m_qmlPort);
+ r.commandLineArguments += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices,
+ m_qmlPort);
appRunner()->start(device(), r);
}
diff --git a/src/plugins/qnx/qnxanalyzesupport.h b/src/plugins/qnx/qnxanalyzesupport.h
index 8c7b9b64f9c..19165a16863 100644
--- a/src/plugins/qnx/qnxanalyzesupport.h
+++ b/src/plugins/qnx/qnxanalyzesupport.h
@@ -67,7 +67,7 @@ private:
ProjectExplorer::StandardRunnable m_runnable;
Debugger::AnalyzerRunControl *m_runControl;
QmlDebug::QmlOutputParser m_outputParser;
- int m_qmlPort;
+ Utils::Port m_qmlPort;
Slog2InfoRunner *m_slog2Info;
};
diff --git a/src/plugins/qnx/qnxattachdebugsupport.cpp b/src/plugins/qnx/qnxattachdebugsupport.cpp
index 9eea7bf4826..87ded8d789f 100644
--- a/src/plugins/qnx/qnxattachdebugsupport.cpp
+++ b/src/plugins/qnx/qnxattachdebugsupport.cpp
@@ -105,14 +105,14 @@ void QnxAttachDebugSupport::launchPDebug()
{
Utils::PortList portList = m_device->freePorts();
m_pdebugPort = m_portsGatherer->getNextFreePort(&portList);
- if (m_pdebugPort == -1) {
+ if (!m_pdebugPort.isValid()) {
handleError(tr("No free ports for debugging."));
return;
}
StandardRunnable r;
r.executable = QLatin1String("pdebug");
- r.commandLineArguments = QString::number(m_pdebugPort);
+ r.commandLineArguments = QString::number(m_pdebugPort.number());
m_runner->start(m_device, r);
}
@@ -122,9 +122,11 @@ void QnxAttachDebugSupport::attachToProcess()
sp.attachPID = m_process.pid;
sp.startMode = Debugger::AttachToRemoteServer;
sp.closeMode = Debugger::DetachAtClose;
- sp.connParams.port = m_pdebugPort;
- sp.remoteChannel = m_device->sshParameters().host + QLatin1Char(':') + QString::number(m_pdebugPort);
- sp.displayName = tr("Remote: \"%1:%2\" - Process %3").arg(sp.connParams.host).arg(m_pdebugPort).arg(m_process.pid);
+ sp.connParams.port = m_pdebugPort.number();
+ sp.remoteChannel = m_device->sshParameters().host + QLatin1Char(':') +
+ QString::number(m_pdebugPort.number());
+ sp.displayName = tr("Remote: \"%1:%2\" - Process %3").arg(sp.connParams.host)
+ .arg(m_pdebugPort.number()).arg(m_process.pid);
sp.inferior.executable = m_localExecutablePath;
sp.useCtrlCStub = true;
diff --git a/src/plugins/qnx/qnxattachdebugsupport.h b/src/plugins/qnx/qnxattachdebugsupport.h
index 328c9bda1e8..3ce4d2fe0a1 100644
--- a/src/plugins/qnx/qnxattachdebugsupport.h
+++ b/src/plugins/qnx/qnxattachdebugsupport.h
@@ -28,6 +28,7 @@
#include <debugger/debuggerconstants.h>
#include <projectexplorer/devicesupport/deviceprocesslist.h>
#include <projectexplorer/devicesupport/idevice.h>
+#include <utils/port.h>
#include <QObject>
@@ -71,7 +72,7 @@ private:
ProjectExplorer::DeviceUsedPortsGatherer *m_portsGatherer;
Debugger::DebuggerRunControl *m_runControl = 0;
- int m_pdebugPort = -1;
+ Utils::Port m_pdebugPort;
QString m_projectSourceDirectory;
QString m_localExecutablePath;
};
diff --git a/src/plugins/qnx/qnxdebugsupport.cpp b/src/plugins/qnx/qnxdebugsupport.cpp
index 92526114bf1..1f3f2ed9a0f 100644
--- a/src/plugins/qnx/qnxdebugsupport.cpp
+++ b/src/plugins/qnx/qnxdebugsupport.cpp
@@ -105,7 +105,7 @@ void QnxDebugSupport::startExecution()
QStringList arguments;
if (m_useCppDebugger)
- arguments << QString::number(m_pdebugPort);
+ arguments << QString::number(m_pdebugPort.number());
else if (m_useQmlDebugger && !m_useCppDebugger)
arguments = Utils::QtcProcess::splitArgs(
m_runControl->startParameters().inferior.commandLineArguments);
diff --git a/src/plugins/qnx/qnxdebugsupport.h b/src/plugins/qnx/qnxdebugsupport.h
index 27edfe773ba..f389c3ee495 100644
--- a/src/plugins/qnx/qnxdebugsupport.h
+++ b/src/plugins/qnx/qnxdebugsupport.h
@@ -73,8 +73,8 @@ private:
Slog2InfoRunner *m_slog2Info;
Debugger::DebuggerRunControl *m_runControl;
- int m_pdebugPort;
- int m_qmlPort;
+ Utils::Port m_pdebugPort;
+ Utils::Port m_qmlPort;
bool m_useCppDebugger;
bool m_useQmlDebugger;
diff --git a/src/plugins/qnx/qnxdeviceconfiguration.cpp b/src/plugins/qnx/qnxdeviceconfiguration.cpp
index f682c9b450a..1215b399930 100644
--- a/src/plugins/qnx/qnxdeviceconfiguration.cpp
+++ b/src/plugins/qnx/qnxdeviceconfiguration.cpp
@@ -33,6 +33,7 @@
#include <projectexplorer/devicesupport/sshdeviceprocess.h>
#include <projectexplorer/runnables.h>
#include <ssh/sshconnection.h>
+#include <utils/port.h>
#include <utils/qtcassert.h>
#include <QApplication>
@@ -66,16 +67,16 @@ class QnxPortsGatheringMethod : public PortsGatheringMethod
"done";
}
- QList<int> usedPorts(const QByteArray &output) const
+ QList<Port> usedPorts(const QByteArray &output) const
{
- QList<int> ports;
+ QList<Port> ports;
QList<QByteArray> portStrings = output.split('\n');
portStrings.removeFirst();
foreach (const QByteArray &portString, portStrings) {
if (portString.isEmpty())
continue;
bool ok;
- const int port = portString.toInt(&ok, 16);
+ const Port port(portString.toInt(&ok, 16));
if (ok) {
if (!ports.contains(port))
ports << port;
diff --git a/src/plugins/qnx/qnxruncontrolfactory.cpp b/src/plugins/qnx/qnxruncontrolfactory.cpp
index 0b95af65b1e..b65ded3e80e 100644
--- a/src/plugins/qnx/qnxruncontrolfactory.cpp
+++ b/src/plugins/qnx/qnxruncontrolfactory.cpp
@@ -75,7 +75,7 @@ static DebuggerStartParameters createDebuggerStartParameters(QnxRunConfiguration
auto aspect = runConfig->extraAspect<DebuggerRunConfigurationAspect>();
if (aspect->useQmlDebugger()) {
params.qmlServerAddress = device->sshParameters().host;
- params.qmlServerPort = 0; // QML port is handed out later
+ params.qmlServerPort = Utils::Port(); // QML port is handed out later
}
auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitInformation::qtVersion(k));
@@ -147,7 +147,7 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, Core::Id m
AnalyzerConnection connection;
connection.connParams = device->sshParameters();
connection.analyzerHost = connection.connParams.host;
- connection.analyzerPort = connection.connParams.port;
+ connection.analyzerPort = Utils::Port(connection.connParams.port);
runControl->setConnection(connection);
auto analyzeSupport = new QnxAnalyzeSupport(rc, runControl);
connect(runControl, &RunControl::finished, analyzeSupport, &QnxAnalyzeSupport::handleProfilingFinished);
diff --git a/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp b/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp
index ca93f696175..5277e73841a 100644
--- a/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp
+++ b/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp
@@ -128,10 +128,10 @@ void AbstractRemoteLinuxRunSupport::setFinished()
d->state = Inactive;
}
-bool AbstractRemoteLinuxRunSupport::setPort(int &port)
+bool AbstractRemoteLinuxRunSupport::setPort(Utils::Port &port)
{
port = d->portsGatherer.getNextFreePort(&d->portList);
- if (port == -1) {
+ if (!port.isValid()) {
handleAdapterSetupFailed(tr("Not enough free ports on device for debugging."));
return false;
}
diff --git a/src/plugins/remotelinux/abstractremotelinuxrunsupport.h b/src/plugins/remotelinux/abstractremotelinuxrunsupport.h
index e2e4611d039..71745b5f3e6 100644
--- a/src/plugins/remotelinux/abstractremotelinuxrunsupport.h
+++ b/src/plugins/remotelinux/abstractremotelinuxrunsupport.h
@@ -28,6 +28,7 @@
#include "remotelinux_export.h"
#include <projectexplorer/devicesupport/idevice.h>
+#include <utils/port.h>
#include <QObject>
@@ -68,7 +69,7 @@ protected:
virtual void handleAdapterSetupDone();
void setFinished();
- bool setPort(int &port);
+ bool setPort(Utils::Port &port);
const ProjectExplorer::IDevice::ConstPtr device() const;
const ProjectExplorer::StandardRunnable &runnable() const;
diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp
index 6f960c07860..aad5c3ddf77 100644
--- a/src/plugins/remotelinux/linuxdevice.cpp
+++ b/src/plugins/remotelinux/linuxdevice.cpp
@@ -37,6 +37,7 @@
#include <projectexplorer/devicesupport/sshdeviceprocesslist.h>
#include <ssh/sshremoteprocessrunner.h>
#include <utils/algorithm.h>
+#include <utils/port.h>
#include <utils/qtcassert.h>
#include <QTimer>
@@ -137,16 +138,16 @@ class LinuxPortsGatheringMethod : public PortsGatheringMethod
.arg(addressLength).arg(procFilePath).toUtf8();
}
- QList<int> usedPorts(const QByteArray &output) const
+ QList<Utils::Port> usedPorts(const QByteArray &output) const
{
- QList<int> ports;
+ QList<Utils::Port> ports;
QList<QByteArray> portStrings = output.split('\n');
portStrings.removeFirst();
foreach (const QByteArray &portString, portStrings) {
if (portString.isEmpty())
continue;
bool ok;
- const int port = portString.toInt(&ok, 16);
+ const Utils::Port port(portString.toInt(&ok, 16));
if (ok) {
if (!ports.contains(port))
ports << port;
diff --git a/src/plugins/remotelinux/linuxdevicetester.cpp b/src/plugins/remotelinux/linuxdevicetester.cpp
index 4a0e9fa35b2..56e2e290dc9 100644
--- a/src/plugins/remotelinux/linuxdevicetester.cpp
+++ b/src/plugins/remotelinux/linuxdevicetester.cpp
@@ -26,6 +26,7 @@
#include "linuxdevicetester.h"
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
+#include <utils/port.h>
#include <utils/qtcassert.h>
#include <ssh/sshremoteprocess.h>
#include <ssh/sshconnection.h>
@@ -169,8 +170,8 @@ void GenericLinuxDeviceTester::handlePortListReady()
emit progressMessage(tr("All specified ports are available.") + QLatin1Char('\n'));
} else {
QString portList;
- foreach (const int port, d->portsGatherer.usedPorts())
- portList += QString::number(port) + QLatin1String(", ");
+ foreach (const Utils::Port port, d->portsGatherer.usedPorts())
+ portList += QString::number(port.number()) + QLatin1String(", ");
portList.remove(portList.count() - 2, 2);
emit errorMessage(tr("The following specified ports are currently in use: %1")
.arg(portList) + QLatin1Char('\n'));
diff --git a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp
index e63baf8949c..a1d963786e3 100644
--- a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp
+++ b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp
@@ -57,14 +57,13 @@ class RemoteLinuxAnalyzeSupportPrivate
public:
RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, Core::Id runMode)
: runControl(rc),
- qmlProfiling(runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE),
- qmlPort(-1)
+ qmlProfiling(runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
{
}
const QPointer<AnalyzerRunControl> runControl;
bool qmlProfiling;
- int qmlPort;
+ Utils::Port qmlPort;
QmlDebug::QmlOutputParser outputParser;
};
@@ -135,8 +134,8 @@ void RemoteLinuxAnalyzeSupport::startExecution()
auto r = runnable();
if (!r.commandLineArguments.isEmpty())
r.commandLineArguments.append(QLatin1Char(' '));
- r.commandLineArguments
- += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, d->qmlPort);
+ r.commandLineArguments += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices,
+ d->qmlPort);
runner->start(device(), r);
}
diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
index 8316dbfedce..9981efbe278 100644
--- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
+++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
@@ -60,8 +60,7 @@ public:
LinuxDeviceDebugSupportPrivate(const RunConfiguration *runConfig, DebuggerRunControl *runControl)
: runControl(runControl),
qmlDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useQmlDebugger()),
- cppDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useCppDebugger()),
- gdbServerPort(-1), qmlPort(-1)
+ cppDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useCppDebugger())
{
}
@@ -69,8 +68,8 @@ public:
bool qmlDebugging;
bool cppDebugging;
QByteArray gdbserverOutput;
- int gdbServerPort;
- int qmlPort;
+ Port gdbServerPort;
+ Port qmlPort;
};
} // namespace Internal
@@ -149,7 +148,7 @@ void LinuxDeviceDebugSupport::startExecution()
command = QLatin1String("gdbserver");
args.clear();
args.append(QString::fromLatin1("--multi"));
- args.append(QString::fromLatin1(":%1").arg(d->gdbServerPort));
+ args.append(QString::fromLatin1(":%1").arg(d->gdbServerPort.number()));
}
r.executable = command;
r.commandLineArguments = QtcProcess::joinArgs(args, OsTypeLinux);
diff --git a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp b/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp
index 3439c977b4b..15c7a5a368a 100644
--- a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp
+++ b/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp
@@ -116,7 +116,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co
if (aspect->useQmlDebugger()) {
params.qmlServerAddress = dev->sshParameters().host;
- params.qmlServerPort = 0; // port is selected later on
+ params.qmlServerPort = Utils::Port(); // port is selected later on
}
if (aspect->useCppDebugger()) {
aspect->setUseMultiProcess(true);
diff --git a/src/plugins/winrt/winrtdebugsupport.cpp b/src/plugins/winrt/winrtdebugsupport.cpp
index 338e711cdb8..25f2adab410 100644
--- a/src/plugins/winrt/winrtdebugsupport.cpp
+++ b/src/plugins/winrt/winrtdebugsupport.cpp
@@ -63,14 +63,15 @@ bool WinRtDebugSupport::useQmlDebugging(WinRtRunConfiguration *runConfig)
return extraAspect && extraAspect->useQmlDebugger();
}
-bool WinRtDebugSupport::getFreePort(quint16 &qmlDebuggerPort, QString *errorMessage)
+bool WinRtDebugSupport::getFreePort(Utils::Port &qmlDebuggerPort, QString *errorMessage)
{
QTcpServer server;
- if (!server.listen(QHostAddress::LocalHost, qmlDebuggerPort)) {
+ if (!server.listen(QHostAddress::LocalHost,
+ qmlDebuggerPort.isValid() ? qmlDebuggerPort.number() : 0)) {
*errorMessage = tr("Not enough free ports for QML debugging.");
return false;
}
- qmlDebuggerPort = server.serverPort();
+ qmlDebuggerPort = Utils::Port(server.serverPort());
return true;
}
@@ -105,7 +106,7 @@ RunControl *WinRtDebugSupport::createDebugRunControl(WinRtRunConfiguration *runC
}
if (useQmlDebugging(runConfig)) {
- quint16 qmlDebugPort = 0;
+ Utils::Port qmlDebugPort;
if (!getFreePort(qmlDebugPort, errorMessage))
return 0;
params.qmlServerAddress = QHostAddress(QHostAddress::LocalHost).toString();
diff --git a/src/plugins/winrt/winrtdebugsupport.h b/src/plugins/winrt/winrtdebugsupport.h
index 08a21dbf99e..82705576fa1 100644
--- a/src/plugins/winrt/winrtdebugsupport.h
+++ b/src/plugins/winrt/winrtdebugsupport.h
@@ -48,7 +48,7 @@ private:
WinRtDebugSupport(ProjectExplorer::RunControl *runControl, WinRtRunnerHelper *runner);
static bool useQmlDebugging(WinRtRunConfiguration *runConfig);
- static bool getFreePort(quint16 &qmlDebuggerPort, QString *errorMessage);
+ static bool getFreePort(Utils::Port &qmlDebuggerPort, QString *errorMessage);
ProjectExplorer::RunControl *m_debugRunControl;
WinRtRunnerHelper *m_runner;