Commit cb4bfaf9 authored by Aurindam Jana's avatar Aurindam Jana
Browse files

QmlProfiler: Use a port from the device port range



Check for free ports from the range of device ports instead of
using a fixed port.

Change-Id: I30b2e141ae6bce1ddd90294d4b802e2c9943424b
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@digia.com>
parent 53ce5340
......@@ -37,6 +37,9 @@
#include <debugger/debuggerrunconfigurationaspect.h>
#include <utils/qtcassert.h>
#include <coreplugin/helpmanager.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <qmlprojectmanager/qmlprojectrunconfiguration.h>
#include <qmlprojectmanager/qmlprojectplugin.h>
#include <projectexplorer/environmentaspect.h>
......@@ -44,6 +47,7 @@
#include <projectexplorer/localapplicationrunconfiguration.h>
#include <qmldebug/qmloutputparser.h>
#include <remotelinux/remotelinuxrunconfiguration.h>
#include <utils/tcpportsgatherer.h>
#include <QMainWindow>
#include <QMessageBox>
......@@ -91,31 +95,40 @@ QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(ProjectExplorer::RunCo
ProjectExplorer::EnvironmentAspect *environment
= runConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
QTC_ASSERT(environment, return 0);
if (QmlProjectManager::QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration)) {
// This is a "plain" .qmlproject.
LocalQmlProfilerRunner::Configuration conf;
conf.executable = rc1->observerPath();
conf.executableArguments = rc1->viewerArguments();
conf.workingDirectory = rc1->workingDirectory();
conf.environment = environment->environment();
conf.port = debugger->qmlDebugServerPort();
runner = new LocalQmlProfilerRunner(conf, parent);
} else if (LocalApplicationRunConfiguration *rc2 =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) {
// FIXME: Check.
LocalQmlProfilerRunner::Configuration conf;
conf.executable = rc2->executable();
conf.executableArguments = rc2->commandLineArguments();
conf.workingDirectory = rc2->workingDirectory();
conf.environment = environment->environment();
conf.port = debugger->qmlDebugServerPort();
runner = new LocalQmlProfilerRunner(conf, parent);
} else if (RemoteLinux::RemoteLinuxRunConfiguration *rmConfig =
if (RemoteLinux::RemoteLinuxRunConfiguration *rmConfig =
qobject_cast<RemoteLinux::RemoteLinuxRunConfiguration *>(runConfiguration)) {
runner = new RemoteLinuxQmlProfilerRunner(rmConfig, parent);
} else {
QTC_CHECK(false);
LocalQmlProfilerRunner::Configuration conf;
if (QmlProjectManager::QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration)) {
// This is a "plain" .qmlproject.
conf.executable = rc1->observerPath();
conf.executableArguments = rc1->viewerArguments();
conf.workingDirectory = rc1->workingDirectory();
conf.environment = environment->environment();
} else if (LocalApplicationRunConfiguration *rc2 =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) {
// FIXME: Check.
conf.executable = rc2->executable();
conf.executableArguments = rc2->commandLineArguments();
conf.workingDirectory = rc2->workingDirectory();
conf.environment = environment->environment();
} else {
QTC_CHECK(false);
}
const ProjectExplorer::IDevice::ConstPtr device =
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
Utils::TcpPortsGatherer portsGatherer;
portsGatherer.update(QAbstractSocket::UnknownNetworkLayerProtocol);
Utils::PortList portList = device->freePorts();
int freePort = portsGatherer.getNextFreePort(&portList);
if (freePort == -1)
return 0;
conf.port = freePort;
runner = new LocalQmlProfilerRunner(conf, parent);
}
return runner;
}
......
......@@ -48,11 +48,13 @@
#include <utils/fancymainwindow.h>
#include <utils/fileinprojectfinder.h>
#include <utils/qtcassert.h>
#include <utils/tcpportsgatherer.h>
#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <projectexplorer/session.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/localapplicationrunconfiguration.h>
#include <texteditor/itexteditor.h>
......@@ -305,7 +307,6 @@ AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration
Debugger::DebuggerRunConfigurationAspect *debugger
= runConfiguration->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
QTC_ASSERT(debugger, return sp);
sp.startMode = StartQml; // FIXME: The parameter struct is not needed/not used.
// FIXME: This is only used to communicate the connParams settings.
if (QmlProjectRunConfiguration *rc1 =
......@@ -318,7 +319,6 @@ AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration
sp.debuggeeArgs = rc1->viewerArguments();
sp.displayName = rc1->displayName();
sp.connParams.host = QLatin1String("localhost");
sp.connParams.port = debugger->qmlDebugServerPort();
} else if (LocalApplicationRunConfiguration *rc2 =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) {
if (environment)
......@@ -328,7 +328,6 @@ AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration
sp.debuggeeArgs = rc2->commandLineArguments();
sp.displayName = rc2->displayName();
sp.connParams.host = QLatin1String("localhost");
sp.connParams.port = debugger->qmlDebugServerPort();
} else if (RemoteLinux::RemoteLinuxRunConfiguration *rc3 =
qobject_cast<RemoteLinux::RemoteLinuxRunConfiguration *>(runConfiguration)) {
sp.debuggee = rc3->remoteExecutableFilePath();
......@@ -341,6 +340,18 @@ AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration
// What could that be?
QTC_ASSERT(false, return sp);
}
const ProjectExplorer::IDevice::ConstPtr device =
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
Utils::TcpPortsGatherer portsGatherer;
portsGatherer.update(QAbstractSocket::UnknownNetworkLayerProtocol);
Utils::PortList portList = device->freePorts();
int freePort = portsGatherer.getNextFreePort(&portList);
if (freePort == -1)
return sp;
sp.connParams.port = freePort;
}
sp.startMode = StartQml;
return sp;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment