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

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

>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] [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()

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

Reply via email to