https://github.com/da-viper created 
https://github.com/llvm/llvm-project/pull/210946

gdbserver recognises 'x86_64' arch as 'i386:x86-64', this prevents gdb (binary) 
from connecting to lldb-server since lldb-server reports architecture  as 
'x86_64'. we already do something similar when connecting a server to lldb.
This does not affect lldb -> lldb-server since we use qHostInfo to get that 
information.

>From fd2c62be728593ab1097abeadee8c2c89f825d1d Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <[email protected]>
Date: Mon, 20 Jul 2026 19:01:53 +0100
Subject: [PATCH] [lldb] Update the expected gdbserver's architecture

gdbserver recognises 'x86_64' arch as 'i386:x86-64', this prevents
gdb (binary) from connecting to lldb-server since lldb-server reports
architecture  as 'x86_64'. we already do something similar when
connecting a server to lldb.
This does not affect lldb -> lldb-server since we use qHostInfo to get
that information.
---
 .../GDBRemoteCommunicationServerLLGS.cpp      | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 4f11cf8c5475e..a9b9bb160380a 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -43,6 +43,7 @@
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/UnimplementedError.h"
 #include "lldb/Utility/UriParser.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorExtras.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/JSON.h"
@@ -3313,13 +3314,17 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
   response.IndentMore();
 
   response.Indent();
-  response.Printf("<architecture>%s</architecture>\n",
-                  m_current_process->GetArchitecture()
-                      .GetTriple()
-                      .getArchName()
-                      .str()
-                      .c_str());
-
+  const llvm::StringRef arch_name =
+      m_current_process->GetArchitecture().GetTriple().getArchName();
+  // Match gdbserver's expected architecture name we aready do the same
+  // when decoding the architecture when receiving the target.xml
+  // in ProcessGDBRemote::GetGDBServerRegisterInfoXMLAndProcess.
+  const llvm::StringRef new_arch_name = 
StringSwitch<llvm::StringRef>(arch_name)
+                                            .Case("x86_64", "i386:x86-64")
+                                            .Case("riscv64", "riscv:rv64")
+                                            .Case("riscv32", "riscv:rv32")
+                                            .Default(arch_name);
+  response.Format("<architecture>{}</architecture>\n", new_arch_name);
   response.Indent("<feature>\n");
 
   const int registers_count = reg_context.GetUserRegisterCount();

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

Reply via email to