Let PortsGatherer produce full URLs instead of ports only

This is what the consuming code expects in most cases.

Change-Id: I135592039e28b994996186f627215ab1d2f8d6dc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
hjk
2019-08-23 11:13:29 +02:00
parent 89f3b32104
commit dca7edbeef
11 changed files with 35 additions and 60 deletions

View File

@@ -25,7 +25,6 @@
#pragma once
#include <utils/port.h>
#include <QString>
#include <QUrl>
@@ -69,9 +68,10 @@ inline QString qmlDebugCommandLineArguments(QmlDebugServicesPreset services,
}
inline QString qmlDebugTcpArguments(QmlDebugServicesPreset services,
Utils::Port port, bool block = true)
const QUrl &server, bool block = true)
{
return qmlDebugCommandLineArguments(services, QString("port:%1").arg(port.number()), block);
// TODO: Also generate host:<host> if applicable.
return qmlDebugCommandLineArguments(services, QString("port:%1").arg(server.port()), block);
}
inline QString qmlDebugNativeArguments(QmlDebugServicesPreset services, bool block = true)

View File

@@ -72,16 +72,15 @@ public:
addStartDependency(m_portsGatherer);
}
Port perfPort() const { return m_portsGatherer->gdbServerPort(); }
QUrl perfServer() const { return m_portsGatherer->gdbServer(); }
QUrl gdbServer() const { return m_portsGatherer->gdbServer(); }
Port qmlServerPort() const { return m_portsGatherer->qmlServerPort(); }
QUrl qmlServer() const { return m_portsGatherer->qmlServer(); }
void start() override
{
const int perfPort = m_portsGatherer->gdbServerPort().number();
const int gdbServerPort = m_portsGatherer->gdbServerPort().number();
const int qmlServerPort = m_portsGatherer->qmlServerPort().number();
const int perfPort = m_portsGatherer->gdbServer().port();
const int gdbServerPort = m_portsGatherer->gdbServer().port();
const int qmlServerPort = m_portsGatherer->qmlServer().port();
int lowerPort = 0;
int upperPort = 0;
@@ -212,11 +211,7 @@ QdbDevicePerfProfilerSupport::QdbDevicePerfProfilerSupport(RunControl *runContro
void QdbDevicePerfProfilerSupport::start()
{
QUrl url;
url.setScheme(Utils::urlTcpScheme());
url.setHost(device()->sshParameters().host());
url.setPort(m_profilee->perfPort().number());
runControl()->setProperty("PerfConnection", url);
runControl()->setProperty("PerfConnection", m_profilee->perfServer());
reportStarted();
}

View File

@@ -845,7 +845,7 @@ bool DebuggerRunTool::fixupParameters()
if (rp.startMode != AttachExternal && rp.startMode != AttachCrashedExternal) {
QString qmlarg = rp.isCppDebugging() && rp.nativeMixedEnabled
? QmlDebug::qmlDebugNativeArguments(service, false)
: QmlDebug::qmlDebugTcpArguments(service, Port(rp.qmlServer.port()));
: QmlDebug::qmlDebugTcpArguments(service, rp.qmlServer);
QtcProcess::addArg(&rp.inferior.commandLineArguments, qmlarg);
}
}
@@ -1047,23 +1047,11 @@ GdbServerPortsGatherer::GdbServerPortsGatherer(RunControl *runControl)
GdbServerPortsGatherer::~GdbServerPortsGatherer() = default;
Port GdbServerPortsGatherer::gdbServerPort() const
{
QUrl url = channel(0);
return Port(url.port());
}
QUrl GdbServerPortsGatherer::gdbServer() const
{
return channel(0);
}
Port GdbServerPortsGatherer::qmlServerPort() const
{
QUrl url = channel(1);
return Port(url.port());
}
QUrl GdbServerPortsGatherer::qmlServer() const
{
return channel(1);
@@ -1111,7 +1099,7 @@ void GdbServerRunner::start()
if (isQmlDebugging) {
args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
m_portsGatherer->qmlServerPort()));
m_portsGatherer->qmlServer()));
}
if (isQmlDebugging && !isCppDebugging) {
gdbserver.executable = m_runnable.executable; // FIXME: Case should not happen?
@@ -1124,7 +1112,7 @@ void GdbServerRunner::start()
args.append("--multi");
if (m_pid.isValid())
args.append("--attach");
args.append(QString(":%1").arg(m_portsGatherer->gdbServerPort().number()));
args.append(QString(":%1").arg(m_portsGatherer->gdbServer().port()));
if (m_pid.isValid())
args.append(QString::number(m_pid.pid()));
}

View File

@@ -147,12 +147,10 @@ public:
void setUseGdbServer(bool useIt) { m_useGdbServer = useIt; }
bool useGdbServer() const { return m_useGdbServer; }
Utils::Port gdbServerPort() const;
QUrl gdbServer() const;
void setUseQmlServer(bool useIt) { m_useQmlServer = useIt; }
bool useQmlServer() const { return m_useQmlServer; }
Utils::Port qmlServerPort() const;
QUrl qmlServer() const;
private:

View File

@@ -199,8 +199,11 @@ void IosRunner::start()
this, &IosRunner::handleFinished);
QStringList args = QtcProcess::splitArgs(m_arguments, OsTypeMac);
if (m_qmlServerPort.isValid())
args.append(QmlDebug::qmlDebugTcpArguments(m_qmlDebugServices, m_qmlServerPort));
if (m_qmlServerPort.isValid()) {
QUrl qmlServer;
qmlServer.setPort(m_qmlServerPort.number());
args.append(QmlDebug::qmlDebugTcpArguments(m_qmlDebugServices, qmlServer));
}
m_toolHandler->requestRunApp(bundlePath(), args, runType(), deviceId());
}

View File

@@ -197,9 +197,13 @@ void PortsGatherer::start()
m_portsGatherer.start(device());
}
Port PortsGatherer::findPort()
QUrl PortsGatherer::findEndPoint()
{
return m_portsGatherer.getNextFreePort(&m_portList);
QUrl result;
result.setScheme(urlTcpScheme());
result.setHost(device()->sshParameters().host());
result.setPort(m_portsGatherer.getNextFreePort(&m_portList).number());
return result;
}
void PortsGatherer::stop()
@@ -268,11 +272,7 @@ public:
if (m_channelForwarder) {
m_channelForwarder->addStartDependency(m_portGatherer);
m_channelForwarder->setFromUrlGetter([this] {
QUrl url;
url.setScheme(urlTcpScheme());
url.setHost(device()->sshParameters().host());
url.setPort(m_portGatherer->findPort().number());
return url;
return m_portGatherer->findEndPoint();
});
addStartDependency(m_channelForwarder);
}
@@ -287,7 +287,7 @@ public:
if (m_channelForwarder)
m_channel.setPort(m_channelForwarder->recordedData("LocalPort").toUInt());
else if (m_portGatherer)
m_channel.setPort(m_portGatherer->findPort().number());
m_channel.setPort(m_portGatherer->findEndPoint().port());
reportStarted();
}

View File

@@ -74,7 +74,7 @@ public:
explicit PortsGatherer(RunControl *runControl);
~PortsGatherer() override;
Utils::Port findPort();
QUrl findEndPoint();
protected:
void start() override;

View File

@@ -66,17 +66,12 @@ QnxQmlProfilerSupport::QnxQmlProfilerSupport(RunControl *runControl)
void QnxQmlProfilerSupport::start()
{
Port qmlPort = m_portsGatherer->findPort();
QUrl serverUrl;
serverUrl.setHost(device()->sshParameters().host());
serverUrl.setPort(qmlPort.number());
serverUrl.setScheme("tcp");
const QUrl serverUrl = m_portsGatherer->findEndPoint();
m_profiler->recordData("QmlServerUrl", serverUrl);
Runnable r = runnable();
QtcProcess::addArg(&r.commandLineArguments,
QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, qmlPort),
QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, serverUrl),
device()->osType());
setRunnable(r);

View File

@@ -108,13 +108,13 @@ private:
Runnable r = runnable();
QStringList arguments;
if (m_portsGatherer->useGdbServer()) {
Port pdebugPort = m_portsGatherer->gdbServerPort();
int pdebugPort = m_portsGatherer->gdbServer().port();
r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE);
arguments.append(pdebugPort.toString());
arguments.append(QString::number(pdebugPort));
}
if (m_portsGatherer->useQmlServer()) {
arguments.append(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
m_portsGatherer->qmlServerPort()));
m_portsGatherer->qmlServer()));
}
arguments.append(QtcProcess::splitArgs(r.commandLineArguments));
r.commandLineArguments = QtcProcess::joinArgs(arguments);
@@ -206,11 +206,11 @@ public:
private:
void start() final
{
Port pdebugPort = m_portsGatherer->gdbServerPort();
const int pdebugPort = m_portsGatherer->gdbServer().port();
Runnable r;
r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE);
r.commandLineArguments = pdebugPort.toString();
r.commandLineArguments = QString::number(pdebugPort);
setRunnable(r);
SimpleTargetRunner::start();

View File

@@ -57,16 +57,12 @@ RemoteLinuxQmlToolingSupport::RemoteLinuxQmlToolingSupport(
void RemoteLinuxQmlToolingSupport::start()
{
Port qmlPort = m_portsGatherer->findPort();
const QUrl serverUrl = m_portsGatherer->findEndPoint();
QUrl serverUrl;
serverUrl.setScheme(urlTcpScheme());
serverUrl.setHost(device()->sshParameters().host());
serverUrl.setPort(qmlPort.number());
m_runworker->recordData("QmlServerUrl", serverUrl);
Runnable r = runnable();
QtcProcess::addArg(&r.commandLineArguments, QmlDebug::qmlDebugTcpArguments(m_services, qmlPort),
QtcProcess::addArg(&r.commandLineArguments, QmlDebug::qmlDebugTcpArguments(m_services, serverUrl),
device()->osType());
setRunnable(r);

View File

@@ -99,7 +99,7 @@ public:
{
CommandLine cmd = emrunCommand(runControl()->target(),
runControl()->aspect<WebBrowserSelectionAspect>()->currentBrowser(),
m_portsGatherer->findPort().toString());
QString::number(m_portsGatherer->findEndPoint().port()));
Runnable r;
r.setCommandLine(cmd);
setRunnable(r);