From 2eda632ab3292efd2c23a53adf67e04ec2f0179a Mon Sep 17 00:00:00 2001
From: Fawzi Mohamed <fawzi.mohamed@nokia.com>
Date: Wed, 22 Feb 2012 19:17:30 +0100
Subject: [PATCH] remote debugger: wrap IPv6 addresses of remote gdb in [] as
 per rfc2732.

Change-Id: I590f7e8e7e45a45fc699732fdefbd5130a06d3e1
Reviewed-by: hjk <qthjk@ovi.com>
---
 src/plugins/remotelinux/remotelinuxdebugsupport.cpp | 5 ++++-
 src/plugins/remotelinux/startgdbserverdialog.cpp    | 7 ++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
index 3a2406b9d27..469024decc0 100644
--- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
+++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
@@ -110,7 +110,10 @@ DebuggerStartParameters AbstractRemoteLinuxDebugSupport::startParameters(const R
         params.startMode = AttachToRemoteServer;
         params.executable = runConfig->localExecutableFilePath();
         params.debuggerCommand = runConfig->gdbCmd();
-        params.remoteChannel = devConf->sshParameters().host + QLatin1String(":-1");
+        QString host = devConf->sshParameters().host;
+        params.remoteChannel = host.contains(QLatin1Char(':'))
+                ? QString::fromLatin1("[%1]:-1").arg(host)
+                : host + QLatin1String(":-1");
 
         // TODO: This functionality should be inside the debugger.
         const ProjectExplorer::Abi &abi = runConfig->target()
diff --git a/src/plugins/remotelinux/startgdbserverdialog.cpp b/src/plugins/remotelinux/startgdbserverdialog.cpp
index bbd0619c7db..f12369d7238 100644
--- a/src/plugins/remotelinux/startgdbserverdialog.cpp
+++ b/src/plugins/remotelinux/startgdbserverdialog.cpp
@@ -359,7 +359,12 @@ void StartGdbServerDialog::reportOpenPort(int port)
         return;
 
     LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
-    QString channel = QString("%1:%2").arg(device->sshParameters().host).arg(port);
+    QString host = device->sshParameters().host;
+    QString channel;
+    if (host.contains(QLatin1Char(':')))
+        channel = QString::fromLatin1("[%1]:%2").arg(host).arg(port);
+    else
+        channel = QString::fromLatin1("%1:%2").arg(host).arg(port);
     logMessage(tr("Server started on %1").arg(channel));
 
     QMetaObject::invokeMethod(ob, "gdbServerStarted", Qt::QueuedConnection,
-- 
GitLab