forked from qt-creator/qt-creator
Use Utils::Port where possible
This solves the ambiguity between 0 and -1 being the "invalid" port. Change-Id: I3bac11dd4117bb1820fbd58186699925b73df1c5 Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -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)
|
||||
|
@@ -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)) {
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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())
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
});
|
||||
|
||||
|
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
private:
|
||||
QmlDebug::QmlOutputParser m_outputParser;
|
||||
int m_qmlPort;
|
||||
Utils::Port m_qmlPort;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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:
|
||||
|
@@ -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);
|
||||
|
@@ -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 {
|
||||
|
@@ -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';
|
||||
|
@@ -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!
|
||||
|
@@ -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;
|
||||
|
@@ -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());
|
||||
}
|
||||
|
@@ -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));
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
};
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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.
|
||||
|
@@ -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,
|
||||
|
@@ -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:
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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'));
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user