https://github.com/aperez updated 
https://github.com/llvm/llvm-project/pull/146603

>From 8ffabe86dd320880736c691e45e71611988ceb38 Mon Sep 17 00:00:00 2001
From: Alexandre Perez <alexandrepe...@meta.com>
Date: Tue, 1 Jul 2025 14:19:45 -0700
Subject: [PATCH 1/2] [lldb][mcp] Fix unix domain socket protocol server
 addresses

---
 lldb/source/Commands/CommandObjectProtocolServer.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectProtocolServer.cpp 
b/lldb/source/Commands/CommandObjectProtocolServer.cpp
index 55bd42ed1a533..4cafd2266e235 100644
--- a/lldb/source/Commands/CommandObjectProtocolServer.cpp
+++ b/lldb/source/Commands/CommandObjectProtocolServer.cpp
@@ -75,9 +75,12 @@ class CommandObjectProtocolServerStart : public 
CommandObjectParsed {
 
     ProtocolServer::Connection connection;
     connection.protocol = protocol_and_mode->first;
-    connection.name =
-        formatv("[{0}]:{1}", uri->hostname.empty() ? "0.0.0.0" : uri->hostname,
-                uri->port.value_or(0));
+    if (connection.protocol == Socket::SocketProtocol::ProtocolUnixDomain)
+      connection.name = uri->path;
+    else
+      connection.name = formatv(
+          "[{0}]:{1}", uri->hostname.empty() ? "0.0.0.0" : uri->hostname,
+          uri->port.value_or(0));
 
     if (llvm::Error error = server->Start(connection)) {
       result.AppendErrorWithFormatv("{0}", 
llvm::fmt_consume(std::move(error)));

>From 42150df6829d641756aa5bfc060ac579447c0391 Mon Sep 17 00:00:00 2001
From: Alexandre Perez <alexandrepe...@meta.com>
Date: Wed, 2 Jul 2025 10:14:09 -0700
Subject: [PATCH 2/2] Add test

---
 .../Commands/CommandObjectProtocolServer.cpp  |  1 +
 .../commands/protocol/TestMCPUnixSocket.py    | 23 +++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 lldb/test/API/commands/protocol/TestMCPUnixSocket.py

diff --git a/lldb/source/Commands/CommandObjectProtocolServer.cpp 
b/lldb/source/Commands/CommandObjectProtocolServer.cpp
index 4cafd2266e235..f11e27f01c8a8 100644
--- a/lldb/source/Commands/CommandObjectProtocolServer.cpp
+++ b/lldb/source/Commands/CommandObjectProtocolServer.cpp
@@ -93,6 +93,7 @@ class CommandObjectProtocolServerStart : public 
CommandObjectParsed {
       result.AppendMessageWithFormatv(
           "{0} server started with connection listeners: {1}", protocol,
           address);
+      result.SetStatus(eReturnStatusSuccessFinishNoResult);
     }
   }
 };
diff --git a/lldb/test/API/commands/protocol/TestMCPUnixSocket.py 
b/lldb/test/API/commands/protocol/TestMCPUnixSocket.py
new file mode 100644
index 0000000000000..6f5405b82666d
--- /dev/null
+++ b/lldb/test/API/commands/protocol/TestMCPUnixSocket.py
@@ -0,0 +1,23 @@
+import os
+import tempfile
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class MCPUnixSocketCommandTestCase(TestBase):
+    @skipIfWindows
+    @no_debug_info_test
+    def test_unix_socket(self):
+        """
+        Test if we can start an MCP protocol-server accepting unix sockets
+        """
+
+        temp_directory = tempfile.TemporaryDirectory()
+        socket_file = os.path.join(temp_directory.name, "mcp.sock")
+
+        self.expect(
+            f"protocol-server start MCP accept://{socket_file}",
+            startstr="MCP server started with connection listeners:",
+            substrs=[f"unix-connect://{socket_file}"],
+        )

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to