https://github.com/charles-zablit updated 
https://github.com/llvm/llvm-project/pull/205618

>From 964ab8b85c4e328a216a7322edf6ea6d1c08b810 Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Wed, 24 Jun 2026 18:49:32 +0100
Subject: [PATCH 1/3] [lldb][Windows] Support AF_UNIX domain sockets

---
 lldb/source/Host/CMakeLists.txt                       |  1 +
 lldb/source/Host/common/DomainSocket.cpp              |  3 +++
 lldb/source/Host/common/Socket.cpp                    |  2 +-
 lldb/tools/lldb-server/lldb-platform.cpp              |  2 +-
 lldb/unittests/Host/SocketTest.cpp                    | 11 +++++++++--
 .../TestingSupport/Host/SocketTestUtilities.cpp       |  7 ++++---
 .../TestingSupport/Host/SocketTestUtilities.h         |  4 ++--
 7 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index 57a833af97184..96a1c4d865c79 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -74,6 +74,7 @@ endif()
 
 add_host_subdirectory(posix
   posix/ConnectionFileDescriptorPosix.cpp
+  posix/DomainSocket.cpp
   )
 
 if (CMAKE_SYSTEM_NAME MATCHES "Windows")
diff --git a/lldb/source/Host/common/DomainSocket.cpp 
b/lldb/source/Host/common/DomainSocket.cpp
index 988b8238a3cce..7b9d652136d91 100644
--- a/lldb/source/Host/common/DomainSocket.cpp
+++ b/lldb/source/Host/common/DomainSocket.cpp
@@ -15,13 +15,16 @@
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
+#include <chrono>
 #include <cstddef>
 #include <memory>
 
 #ifdef _WIN32
 #include <afunix.h>
 #else
+#include <fcntl.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #endif
diff --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index c0247509df1c1..629cb8a6f90cb 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -211,7 +211,7 @@ std::unique_ptr<Socket> Socket::Create(const SocketProtocol 
protocol,
     socket_up = std::make_unique<UDPSocket>(should_close);
     break;
   case ProtocolUnixDomain:
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
     socket_up = std::make_unique<DomainSocket>(should_close);
 #else
     error = Status::FromErrorString(
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index b1f03b36c578f..4936d41fc363f 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -537,7 +537,7 @@ int main_platform(int argc, char *argv[]) {
     if (gdbserver_port) {
       socket = std::make_unique<TCPSocket>(sockfd, /*should_close=*/true);
     } else {
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
       llvm::Expected<std::unique_ptr<DomainSocket>> domain_socket =
           DomainSocket::FromBoundNativeSocket(sockfd, /*should_close=*/true);
       if (!domain_socket) {
diff --git a/lldb/unittests/Host/SocketTest.cpp 
b/lldb/unittests/Host/SocketTest.cpp
index 45dcce83ca0a7..d080946108028 100644
--- a/lldb/unittests/Host/SocketTest.cpp
+++ b/lldb/unittests/Host/SocketTest.cpp
@@ -93,6 +93,11 @@ TEST_F(SocketTest, CreatePair) {
     functional_protocols.push_back(Socket::ProtocolUnixDomain);
     functional_protocols.push_back(Socket::ProtocolUnixAbstract);
   }
+#elif defined(_WIN32)
+  // Windows supports AF_UNIX domain sockets (Windows 10 1803+) but not the
+  // Linux abstract-namespace variant.
+  if (HostSupportsDomainSockets())
+    functional_protocols.push_back(Socket::ProtocolUnixDomain);
 #endif
 
   for (auto p : functional_protocols) {
@@ -111,7 +116,7 @@ TEST_F(SocketTest, CreatePair) {
 
   std::vector<Socket::SocketProtocol> erroring_protocols = {
 #if !LLDB_ENABLE_POSIX
-      Socket::ProtocolUnixDomain,
+      // Windows has AF_UNIX domain sockets but no abstract-namespace sockets.
       Socket::ProtocolUnixAbstract,
 #endif
   };
@@ -121,7 +126,7 @@ TEST_F(SocketTest, CreatePair) {
   }
 }
 
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
 TEST_F(SocketTest, DomainListenConnectAccept) {
   if (!HostSupportsDomainSockets())
     GTEST_SKIP() << "Domain sockets unavailable";
@@ -397,7 +402,9 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 
   EXPECT_EQ(socket_b_up->GetRemoteConnectionURI(), "");
 }
+#endif
 
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
 TEST_F(SocketTest, DomainSocketFromBoundNativeSocket) {
   if (!HostSupportsDomainSockets())
     GTEST_SKIP() << "Domain sockets unavailable";
diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp 
b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
index 2c5e310ea9a9b..5b66004a7a33e 100644
--- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
+++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
@@ -71,7 +71,7 @@ bool lldb_private::CreateTCPConnectedSockets(
   return true;
 }
 
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
 void lldb_private::CreateDomainConnectedSockets(
     llvm::StringRef path, std::unique_ptr<DomainSocket> *socket_a_up,
     std::unique_ptr<DomainSocket> *socket_b_up) {
@@ -148,16 +148,17 @@ llvm::Expected<std::string> 
lldb_private::GetLocalhostIP() {
       "Neither IPv4 nor IPv6 appear to be supported");
 }
 
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
 bool lldb_private::HostSupportsDomainSockets() {
   llvm::SmallString<64> Path;
   if (llvm::sys::fs::createUniqueDirectory("SocketTestCanary", Path))
     return false;
+  auto cleanup_dir = Path;
   llvm::sys::path::append(Path, "test");
   DomainSocket sock(true);
   Status status = sock.Listen(Path, 1);
   llvm::sys::fs::remove(Path);
-  llvm::sys::fs::remove(Path.str().rsplit('/').first);
+  llvm::sys::fs::remove(cleanup_dir);
   return status.Success();
 }
 #endif
diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h 
b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
index a03baf190dd33..bde9b0a778789 100644
--- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
+++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
@@ -34,7 +34,7 @@ void CreateConnectedSockets(
 bool CreateTCPConnectedSockets(std::string listen_remote_ip,
                                std::unique_ptr<TCPSocket> *a_up,
                                std::unique_ptr<TCPSocket> *b_up);
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
 void CreateDomainConnectedSockets(llvm::StringRef path,
                                   std::unique_ptr<DomainSocket> *a_up,
                                   std::unique_ptr<DomainSocket> *b_up);
@@ -42,7 +42,7 @@ void CreateDomainConnectedSockets(llvm::StringRef path,
 
 bool HostSupportsIPv6();
 bool HostSupportsIPv4();
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
 bool HostSupportsDomainSockets();
 #endif
 

>From ad36cc6250b47a42f918fd3dd37b58e6f3423c30 Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Mon, 29 Jun 2026 18:08:38 +0100
Subject: [PATCH 2/3] fixup! [lldb][Windows] Support AF_UNIX domain sockets

---
 lldb/source/Host/CMakeLists.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index 96a1c4d865c79..57a833af97184 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -74,7 +74,6 @@ endif()
 
 add_host_subdirectory(posix
   posix/ConnectionFileDescriptorPosix.cpp
-  posix/DomainSocket.cpp
   )
 
 if (CMAKE_SYSTEM_NAME MATCHES "Windows")

>From c0e902c1f9ffa9f530ff9196bb11fe9f61e26b7d Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Tue, 30 Jun 2026 14:08:13 +0100
Subject: [PATCH 3/3] fixup! [lldb][Windows] Support AF_UNIX domain sockets

---
 lldb/source/Host/common/Socket.cpp                       | 2 +-
 lldb/unittests/TestingSupport/Host/SocketTestUtilities.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index 629cb8a6f90cb..a6d71cf1ec105 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -242,7 +242,7 @@ Socket::CreatePair(std::optional<SocketProtocol> protocol) {
   case ProtocolTcp:
     return TCPSocket::CreatePair();
   case ProtocolUnixDomain:
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
     return DomainSocketPlatform::CreatePair();
 #else
     return llvm::createStringError("unsupported protocol");
diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h 
b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
index bde9b0a778789..39995b0d4b5b9 100644
--- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
+++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
@@ -21,7 +21,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Testing/Support/Error.h"
 
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX || defined(_WIN32)
 #include "lldb/Host/common/DomainSocket.h"
 #endif
 

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to