[Lldb-commits] [lldb] [lldb] Extract URI schemes manually to support Windows paths (PR #206985)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 1 09:01:09 PDT 2026
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/206985
>From 8b897129938714430e907c8e7780c8df622b0f87 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 1 Jul 2026 14:44:35 +0100
Subject: [PATCH 1/3] [lldb] Extract URI schemes manually to support Windows
paths
---
.../gdb-server/PlatformRemoteGDBServer.cpp | 24 ++++++++++++++-----
.../GDBRemoteCommunicationServerLLGS.cpp | 12 ++++++----
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 1f69ef5f3f6ca..55fdc94df4b99 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -19,6 +19,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/PosixApi.h"
+#include "lldb/Host/Socket.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/FileSpec.h"
@@ -226,13 +227,24 @@ Status PlatformRemoteGDBServer::ConnectRemote(Args &args) {
if (!url)
return Status::FromErrorString("URL is null.");
- std::optional<URI> parsed_url = URI::Parse(url);
- if (!parsed_url)
- return Status::FromErrorStringWithFormat("Invalid URL: %s", url);
+ // Parse the scheme manually because URI::parse does not handle Windows paths.
+ llvm::StringRef scheme = llvm::StringRef(url).split("://").first;
+ std::optional<Socket::ProtocolModePair> protocol_and_mode =
+ Socket::GetProtocolAndMode(scheme);
+ if (protocol_and_mode &&
+ (protocol_and_mode->first == Socket::ProtocolUnixDomain ||
+ protocol_and_mode->first == Socket::ProtocolUnixAbstract)) {
+ m_platform_scheme = scheme.str();
+ m_platform_hostname = "";
+ } else {
+ std::optional<URI> parsed_url = URI::Parse(url);
+ if (!parsed_url)
+ return Status::FromErrorStringWithFormat("Invalid URL: %s", url);
- // We're going to reuse the hostname when we connect to the debugserver.
- m_platform_scheme = parsed_url->scheme.str();
- m_platform_hostname = parsed_url->hostname.str();
+ // We're going to reuse the hostname when we connect to the debugserver.
+ m_platform_scheme = parsed_url->scheme.str();
+ m_platform_hostname = parsed_url->hostname.str();
+ }
auto client_up =
std::make_unique<process_gdb_remote::GDBRemoteCommunicationClient>();
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 769705588fbdf..948e939a02613 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -4560,20 +4560,22 @@ void GDBRemoteCommunicationServerLLGS::AppendThreadIDToResponse(
std::string
lldb_private::process_gdb_remote::LLGSArgToURL(llvm::StringRef url_arg,
bool reverse_connect) {
- // Try parsing the argument as URL.
- if (std::optional<URI> url = URI::Parse(url_arg)) {
+ // Parse the scheme manually because URI::parse does not handle Windows paths.
+ constexpr llvm::StringRef kSchemeSep = "://";
+ if (size_t pos = url_arg.find(kSchemeSep); pos != llvm::StringRef::npos) {
if (reverse_connect)
return url_arg.str();
// Translate the scheme from LLGS notation to ConnectionFileDescriptor.
// If the scheme doesn't match any, pass it through to support using CFD
// schemes directly.
- std::string new_url = llvm::StringSwitch<std::string>(url->scheme)
+ llvm::StringRef scheme = url_arg.substr(0, pos);
+ std::string new_url = llvm::StringSwitch<std::string>(scheme)
.Case("tcp", "listen")
.Case("unix", "unix-accept")
.Case("unix-abstract", "unix-abstract-accept")
- .Default(url->scheme.str());
- llvm::append_range(new_url, url_arg.substr(url->scheme.size()));
+ .Default(scheme.str());
+ llvm::append_range(new_url, url_arg.substr(scheme.size()));
return new_url;
}
>From 52b7d2cf85f6ffaaacf5d61720c9fd4d40a93d11 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 1 Jul 2026 16:38:40 +0100
Subject: [PATCH 2/3] inline variable
---
.../Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 948e939a02613..f550c82d0885f 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -4561,8 +4561,7 @@ std::string
lldb_private::process_gdb_remote::LLGSArgToURL(llvm::StringRef url_arg,
bool reverse_connect) {
// Parse the scheme manually because URI::parse does not handle Windows paths.
- constexpr llvm::StringRef kSchemeSep = "://";
- if (size_t pos = url_arg.find(kSchemeSep); pos != llvm::StringRef::npos) {
+ if (size_t pos = url_arg.find("://"); pos != llvm::StringRef::npos) {
if (reverse_connect)
return url_arg.str();
>From b58e5d550d04029a021e9b728408f75df77db57a Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 1 Jul 2026 17:00:55 +0100
Subject: [PATCH 3/3] add comment
---
.../Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 55fdc94df4b99..22d30d660d9c3 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -235,6 +235,7 @@ Status PlatformRemoteGDBServer::ConnectRemote(Args &args) {
(protocol_and_mode->first == Socket::ProtocolUnixDomain ||
protocol_and_mode->first == Socket::ProtocolUnixAbstract)) {
m_platform_scheme = scheme.str();
+ // The URI contains a filepath, the hostname is empty.
m_platform_hostname = "";
} else {
std::optional<URI> parsed_url = URI::Parse(url);
More information about the lldb-commits
mailing list