https://github.com/aokblast updated 
https://github.com/llvm/llvm-project/pull/162890

>From 02a3bd3f786925b22f29a8c9f7c9a1db2c9dbec4 Mon Sep 17 00:00:00 2001
From: ShengYi Hung <[email protected]>
Date: Sat, 11 Oct 2025 01:07:36 +0800
Subject: [PATCH] [LLDB, FreeBSD, x86] Fix empty register set when trying to
 get size of register

GetSharedRegisterInfoVector is a function to get the singleton of total
register info. Also, PrivateGetRegisterCount assumes that we have already
filled the object in GetSharedRegisterInfoVector and panic when the object
is empty.
However, the actually function possess the register info
is GetRegisterInfo_i386. Originally, I plan to solve this by only
referencing object in GetSharedRegisterInfoVector. However,
RegisterInfos_x86_64.h requires the symbol with name g_register_infos in
current scope so that the header can append x86_64 registers after it.
As a result, I decide to copy the info to the object in
GetSharedRegisterInfoVector.

Also, reorder the header order and provide tests for debugging 32bit
binary on 64bit platform.
---
 lldb/source/Host/freebsd/Host.cpp                           | 3 +--
 .../Process/Utility/RegisterContextFreeBSD_x86_64.cpp       | 6 ++++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Host/freebsd/Host.cpp 
b/lldb/source/Host/freebsd/Host.cpp
index fa7efad466bad..dfdbfea0c3c0a 100644
--- a/lldb/source/Host/freebsd/Host.cpp
+++ b/lldb/source/Host/freebsd/Host.cpp
@@ -18,8 +18,6 @@
 #include <dlfcn.h>
 #include <execinfo.h>
 
-#include "llvm/Object/ELF.h"
-
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
@@ -32,6 +30,7 @@
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
 
+#include "llvm/Object/ELF.h"
 #include "llvm/TargetParser/Host.h"
 
 namespace lldb_private {
diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
index e0f3971c6e272..b55a5c595d3ca 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
@@ -76,8 +76,7 @@ static std::vector<lldb_private::RegisterInfo> 
&GetSharedRegisterInfoVector() {
 
 static const RegisterInfo *
 GetRegisterInfo_i386(const lldb_private::ArchSpec &arch) {
-  static std::vector<lldb_private::RegisterInfo> g_register_infos(
-      GetSharedRegisterInfoVector());
+  static std::vector<lldb_private::RegisterInfo> g_register_infos;
 
   // Allocate RegisterInfo only once
   if (g_register_infos.empty()) {
@@ -93,6 +92,9 @@ GetRegisterInfo_i386(const lldb_private::ArchSpec &arch) {
 #define UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
 #include "RegisterInfos_x86_64.h"
 #undef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
+    std::vector<lldb_private::RegisterInfo> &shared_regs =
+        GetSharedRegisterInfoVector();
+    shared_regs = g_register_infos;
   }
 
   return &g_register_infos[0];

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

Reply via email to