diff --git a/src/libs/qmldebug/qmldebugcommandlinearguments.h b/src/libs/qmldebug/qmldebugcommandlinearguments.h index f1d3d8933e9..407f991114e 100644 --- a/src/libs/qmldebug/qmldebugcommandlinearguments.h +++ b/src/libs/qmldebug/qmldebugcommandlinearguments.h @@ -27,6 +27,7 @@ #include #include +#include namespace QmlDebug { @@ -84,4 +85,15 @@ static inline QString qmlDebugLocalArguments(QmlDebugServicesPreset services, co return qmlDebugCommandLineArguments(services, QLatin1String("file:") + socket, block); } +static inline QString qmlDebugArguments(QmlDebugServicesPreset services, const QUrl &serverUrl, + bool block = true) +{ + if (serverUrl.scheme() == "socket") + return qmlDebugCommandLineArguments(services, "file:" + serverUrl.path(), block); + else + return qmlDebugCommandLineArguments(services, serverUrl.port() != -1 ? + QString("port:%1").arg(serverUrl.port()) : + "port:%qml_port%", block); +} + } // namespace QmlDebug diff --git a/src/plugins/android/androidanalyzesupport.cpp b/src/plugins/android/androidanalyzesupport.cpp index 60074d318b6..38d84d48630 100644 --- a/src/plugins/android/androidanalyzesupport.cpp +++ b/src/plugins/android/androidanalyzesupport.cpp @@ -29,7 +29,6 @@ #include "androidmanager.h" #include -#include #include #include @@ -37,9 +36,6 @@ #include -#include -#include - using namespace Debugger; using namespace ProjectExplorer; @@ -51,16 +47,9 @@ AndroidAnalyzeSupport::AndroidAnalyzeSupport(RunControl *runControl) { setDisplayName("AndroidAnalyzeSupport"); - AnalyzerConnection connection; - if (runMode() == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { - QTcpServer server; - QTC_ASSERT(server.listen(QHostAddress::LocalHost) - || server.listen(QHostAddress::LocalHostIPv6), return); - connection.analyzerHost = server.serverAddress().toString(); - } RunConfiguration *runConfig = runControl->runConfiguration(); runControl->setDisplayName(AndroidManager::packageName(runConfig->target())); - runControl->setConnection(connection); + runControl->setConnection(UrlConnection::localHostWithoutPort()); auto runner = new AndroidRunner(runControl); diff --git a/src/plugins/baremetal/baremetalruncontrolfactory.cpp b/src/plugins/baremetal/baremetalruncontrolfactory.cpp index 5cbe0948d71..3b419a493bd 100644 --- a/src/plugins/baremetal/baremetalruncontrolfactory.cpp +++ b/src/plugins/baremetal/baremetalruncontrolfactory.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/src/plugins/debugger/analyzer/analyzer.pri b/src/plugins/debugger/analyzer/analyzer.pri index 7fa5582dc78..6a0af3ab27e 100644 --- a/src/plugins/debugger/analyzer/analyzer.pri +++ b/src/plugins/debugger/analyzer/analyzer.pri @@ -13,7 +13,6 @@ SOURCES += \ HEADERS += \ $$PWD/analyzerconstants.h \ $$PWD/analyzermanager.h \ - $$PWD/analyzerstartparameters.h \ $$PWD/analyzerrunconfigwidget.h \ $$PWD/analyzerutils.h \ $$PWD/detailederrorview.h \ diff --git a/src/plugins/debugger/analyzer/analyzerstartparameters.h b/src/plugins/debugger/analyzer/analyzerstartparameters.h deleted file mode 100644 index 75ff6afaf22..00000000000 --- a/src/plugins/debugger/analyzer/analyzerstartparameters.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include - -#include -#include - -namespace Debugger { - -class DEBUGGER_EXPORT AnalyzerConnection -{ -public: - QSsh::SshConnectionParameters connParams; - QString analyzerHost; - QString analyzerSocket; - Utils::Port analyzerPort; - - static void *staticTypeId; -}; - -} // namespace Debugger diff --git a/src/plugins/debugger/analyzer/startremotedialog.cpp b/src/plugins/debugger/analyzer/startremotedialog.cpp index 65de8f2f7f3..89b03b8f2d8 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.cpp +++ b/src/plugins/debugger/analyzer/startremotedialog.cpp @@ -25,8 +25,6 @@ #include "startremotedialog.h" -#include "analyzerstartparameters.h" - #include #include #include @@ -130,11 +128,14 @@ void StartRemoteDialog::validate() d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); } -QSsh::SshConnectionParameters StartRemoteDialog::sshParams() const +QUrl StartRemoteDialog::serverUrl() const { + QUrl url; Kit *kit = d->kitChooser->currentKit(); IDevice::ConstPtr device = DeviceKitInformation::device(kit); - return device->sshParameters(); + url.setHost(device->sshParameters().host); + url.setPort(device->sshParameters().port); + return url; } StandardRunnable StartRemoteDialog::runnable() const diff --git a/src/plugins/debugger/analyzer/startremotedialog.h b/src/plugins/debugger/analyzer/startremotedialog.h index b7e1c337870..91e61873162 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.h +++ b/src/plugins/debugger/analyzer/startremotedialog.h @@ -28,8 +28,7 @@ #include #include - -namespace QSsh { class SshConnectionParameters; } +#include namespace ProjectExplorer { class StandardRunnable; } @@ -45,7 +44,7 @@ public: explicit StartRemoteDialog(QWidget *parent = 0); ~StartRemoteDialog() override; - QSsh::SshConnectionParameters sshParams() const; + QUrl serverUrl() const; ProjectExplorer::StandardRunnable runnable() const; private: diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs index 6e6b4d441de..b27af6cff61 100644 --- a/src/plugins/debugger/debugger.qbs +++ b/src/plugins/debugger/debugger.qbs @@ -239,7 +239,6 @@ Project { "analyzermanager.h", "analyzerrunconfigwidget.cpp", "analyzerrunconfigwidget.h", - "analyzerstartparameters.h", "analyzerutils.cpp", "analyzerutils.h", "detailederrorview.cpp", diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 9b4bb8a5be8..a4cd4a9559c 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -66,7 +66,6 @@ #include "analyzer/analyzerconstants.h" #include "analyzer/analyzermanager.h" -#include "analyzer/analyzerstartparameters.h" #include #include @@ -3799,9 +3798,6 @@ QList DebuggerPlugin::createTestObjects() const #endif // if WITH_TESTS } // namespace Internal - -void *AnalyzerConnection::staticTypeId = &AnalyzerConnection::staticTypeId; - } // namespace Debugger #include "debuggerplugin.moc" diff --git a/src/plugins/ios/iosrunfactories.cpp b/src/plugins/ios/iosrunfactories.cpp index f559d9754fb..740b21ae80c 100644 --- a/src/plugins/ios/iosrunfactories.cpp +++ b/src/plugins/ios/iosrunfactories.cpp @@ -31,7 +31,6 @@ #include "iosmanager.h" #include -#include #include #include diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index f2635a96001..9f30b7ba11d 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -32,7 +32,6 @@ #include "iossimulator.h" #include "iosconstants.h" -#include #include #include #include @@ -367,10 +366,8 @@ IosAnalyzeSupport::IosAnalyzeSupport(RunControl *runControl) StandardRunnable runnable; runnable.executable = iosRunConfig->localExecutable().toUserOutput(); runnable.commandLineArguments = iosRunConfig->commandLineArguments(); - Debugger::AnalyzerConnection connection; - connection.analyzerHost = "localhost"; runControl->setRunnable(runnable); - runControl->setConnection(connection); + runControl->setConnection(UrlConnection::localHostWithoutPort()); runControl->setDisplayName(iosRunConfig->applicationName()); connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, diff --git a/src/plugins/projectexplorer/runnables.cpp b/src/plugins/projectexplorer/runnables.cpp index a8c9be4aad2..2a6bf23d6cf 100644 --- a/src/plugins/projectexplorer/runnables.cpp +++ b/src/plugins/projectexplorer/runnables.cpp @@ -25,6 +25,10 @@ #include "runnables.h" +#include + +#include + namespace ProjectExplorer { bool operator==(const StandardRunnable &r1, const StandardRunnable &r2) @@ -37,4 +41,40 @@ bool operator==(const StandardRunnable &r1, const StandardRunnable &r2) void *StandardRunnable::staticTypeId = &StandardRunnable::staticTypeId; +UrlConnection UrlConnection::fromHost(const QString &host) +{ + UrlConnection connection; + connection.setHost(host); + return connection; +} + +UrlConnection UrlConnection::localHostWithoutPort() +{ + QUrl serverUrl; + QTcpServer server; + serverUrl.setHost(server.serverAddress().toString()); + return UrlConnection(serverUrl); +} + +UrlConnection UrlConnection::localHostAndFreePort() +{ + QUrl serverUrl; + QTcpServer server; + if (server.listen(QHostAddress::LocalHost) || server.listen(QHostAddress::LocalHostIPv6)) { + serverUrl.setHost(server.serverAddress().toString()); + serverUrl.setPort(server.serverPort()); + } + return UrlConnection(serverUrl); +} + +UrlConnection UrlConnection::localSocket() +{ + QUrl serverUrl; + serverUrl.setScheme(socketScheme()); + Utils::TemporaryFile file("qmlprofiler-freesocket"); + if (file.open()) + serverUrl.setPath(file.fileName()); + return UrlConnection(serverUrl); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runnables.h b/src/plugins/projectexplorer/runnables.h index 3d286a8b838..09c06e7754e 100644 --- a/src/plugins/projectexplorer/runnables.h +++ b/src/plugins/projectexplorer/runnables.h @@ -71,11 +71,12 @@ public: UrlConnection() {} explicit UrlConnection(const QUrl &url) : QUrl(url) {} - static UrlConnection fromHost(const QString &host) { - UrlConnection connection; - connection.setHost(host); - return connection; - } + static UrlConnection fromHost(const QString &host); + static UrlConnection localHostAndFreePort(); + static UrlConnection localHostWithoutPort(); + static UrlConnection localSocket(); + + static QString socketScheme() { return QLatin1String("socket"); } static void *staticTypeId; }; diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp index 17cde0886b9..5108b7bd245 100644 --- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp @@ -65,23 +65,10 @@ void QmlProfilerClientManager::setRetryParams(int interval, int maxAttempts) m_maximumRetries = maxAttempts; } -void QmlProfilerClientManager::setTcpConnection(QString host, Utils::Port port) +void QmlProfilerClientManager::setServerUrl(const QUrl &server) { - if (!m_localSocket.isEmpty() || m_tcpHost != host || m_tcpPort != port) { - m_tcpHost = host; - m_tcpPort = port; - m_localSocket.clear(); - disconnectClient(); - stopConnectionTimer(); - } -} - -void QmlProfilerClientManager::setLocalSocket(QString file) -{ - if (m_localSocket != file || !m_tcpHost.isEmpty() || m_tcpPort.isValid()) { - m_localSocket = file; - m_tcpHost.clear(); - m_tcpPort = Utils::Port(); + if (m_server != server) { + m_server = server; disconnectClient(); stopConnectionTimer(); } @@ -89,9 +76,7 @@ void QmlProfilerClientManager::setLocalSocket(QString file) void QmlProfilerClientManager::clearConnection() { - m_localSocket.clear(); - m_tcpHost.clear(); - m_tcpPort = Utils::Port(); + m_server.clear(); disconnectClient(); stopConnectionTimer(); } @@ -115,7 +100,7 @@ void QmlProfilerClientManager::connectToTcpServer() if (m_connection.isNull()) { // If the previous connection failed, recreate it. createConnection(); - m_connection->connectToHost(m_tcpHost, m_tcpPort.number()); + m_connection->connectToHost(m_server.host(), m_server.port()); } else if (m_numRetries < 3 && m_connection->socketState() != QAbstractSocket::ConnectedState) { // If we don't get connected in the first retry interval, drop the socket and try @@ -124,7 +109,7 @@ void QmlProfilerClientManager::connectToTcpServer() // On other operating systems (windows) every connection takes forever to get // established. So, after tearing down and rebuilding the socket twice, just // keep trying with the same one. - m_connection->connectToHost(m_tcpHost, m_tcpPort.number()); + m_connection->connectToHost(m_server.host(), m_server.port()); } // Else leave it alone and wait for hello. } else { // On final timeout, clear the connection. @@ -142,7 +127,7 @@ void QmlProfilerClientManager::connectToTcpServer() QTC_ASSERT(m_qmlclientplugin.isNull(), disconnectClient()); createConnection(); QTC_ASSERT(m_connection, emit connectionFailed(); return); - m_connection->connectToHost(m_tcpHost, m_tcpPort.number()); + m_connection->connectToHost(m_server.host(), m_server.port()); } } @@ -169,7 +154,7 @@ void QmlProfilerClientManager::startLocalServer() QTC_ASSERT(m_qmlclientplugin.isNull(), disconnectClient()); createConnection(); QTC_ASSERT(m_connection, emit connectionFailed(); return); - m_connection->startLocalServer(m_localSocket); + m_connection->startLocalServer(m_server.path()); } } @@ -181,9 +166,9 @@ void QmlProfilerClientManager::stopRecording() void QmlProfilerClientManager::retryConnect() { - if (!m_localSocket.isEmpty()) { + if (m_server.scheme() == "socket") { startLocalServer(); - } else if (!m_tcpHost.isEmpty() && m_tcpPort.isValid()) { + } else if (!m_server.host().isEmpty() && m_server.port() > -1) { disconnectClient(); connectToTcpServer(); } else { diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h index 2c4a78f6b09..61a9d178004 100644 --- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h +++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h @@ -28,12 +28,10 @@ #include "qmlprofilertraceclient.h" #include -#include #include #include -#include -#include +#include namespace QmlProfiler { class QmlProfilerModelManager; @@ -49,8 +47,7 @@ public: ~QmlProfilerClientManager(); void setProfilerStateManager(QmlProfilerStateManager *profilerState); - void setTcpConnection(QString host, Utils::Port port); - void setLocalSocket(QString file); + void setServerUrl(const QUrl &server); void clearConnection(); void clearBufferedData(); @@ -79,9 +76,7 @@ private: QTimer m_connectionTimer; - QString m_localSocket; - QString m_tcpHost; - Utils::Port m_tcpPort; + QUrl m_server; quint32 m_flushInterval = 0; int m_retryInterval = 200; diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index fb74804aa2a..3c7d65b2bf4 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -29,7 +29,6 @@ #include "qmlprofilerplugin.h" #include -#include #include #include @@ -37,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -51,15 +49,11 @@ #include #include -#include #include #include #include -#include #include -#include -#include #include using namespace Debugger; @@ -79,7 +73,7 @@ public: QmlProfilerStateManager *m_profilerState = 0; QTimer m_noDebugOutputTimer; bool m_isLocal = false; - QmlProfilerRunner::Configuration m_configuration; + QUrl m_serverUrl; ProjectExplorer::ApplicationLauncher m_launcher; QmlDebug::QmlOutputParser m_outputParser; }; @@ -116,29 +110,24 @@ void QmlProfilerRunner::start() Internal::QmlProfilerTool::instance()->finalizeRunControl(this); QTC_ASSERT(d->m_profilerState, return); - QTC_ASSERT(connection().is(), return); - auto conn = connection().as(); + QTC_ASSERT(connection().is(), return); + QUrl serverUrl = connection().as(); - if (conn.analyzerPort.isValid()) { + if (serverUrl.port() != -1) { auto clientManager = Internal::QmlProfilerTool::clientManager(); - clientManager->setTcpConnection(conn.analyzerHost, conn.analyzerPort); + clientManager->setServerUrl(serverUrl); clientManager->connectToTcpServer(); } - else if (conn.analyzerSocket.isEmpty()) + else if (serverUrl.path().isEmpty()) d->m_noDebugOutputTimer.start(); d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning); if (d->m_isLocal) { - QTC_ASSERT(!d->m_configuration.socket.isEmpty() || d->m_configuration.port.isValid(), return); + QTC_ASSERT(!d->m_serverUrl.path().isEmpty() || d->m_serverUrl.port() != -1, return); StandardRunnable debuggee = runnable().as(); - QString arguments = d->m_configuration.socket.isEmpty() ? - QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, - d->m_configuration.port) : - QmlDebug::qmlDebugLocalArguments(QmlDebug::QmlProfilerServices, - d->m_configuration.socket); - + QString arguments = QmlDebug::qmlDebugArguments(QmlDebug::QmlProfilerServices, d->m_serverUrl); if (!debuggee.commandLineArguments.isEmpty()) arguments += ' ' + debuggee.commandLineArguments; @@ -254,13 +243,15 @@ void QmlProfilerRunner::notifyRemoteSetupDone(Utils::Port port) { d->m_noDebugOutputTimer.stop(); - if (!port.isValid()) { - QTC_ASSERT(connection().is(), return); - port = connection().as().analyzerPort; - } + QTC_ASSERT(connection().is(), return); + QUrl serverUrl = connection().as(); + if (!port.isValid()) + port = Utils::Port(serverUrl.port()); + if (port.isValid()) { + serverUrl.setPort(port.number()); auto clientManager = Internal::QmlProfilerTool::clientManager(); - clientManager->setTcpConnection(connection().as().analyzerHost, port); + clientManager->setServerUrl(serverUrl); clientManager->connectToTcpServer(); } } @@ -291,33 +282,10 @@ void QmlProfilerRunner::profilerStateChanged() } } -QString QmlProfilerRunner::findFreeSocket() -{ - Utils::TemporaryFile file("qmlprofiler-freesocket"); - if (file.open()) { - return file.fileName(); - } else { - qWarning() << "Could not open a temporary file to find a debug socket."; - return QString(); - } -} - -Utils::Port QmlProfilerRunner::findFreePort(QString &host) -{ - QTcpServer server; - if (!server.listen(QHostAddress::LocalHost) - && !server.listen(QHostAddress::LocalHostIPv6)) { - qWarning() << "Cannot open port on host for QML profiling."; - return Utils::Port(); - } - host = server.serverAddress().toString(); - return Utils::Port(server.serverPort()); -} - -void QmlProfilerRunner::setLocalConfiguration(const Configuration &configuration) +void QmlProfilerRunner::setServerUrl(const QUrl &serverUrl) { d->m_isLocal = true; - d->m_configuration = configuration; + d->m_serverUrl = serverUrl; connect(&d->m_launcher, &ApplicationLauncher::appendMessage, this, &QmlProfilerRunner::appendMessage); connect(this, &QmlProfilerRunner::localRunnerStopped, diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h index 00979d01a7f..beea00b51d6 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h @@ -45,11 +45,7 @@ public: QmlProfilerRunner(ProjectExplorer::RunControl *runControl); ~QmlProfilerRunner() override; - struct Configuration { - Utils::Port port; - QString socket; - }; - void setLocalConfiguration(const Configuration &conf); + void setServerUrl(const QUrl &serverUrl); void registerProfilerStateManager( QmlProfilerStateManager *profilerState ); @@ -58,9 +54,6 @@ public: void cancelProcess(); void notifyRemoteFinished(); - static Utils::Port findFreePort(QString &host); - static QString findFreeSocket(); - signals: void localRunnerStarted(); void localRunnerStopped(); diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp index c1239ef6742..e59a58d8cf3 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp @@ -28,7 +28,6 @@ #include "qmlprofilerrunconfigurationaspect.h" #include -#include #include #include @@ -74,27 +73,23 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat QTC_ASSERT(runConfiguration->runnable().is(), return 0); Kit *kit = runConfiguration->target()->kit(); - AnalyzerConnection connection; + QUrl serverUrl; const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); if (version) { if (version->qtVersion() >= QtSupport::QtVersionNumber(5, 6, 0)) - connection.analyzerSocket = QmlProfilerRunner::findFreeSocket(); + serverUrl = UrlConnection::localSocket(); else - connection.analyzerPort = QmlProfilerRunner::findFreePort(connection.analyzerHost); + serverUrl = UrlConnection::localHostAndFreePort(); } else { - qWarning() << "Running QML profiler on Kit without Qt version??"; - connection.analyzerPort = QmlProfilerRunner::findFreePort(connection.analyzerHost); + qWarning("Running QML profiler on Kit without Qt version?"); + serverUrl = UrlConnection::localHostAndFreePort(); } auto runControl = new RunControl(runConfiguration, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); - runControl->setConnection(connection); - - QmlProfilerRunner::Configuration conf; - conf.socket = connection.analyzerSocket; - conf.port = connection.analyzerPort; + runControl->setConnection(UrlConnection(serverUrl)); auto runner = new QmlProfilerRunner(runControl); - runner->setLocalConfiguration(conf); + runner->setServerUrl(serverUrl); return runControl; } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 0a087b38354..c7529101d6b 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -40,7 +40,6 @@ #include #include -#include #include #include @@ -352,15 +351,14 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker) runWorker->registerProfilerStateManager(d->m_profilerState); QmlProfilerClientManager *clientManager = d->m_profilerConnections; - QTC_ASSERT(runWorker->connection().is(), return); + QTC_ASSERT(runWorker->connection().is(), return); // FIXME: Check that there's something sensible in sp.connParams - auto connection = runWorker->connection().as(); - if (!connection.analyzerSocket.isEmpty()) { - clientManager->setLocalSocket(connection.analyzerSocket); + auto serverUrl = runWorker->connection().as(); + clientManager->setServerUrl(serverUrl); + if (!serverUrl.path().isEmpty()) { + // That's the local socket case. // We open the server and the application connects to it, so let's do that right away. clientManager->startLocalServer(); - } else { - clientManager->setTcpConnection(connection.analyzerHost, connection.analyzerPort); } // @@ -579,23 +577,21 @@ void QmlProfilerTool::startRemoteTool() settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/port"), port); } - AnalyzerConnection connection; + QUrl serverUrl; IDevice::ConstPtr device = DeviceKitInformation::device(kit); - if (device) { - Connection toolControl = device->toolControlChannel(IDevice::QmlControlChannel); - QTC_ASSERT(toolControl.is(), return); - connection.analyzerHost = toolControl.as().host(); - connection.connParams = device->sshParameters(); - } - connection.analyzerPort = Utils::Port(port); + QTC_ASSERT(device, return); + Connection toolControl = device->toolControlChannel(IDevice::QmlControlChannel); + QTC_ASSERT(toolControl.is(), return); + serverUrl.setHost(toolControl.as().host()); + serverUrl.setPort(port); Debugger::selectPerspective(Constants::QmlProfilerPerspectiveId); RunConfiguration *rc = Debugger::startupRunConfiguration(); auto runControl = new RunControl(rc, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); runControl->createWorker(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); - runControl->setConnection(connection); + runControl->setConnection(UrlConnection(serverUrl)); ProjectExplorerPlugin::startRunControl(runControl); } diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp index db97b33ef4d..739ce2e5225 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp @@ -28,7 +28,6 @@ #include "../qmlprofilerruncontrol.h" #include -#include #include @@ -63,13 +62,13 @@ void LocalQmlProfilerRunnerTest::testRunner() debuggee.environment = Utils::Environment::systemEnvironment(); // should not be used anywhere but cannot be empty - configuration.socket = connection.analyzerSocket = QString("invalid"); + serverUrl.setPath("invalid"); rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); rc->setRunnable(debuggee); - rc->setConnection(connection); + rc->setConnection(UrlConnection(serverUrl)); auto runner = new QmlProfilerRunner(rc); - runner->setLocalConfiguration(configuration); + runner->setServerUrl(serverUrl); connectRunner(runner); rc->initiateStart(); @@ -81,7 +80,7 @@ void LocalQmlProfilerRunnerTest::testRunner1() QTRY_COMPARE_WITH_TIMEOUT(runCount, 1, 10000); QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); - configuration.socket = connection.analyzerSocket = QmlProfilerRunner::findFreeSocket(); + serverUrl = UrlConnection::localSocket(); debuggee.executable = QCoreApplication::applicationFilePath(); // comma is used to specify a test function. In this case, an invalid one. @@ -90,9 +89,9 @@ void LocalQmlProfilerRunnerTest::testRunner1() delete rc; rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); rc->setRunnable(debuggee); - rc->setConnection(connection); + rc->setConnection(serverUrl); auto runner = new QmlProfilerRunner(rc); - runner->setLocalConfiguration(configuration); + runner->setServerUrl(serverUrl); connectRunner(runner); rc->initiateStart(); QTimer::singleShot(0, this, &LocalQmlProfilerRunnerTest::testRunner2); @@ -106,15 +105,12 @@ void LocalQmlProfilerRunnerTest::testRunner2() delete rc; debuggee.commandLineArguments.clear(); - configuration.socket.clear(); - connection.analyzerSocket.clear(); - configuration.port = connection.analyzerPort = - QmlProfilerRunner::findFreePort(connection.analyzerHost); + serverUrl = UrlConnection::localHostAndFreePort(); rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); rc->setRunnable(debuggee); - rc->setConnection(connection); + rc->setConnection(serverUrl); auto runner = new QmlProfilerRunner(rc); - runner->setLocalConfiguration(configuration); + runner->setServerUrl(serverUrl); connectRunner(runner); rc->initiateStart(); @@ -136,17 +132,17 @@ void LocalQmlProfilerRunnerTest::testRunner4() void LocalQmlProfilerRunnerTest::testFindFreePort() { - QString host; - Utils::Port port = QmlProfilerRunner::findFreePort(host); - QVERIFY(port.isValid()); - QVERIFY(!host.isEmpty()); + QUrl serverUrl = UrlConnection::localHostAndFreePort(); + QVERIFY(serverUrl.port() != -1); + QVERIFY(!serverUrl.host().isEmpty()); QTcpServer server; - QVERIFY(server.listen(QHostAddress(host), port.number())); + QVERIFY(server.listen(QHostAddress(serverUrl.host()), serverUrl.port())); } void LocalQmlProfilerRunnerTest::testFindFreeSocket() { - QString socket = QmlProfilerRunner::findFreeSocket(); + QUrl serverUrl = UrlConnection::localSocket(); + QString socket = serverUrl.path(); QVERIFY(!socket.isEmpty()); QVERIFY(!QFile::exists(socket)); QFile file(socket); diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.h b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.h index 69c1604bcec..07b2d32cf6d 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.h +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.h @@ -27,7 +27,8 @@ #include #include -#include + +#include namespace QmlProfiler { namespace Internal { @@ -54,8 +55,7 @@ private: int runCount = 0; ProjectExplorer::RunControl *rc = nullptr; ProjectExplorer::StandardRunnable debuggee; - Debugger::AnalyzerConnection connection; - QmlProfilerRunner::Configuration configuration; + ProjectExplorer::UrlConnection serverUrl; }; } // namespace Internal diff --git a/src/plugins/qmlprofiler/tests/qmlprofilerclientmanager_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofilerclientmanager_test.cpp index f898782ec17..3dab1be2c01 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilerclientmanager_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofilerclientmanager_test.cpp @@ -35,6 +35,8 @@ #include +using namespace ProjectExplorer; + namespace QmlProfiler { namespace Internal { @@ -68,34 +70,41 @@ void QmlProfilerClientManagerTest::testConnectionFailure_data() QTest::addColumn("stateManager"); QVarLengthArray stateManagers({nullptr, &stateManager}); - QString hostName; - Utils::Port port = QmlProfilerRunner::findFreePort(hostName); + QUrl localUrl = UrlConnection::localHostAndFreePort(); - QTest::addColumn("host"); - QVarLengthArray hosts({"", "/-/|\\-\\|/-", hostName}); - - QTest::addColumn("port"); - QVarLengthArray ports({Utils::Port(), Utils::Port(5), port}); - - QTest::addColumn("socket"); - QVarLengthArray sockets({"", "/-/|\\-\\|/-", QmlProfilerRunner::findFreeSocket()}); + QTest::addColumn("serverUrl"); + QVarLengthArray hosts({"", "/-/|\\-\\|/-", localUrl.host()}); + QVarLengthArray ports({-1, 5, localUrl.port()}); + QVarLengthArray sockets({"", "/-/|\\-\\|/-", UrlConnection::localSocket().path()}); foreach (QmlProfilerModelManager *modelManager, modelManagers) { foreach (QmlProfilerStateManager *stateManager, stateManagers) { foreach (QString host, hosts) { - foreach (Utils::Port port, ports) { - foreach (QString socket, sockets) { - QString tag = QString::fromLatin1("%1, %2, %3, %4, %5") - .arg(QLatin1String(modelManager ? "modelManager" : "")) - .arg(QLatin1String(stateManager ? "stateManager" : "")) - .arg(host.isEmpty() ? "" : host) - .arg(port.isValid() ? port.number() : 0) - .arg(socket.isEmpty() ? "" : socket); - QTest::newRow(tag.toLatin1().constData()) - << modelManager << stateManager << host << port << socket; - } + foreach (int port, ports) { + QString tag = QString::fromLatin1("%1, %2, %3, %4, %5") + .arg(QLatin1String(modelManager ? "modelManager" : "")) + .arg(QLatin1String(stateManager ? "stateManager" : "")) + .arg(host.isEmpty() ? "" : host) + .arg(Utils::Port(port).isValid() ? port : 0) + .arg(""); + QUrl url; + url.setHost(host); + url.setPort(port); + QTest::newRow(tag.toLatin1().constData()) << modelManager << stateManager << url; } } + foreach (QString socket, sockets) { + QString tag = QString::fromLatin1("%1, %2, %3, %4, %5") + .arg(QLatin1String(modelManager ? "modelManager" : "")) + .arg(QLatin1String(stateManager ? "stateManager" : "")) + .arg("") + .arg(0) + .arg(socket); + QUrl url; + url.setScheme(ProjectExplorer::UrlConnection::socketScheme()); + url.setPath(socket); + QTest::newRow(tag.toLatin1().constData()) << modelManager << stateManager << url; + } } } } @@ -118,9 +127,7 @@ void QmlProfilerClientManagerTest::testConnectionFailure() QFETCH(QmlProfilerModelManager *, modelManager); QFETCH(QmlProfilerStateManager *, stateManager); - QFETCH(QString, host); - QFETCH(Utils::Port, port); - QFETCH(QString, socket); + QFETCH(QUrl, serverUrl); QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened())); QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed())); @@ -130,11 +137,7 @@ void QmlProfilerClientManagerTest::testConnectionFailure() clientManager.setModelManager(modelManager); clientManager.setProfilerStateManager(stateManager); - if (socket.isEmpty()) { - clientManager.setTcpConnection(host, port); - } else { - clientManager.setLocalSocket(socket); - } + clientManager.setServerUrl(serverUrl); QVERIFY(!clientManager.isConnected()); @@ -172,14 +175,13 @@ void QmlProfilerClientManagerTest::testUnresponsiveTcp() clientManager.setProfilerStateManager(&stateManager); clientManager.setModelManager(&modelManager); - QString hostName; - Utils::Port port = QmlProfilerRunner::findFreePort(hostName); + QUrl serverUrl = UrlConnection::localHostAndFreePort(); QTcpServer server; - server.listen(QHostAddress(hostName), port.number()); + server.listen(QHostAddress(serverUrl.host()), serverUrl.port()); QSignalSpy connectionSpy(&server, SIGNAL(newConnection())); - clientManager.setTcpConnection(hostName, port); + clientManager.setServerUrl(serverUrl); clientManager.connectToTcpServer(); QTRY_VERIFY(connectionSpy.count() > 0); @@ -202,14 +204,14 @@ void QmlProfilerClientManagerTest::testUnresponsiveLocal() clientManager.setProfilerStateManager(&stateManager); clientManager.setModelManager(&modelManager); - QString socketFile = QmlProfilerRunner::findFreeSocket(); + QUrl socketUrl = UrlConnection::localSocket(); QLocalSocket socket; QSignalSpy connectionSpy(&socket, SIGNAL(connected())); - clientManager.setLocalSocket(socketFile); + clientManager.setServerUrl(socketUrl); clientManager.startLocalServer(); - socket.connectToServer(socketFile); + socket.connectToServer(socketUrl.path()); QTRY_COMPARE(connectionSpy.count(), 1); QTRY_COMPARE(failedSpy.count(), 1); QCOMPARE(openedSpy.count(), 0); @@ -254,8 +256,7 @@ void QmlProfilerClientManagerTest::testResponsiveTcp() { QFETCH(quint32, flushInterval); - QString hostName; - Utils::Port port = QmlProfilerRunner::findFreePort(hostName); + QUrl serverUrl = UrlConnection::localHostAndFreePort(); QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened())); QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed())); @@ -270,7 +271,7 @@ void QmlProfilerClientManagerTest::testResponsiveTcp() fakeDebugServer(socket.data()); }); - server.listen(QHostAddress(hostName), port.number()); + server.listen(QHostAddress(serverUrl.host()), serverUrl.port()); clientManager.setProfilerStateManager(&stateManager); clientManager.setModelManager(&modelManager); @@ -279,7 +280,7 @@ void QmlProfilerClientManagerTest::testResponsiveTcp() connect(&clientManager, &QmlProfilerClientManager::connectionFailed, &clientManager, &QmlProfilerClientManager::retryConnect); - clientManager.setTcpConnection(hostName, port); + clientManager.setServerUrl(serverUrl); clientManager.connectToTcpServer(); QTRY_COMPARE(openedSpy.count(), 1); @@ -314,7 +315,7 @@ void QmlProfilerClientManagerTest::testResponsiveLocal() { QFETCH(quint32, flushInterval); - QString socketFile = QmlProfilerRunner::findFreeSocket(); + QUrl socketUrl = UrlConnection::localSocket(); QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened())); QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed())); @@ -328,12 +329,12 @@ void QmlProfilerClientManagerTest::testResponsiveLocal() connect(&clientManager, &QmlProfilerClientManager::connectionFailed, &clientManager, &QmlProfilerClientManager::retryConnect); - clientManager.setLocalSocket(socketFile); + clientManager.setServerUrl(socketUrl); clientManager.startLocalServer(); { QScopedPointer socket(new QLocalSocket(this)); - socket->connectToServer(socketFile); + socket->connectToServer(socketUrl.path()); QVERIFY(socket->isOpen()); fakeDebugServer(socket.data()); @@ -379,8 +380,7 @@ void QmlProfilerClientManagerTest::testInvalidData() clientManager.setProfilerStateManager(&stateManager); clientManager.setModelManager(&modelManager); - QString hostName; - Utils::Port port = QmlProfilerRunner::findFreePort(hostName); + QUrl serverUrl = UrlConnection::localHostAndFreePort(); bool dataSent = false; QTcpServer server; @@ -395,9 +395,9 @@ void QmlProfilerClientManagerTest::testInvalidData() dataSent = true; }); - server.listen(QHostAddress(hostName), port.number()); + server.listen(QHostAddress(serverUrl.host()), serverUrl.port()); - clientManager.setTcpConnection(hostName, port); + clientManager.setServerUrl(serverUrl); clientManager.connectToTcpServer(); QTRY_VERIFY(dataSent); @@ -411,7 +411,7 @@ void QmlProfilerClientManagerTest::testInvalidData() void QmlProfilerClientManagerTest::testStopRecording() { - QString socketFile = QmlProfilerRunner::findFreeSocket(); + QUrl socketUrl = UrlConnection::localSocket(); { QmlProfilerClientManager clientManager; @@ -427,11 +427,11 @@ void QmlProfilerClientManagerTest::testStopRecording() connect(&clientManager, &QmlProfilerClientManager::connectionFailed, &clientManager, &QmlProfilerClientManager::retryConnect); - clientManager.setLocalSocket(socketFile); + clientManager.setServerUrl(socketUrl); clientManager.startLocalServer(); QScopedPointer socket(new QLocalSocket(this)); - socket->connectToServer(socketFile); + socket->connectToServer(socketUrl.path()); QVERIFY(socket->isOpen()); fakeDebugServer(socket.data()); diff --git a/src/plugins/qnx/qnxruncontrolfactory.cpp b/src/plugins/qnx/qnxruncontrolfactory.cpp index a1e60198027..18a44abd0b0 100644 --- a/src/plugins/qnx/qnxruncontrolfactory.cpp +++ b/src/plugins/qnx/qnxruncontrolfactory.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 97c19cf6012..c6ec33c1227 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include @@ -293,9 +292,7 @@ CallgrindTool::CallgrindTool(QObject *parent) auto runControl = new RunControl(runConfig, CALLGRIND_RUN_MODE); const auto runnable = dlg.runnable(); runControl->setRunnable(runnable); - AnalyzerConnection connection; - connection.connParams = dlg.sshParams(); - runControl->setConnection(connection); + runControl->setConnection(UrlConnection(dlg.serverUrl())); runControl->setDisplayName(runnable.executable); createRunTool(runControl); ProjectExplorerPlugin::startRunControl(runControl); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 09b98c41520..b58457e5bf5 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -456,9 +455,7 @@ MemcheckTool::MemcheckTool(QObject *parent) rc->createWorker(MEMCHECK_RUN_MODE); const auto runnable = dlg.runnable(); rc->setRunnable(runnable); - AnalyzerConnection connection; - connection.connParams = dlg.sshParams(); - rc->setConnection(connection); + rc->setConnection(UrlConnection(dlg.serverUrl())); rc->setDisplayName(runnable.executable); ProjectExplorerPlugin::startRunControl(rc); }); diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp index 569b0d21f6d..9ede8d3e414 100644 --- a/src/plugins/valgrind/valgrindengine.cpp +++ b/src/plugins/valgrind/valgrindengine.cpp @@ -29,7 +29,6 @@ #include "valgrindplugin.h" #include -#include #include #include