[Lldb-commits] [lldb] [lldb] Update the expected gdbserver's architecture (PR #210946)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 21 03:58:48 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Ebuka Ezike (da-viper)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/210946.diff
1 Files Affected:
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (+12-7)
``````````diff
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();
``````````
</details>
https://github.com/llvm/llvm-project/pull/210946
More information about the lldb-commits
mailing list