https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/175195

>From 9bee0a6dd91262bf84567d7a144102817b582613 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <[email protected]>
Date: Fri, 9 Jan 2026 08:09:25 -0800
Subject: [PATCH 1/2] [lldb] Honor the process plugin name in the attach info

When connected to a GDB remote platform, we always use "gdb-remote" as
the process plugin when attaching. This means that the `--plugin`
argument to `process attach` is effectively ignored. This patch makes it
so that "gdb-remote" remains the default, while still honoring the
process plugin name specified in the attach info.

rdar://167845923
---
 .../Platform/gdb-server/PlatformRemoteGDBServer.cpp | 13 ++++++++++---
 .../gdb_remote_client/TestPlatformAttach.py         |  2 ++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git 
a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp 
b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 4a77423bac526..a4f9036bf2f0c 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -505,11 +505,18 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach(
           error.Clear();
 
         if (target && error.Success()) {
-          // The darwin always currently uses the GDB remote debugger plug-in
-          // so even when debugging locally we are debugging remotely!
+          // By default, we always use the GDB remote debugger plug-in.
+          // Even when debugging locally, we are debugging remotely.
+          llvm::StringRef process_plugin = "gdb-remote";
+
+          // However, if a process plugin is specified by the attach info, we
+          // should honor it.
+          if (!attach_info.GetProcessPluginName().empty())
+            process_plugin = attach_info.GetProcessPluginName();
+
           process_sp =
               
target->CreateProcess(attach_info.GetListenerForProcess(debugger),
-                                    "gdb-remote", nullptr, true);
+                                    process_plugin, nullptr, true);
           if (process_sp) {
             error = process_sp->ConnectRemote(connect_url.c_str());
             if (error.Success()) {
diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py
index 3aeb87874bdfa..ea7baecc2e3be 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py
@@ -49,10 +49,12 @@ def vAttach(self, _):
 
         attach_info = lldb.SBAttachInfo()
         attach_info.SetExecutable("foo")
+        attach_info.SetProcessPluginName("wasm")
 
         target = lldb.SBTarget()
         process = platform.Attach(attach_info, self.dbg, target, error)
         self.assertSuccess(error)
         self.assertEqual(process.GetProcessID(), 95117)
+        self.assertEqual(process.GetPluginName(), "wasm")
 
         platform.DisconnectRemote()

>From 0e7a5d0f67138178519d3848939d7f5c1009fd15 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <[email protected]>
Date: Fri, 9 Jan 2026 08:47:31 -0800
Subject: [PATCH 2/2] Do the same thing for launch

---
 .../Platform/gdb-server/PlatformRemoteGDBServer.cpp | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git 
a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp 
b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index a4f9036bf2f0c..88af721b0591f 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -416,10 +416,17 @@ PlatformRemoteGDBServer::DebugProcess(ProcessLaunchInfo 
&launch_info,
         error = Status::FromErrorStringWithFormat(
             "unable to launch a GDB server on '%s'", GetHostname());
       } else {
-        // The darwin always currently uses the GDB remote debugger plug-in
-        // so even when debugging locally we are debugging remotely!
+        // By default, we always use the GDB remote debugger plug-in.
+        // Even when debugging locally, we are debugging remotely.
+        llvm::StringRef process_plugin = "gdb-remote";
+
+        // However, if a process plugin is specified by the attach info, we
+        // should honor it.
+        if (!launch_info.GetProcessPluginName().empty())
+          process_plugin = launch_info.GetProcessPluginName();
+
         process_sp = target.CreateProcess(launch_info.GetListener(),
-                                          "gdb-remote", nullptr, true);
+                                          process_plugin, nullptr, true);
 
         if (process_sp) {
           process_sp->HijackProcessEvents(launch_info.GetHijackListener());

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

Reply via email to