Debugger: Use a QUrl for Qml server port and host

Host and port reasonably belong together, using a QUrl makes that more
explicit and follows the lead of the Qml profiler in that area.

Change-Id: I754cb17d165ce6b2f25c655eeebfd8ac8f5a93c7
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
hjk
2017-08-18 12:23:42 +02:00
parent 60614d6ce1
commit c128731ff2
11 changed files with 43 additions and 64 deletions

View File

@@ -226,8 +226,7 @@ public:
Utils::Port localGdbServerPort() const { return m_localGdbServerPort; }
signals:
void remoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlServerPort,
QString qmlServerHost, int pid);
void remoteProcessStarted(Utils::Port gdbServerPort, const QUrl &qmlServer, int pid);
void remoteProcessFinished(const QString &errString = QString());
void remoteOutput(const QString &output);
@@ -258,8 +257,7 @@ private:
bool m_useCppDebugger = false;
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
Utils::Port m_localGdbServerPort; // Local end of forwarded debug socket.
QString m_qmlServerHost;
Utils::Port m_qmlPort;
QUrl m_qmlServer;
QString m_pingFile;
QString m_pongFile;
QString m_gdbserverPath;
@@ -297,10 +295,8 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunControl *runControl, const AndroidRu
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|| server.listen(QHostAddress::LocalHostIPv6),
qDebug() << tr("No free ports available on host for QML debugging."));
m_qmlServerHost = server.serverAddress().toString();
m_qmlPort = Utils::Port(server.serverPort());
} else {
m_qmlPort = Utils::Port();
m_qmlServer.setHost(server.serverAddress().toString());
m_qmlServer.setPort(server.serverPort());
}
m_adb = AndroidConfigurations::currentConfig().adbToolPath().toString();
@@ -418,7 +414,7 @@ void AndroidRunnerWorker::asyncStart()
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) {
// currently forward to same port on device and host
const QString port = QString("tcp:%1").arg(m_qmlPort.number());
const QString port = QString("tcp:%1").arg(m_qmlServer.port());
if (!runAdb({"forward", port, port}, &errorMessage)) {
emit remoteProcessFinished(tr("Failed to forward QML debugging ports. Reason: %1.")
.arg(errorMessage));
@@ -428,7 +424,7 @@ void AndroidRunnerWorker::asyncStart()
args << "-e" << "qml_debug" << "true"
<< "-e" << "qmljsdebugger"
<< QString("port:%1,block,services:%2")
.arg(m_qmlPort.number()).arg(QmlDebug::qmlDebugServices(m_qmlDebugServices));
.arg(m_qmlServer.port()).arg(QmlDebug::qmlDebugServices(m_qmlDebugServices));
}
if (!runAdb(args, &errorMessage)) {
@@ -641,7 +637,7 @@ void AndroidRunnerWorker::onProcessIdChanged(qint64 pid)
} else {
// In debugging cases this will be funneled to the engine to actually start
// and attach gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below.
emit remoteProcessStarted(m_localGdbServerPort, m_qmlPort, m_qmlServerHost, m_processPID);
emit remoteProcessStarted(m_localGdbServerPort, m_qmlServer, m_processPID);
logcatReadStandardOutput();
QTC_ASSERT(!m_psIsAlive, /**/);
m_psIsAlive.reset(new QProcess);
@@ -785,13 +781,12 @@ void AndroidRunner::remoteErrorOutput(const QString &output)
m_outputParser.processOutput(output);
}
void AndroidRunner::handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlServerPort,
QString qmlServerHost, int pid)
void AndroidRunner::handleRemoteProcessStarted(Utils::Port gdbServerPort,
const QUrl &qmlServer, int pid)
{
m_pid = ProcessHandle(pid);
m_gdbServerPort = gdbServerPort;
m_qmlServerHost = qmlServerHost;
m_qmlServerPort = qmlServerPort;
m_qmlServer = qmlServer;
reportStarted();
}