diff options
author | hjk <[email protected]> | 2025-03-31 17:50:14 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2025-04-04 10:15:42 +0000 |
commit | 29b32cd6000e62f7a9cea1fbb1b76b066128f838 (patch) | |
tree | 1f9b819dc217cc59e48c5d319e38889da3f9540b | |
parent | f5928ad2dbf0aca9c3710db4297f9b0a582e60ca (diff) |
Debugger: Use QUrl for DebuggerRunParameters::m_remoteChannel
Change-Id: If5df09eafe3a869f700e8a468a6887e797884474
Reviewed-by: Jarek Kobus <[email protected]>
Reviewed-by: Eike Ziller <[email protected]>
Reviewed-by: David Schulz <[email protected]>
-rw-r--r-- | src/plugins/debugger/cdb/cdbengine.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerdialogs.cpp | 17 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerengine.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerengine.h | 10 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.cpp | 41 | ||||
-rw-r--r-- | src/plugins/debugger/lldb/lldbengine.cpp | 2 | ||||
-rw-r--r-- | src/plugins/ios/iosrunner.cpp | 6 | ||||
-rw-r--r-- | src/plugins/valgrind/memchecktool.cpp | 2 |
8 files changed, 48 insertions, 34 deletions
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index d1109ea0b56..045d483a74a 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -332,7 +332,7 @@ void CdbEngine::setupEngine() m_extensionFileName = extensionFi.fileName(); const bool isRemote = sp.startMode() == AttachToRemoteServer; if (isRemote) // Must be first - debugger.addArgs({"-remote", sp.remoteChannel()}); + debugger.addArgs({"-remote", sp.remoteChannel().toString()}); else debugger.addArg("-a" + m_extensionFileName); diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 56b932a6fc0..a6045680424 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -409,10 +409,14 @@ void StartApplicationDialog::run(bool attachRemote) DebuggerRunParameters &rp = debugger->runParameters(); const QString inputAddress = dialog.channelOverrideEdit->text(); - if (!inputAddress.isEmpty()) + if (!inputAddress.isEmpty()) { rp.setRemoteChannel(inputAddress); - else - rp.setRemoteChannel(dev->sshParameters().host() + ':' + QString::number(newParameters.serverPort)); + } else { + QUrl channel; + channel.setHost(dev->sshParameters().host()); + channel.setPort(newParameters.serverPort); + rp.setRemoteChannel(channel); + } rp.setDisplayName(newParameters.displayName()); rp.setBreakOnMain(newParameters.breakAtMain); rp.setDebugInfoLocation(newParameters.debugInfoLocation); @@ -435,7 +439,7 @@ void StartApplicationDialog::run(bool attachRemote) rp.setStartMode(AttachToRemoteServer); rp.setCloseMode(KillAtClose); rp.setUseContinueInsteadOfRun(true); - rp.setDisplayName(Tr::tr("Attach to %1").arg(rp.remoteChannel())); + rp.setDisplayName(Tr::tr("Attach to %1").arg(rp.remoteChannel().toDisplayString())); } runControl->start(); @@ -578,7 +582,10 @@ void runAttachToQmlPortDialog() rp.setQmlServer(qmlServer); const SshParameters sshParameters = device->sshParameters(); - rp.setRemoteChannel(sshParameters.host() + ':' + QString::number(sshParameters.port())); + QUrl channel; + channel.setHost(sshParameters.host()); + channel.setPort(sshParameters.port()); + rp.setRemoteChannel(channel); rp.setStartMode(AttachToQmlServer); runControl->start(); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 7cd295d292e..b6785544548 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -2932,7 +2932,7 @@ QString DebuggerEngine::formatStartParameters() const str << '\n'; } if (!rp.remoteChannel().isEmpty()) - str << "Remote: " << rp.remoteChannel() << '\n'; + str << "Remote: " << rp.remoteChannel().toDisplayString() << '\n'; if (!rp.qmlServer().host().isEmpty()) str << "QML server: " << rp.qmlServer().host() << ':' << rp.qmlServer().port() << '\n'; str << "Sysroot: " << rp.sysRoot() << '\n'; diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 10af13d4c67..6bd2c46129d 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -109,8 +109,11 @@ public: bool isQmlDebugging() const { return m_isQmlDebugging; } void setQmlDebugging(bool on) { m_isQmlDebugging = on; } - void setRemoteChannel(const QString &channel) { m_remoteChannel = channel; } - QString remoteChannel() const { return m_remoteChannel; } + void setRemoteChannel(const QUrl &channel) { m_remoteChannel = channel; } + QUrl remoteChannel() const { return m_remoteChannel; } + + void setRemoteChannelPipe(const QString &pipe) { m_remoteChannelPipe = pipe; } + QString remoteChannelPipe() const { return m_remoteChannelPipe; } void setUseExtendedRemote(bool on) { m_useExtendedRemote = on; } bool useExtendedRemote() const { return m_useExtendedRemote; } @@ -280,7 +283,8 @@ private: QUrl m_qmlServer; // Used by Qml debugging. bool m_isQmlDebugging = false; - QString m_remoteChannel; // Used by general remote debugging. + QUrl m_remoteChannel; // Used by general remote debugging. + QString m_remoteChannelPipe; bool m_useExtendedRemote = false; // Whether to use GDB's target extended-remote or not. Utils::FilePath m_symbolFile; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index c54620de2d2..efae5127cb0 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4598,6 +4598,23 @@ void GdbEngine::setupInferior() } } +static QString extractRemoteChannel(const QUrl &url, const QString &pipe) +{ + if (!pipe.isEmpty()) + return " | " + pipe; + + QString scheme = url.scheme(); + if (scheme.isEmpty()) + scheme = "tcp:"; + + // "Fix" the IPv6 case with host names without '['...']' + QString host = url.host(); + if (!host.startsWith('[') && host.count(':') >= 2) + host = '[' + host + ']'; + + return QString("%1:%2:%3").arg(scheme, host).arg(url.port()); +} + void GdbEngine::runEngine() { CHECK_STATE(EngineRunRequested); @@ -4609,7 +4626,7 @@ void GdbEngine::runEngine() claimInitialBreakpoints(); notifyEngineRunAndInferiorStopOk(); - runCommand({"target remote " + rp.remoteChannel()}); + runCommand({"target remote " + extractRemoteChannel(rp.remoteChannel(), rp.remoteChannelPipe())}); } else if (runParameters().isLocalAttachEngine()) { @@ -4873,26 +4890,8 @@ void GdbEngine::handleSetTargetAsync(const DebuggerResponse &response) void GdbEngine::callTargetRemote() { CHECK_STATE(EngineSetupRequested); - QString channel = runParameters().remoteChannel(); - // The remoteChannel string might have been created via a QUrl::toString - // which isn't suitable for `target qnx` or `target (extended-)remote` - // https://www.qnx.com/developers/docs/7.0.0/index.html#com.qnx.doc.neutrino.utilities/topic/g/gdb.html - // https://sourceware.org/gdb/current/onlinedocs/gdb.html/Connecting.html#index-remote-connection-commands - // so change any :// to just : - channel.replace("://", ":"); - - // Don't touch channels with explicitly set protocols. - if (!channel.startsWith("tcp:") && !channel.startsWith("udp:") - && !channel.startsWith("file:") && channel.contains(':') - && !channel.startsWith('|')) - { - // "Fix" the IPv6 case with host names without '['...']' - if (!channel.startsWith('[') && channel.count(':') >= 2) { - channel.insert(0, '['); - channel.insert(channel.lastIndexOf(':'), ']'); - } - channel = "tcp:" + channel; - } + const QString channel = extractRemoteChannel(runParameters().remoteChannel(), + runParameters().remoteChannelPipe()); if (m_isQnxGdb) runCommand({"target qnx " + channel, CB(handleTargetQnx)}); diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 8e7ebad2e09..2ab984dda15 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -311,7 +311,7 @@ void LldbEngine::handleLldbStarted() : rp.deviceSymbolsRoot()); cmd2.arg("remotechannel", ((rp.startMode() == AttachToRemoteProcess || rp.startMode() == AttachToRemoteServer) - ? rp.remoteChannel() : QString())); + ? rp.remoteChannel().toString(): QString())); QTC_CHECK( !rp.continueAfterAttach() || (rp.startMode() == AttachToRemoteProcess || rp.startMode() == AttachToLocalProcess diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index 35cbd8513ff..4da33cacd31 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -854,7 +854,11 @@ static void startDebugger(RunControl *runControl, DebuggerRunTool *debugger, Ios const bool qmlDebug = rp.isQmlDebugging(); if (cppDebug) { rp.setInferiorExecutable(data->localExecutable); - rp.setRemoteChannel("connect://localhost:" + gdbServerPort.toString()); + QUrl channel; + channel.setScheme("connect"); + channel.setHost("localhost"); + channel.setPort(gdbServerPort.number()); + rp.setRemoteChannel(channel); QString bundlePath = data->bundleDirectory.toUrlishString(); bundlePath.chop(4); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 6a1e5e6af56..ab1148a78a3 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -1048,7 +1048,7 @@ static ExecutableItem debuggerRecipe(const Storage<ProcessHandle> pidStorage, Ru DebuggerRunParameters &rp = debugger->runParameters(); rp.setStartMode(Debugger::AttachToRemoteServer); rp.setDisplayName(QString("VGdb %1").arg(pidStorage->pid())); - rp.setRemoteChannel(QString("| vgdb --pid=%1").arg(pidStorage->pid())); + rp.setRemoteChannelPipe(QString("vgdb --pid=%1").arg(pidStorage->pid())); rp.setUseContinueInsteadOfRun(true); rp.addExpectedSignal("SIGTRAP"); |