From 4e832deb02d49ed19967f806581067c5c21c3cbb Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Wed, 17 Apr 2013 12:21:00 +0200 Subject: [PATCH] Valgrind: Use a port from the device port range Change-Id: I046e536dfca0c84dd0dba4901aa316a31d4c4b43 Reviewed-by: Christiaan Janssen --- src/plugins/valgrind/valgrindtool.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/valgrind/valgrindtool.cpp b/src/plugins/valgrind/valgrindtool.cpp index 035e2cd6d61..793313397e1 100644 --- a/src/plugins/valgrind/valgrindtool.cpp +++ b/src/plugins/valgrind/valgrindtool.cpp @@ -37,6 +37,9 @@ #include #include #include +#include + +#include using namespace ProjectExplorer; using namespace RemoteLinux; @@ -65,15 +68,23 @@ Analyzer::AnalyzerStartParameters ValgrindTool::createStartParameters( qobject_cast(runConfiguration)) { ProjectExplorer::EnvironmentAspect *aspect = runConfiguration->extraAspect(); - sp.startMode = Analyzer::StartLocal; if (aspect) sp.environment = aspect->environment(); sp.workingDirectory = rc1->workingDirectory(); sp.debuggee = rc1->executable(); sp.debuggeeArgs = rc1->commandLineArguments(); sp.connParams.host = QLatin1String("localhost"); - sp.connParams.port = rc1->extraAspect() - ->qmlDebugServerPort(); + const ProjectExplorer::IDevice::ConstPtr device = + ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit()); + QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return sp); + 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 = Analyzer::StartLocal; } else if (RemoteLinuxRunConfiguration *rc2 = qobject_cast(runConfiguration)) { sp.startMode = Analyzer::StartRemote;