[Lldb-commits] [lldb] [lldb][RISCV] Handle subsets of CSRs in RV32 core dump images (PR #142932)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 6 09:10:06 PST 2026


================
@@ -7,75 +7,372 @@
 //===----------------------------------------------------------------------===//
 
 #include "RegisterContextPOSIXCore_riscv32.h"
+
 #include "lldb/Utility/DataBufferHeap.h"
 
+#define GPR_OFFSET(idx) ((idx) * sizeof(uint32_t))
+#define FPR_OFFSET(idx) ((idx) * sizeof(uint32_t))
+#define CSR_OFFSET(idx) ((idx) * sizeof(uint32_t))
+
+#define DECLARE_REGISTER_INFOS_RISCV32_STRUCT
+#include "Plugins/Process/Utility/RegisterInfos_riscv32.h"
+#undef DECLARE_REGISTER_INFOS_RISCV32_STRUCT
+
 using namespace lldb_private;
 
 std::unique_ptr<RegisterContextCorePOSIX_riscv32>
 RegisterContextCorePOSIX_riscv32::Create(Thread &thread, const ArchSpec &arch,
                                          const DataExtractor &gpregset,
                                          llvm::ArrayRef<CoreNote> notes) {
-  Flags opt_regsets = RegisterInfoPOSIX_riscv32::eRegsetMaskDefault;
-
   return std::unique_ptr<RegisterContextCorePOSIX_riscv32>(
       new RegisterContextCorePOSIX_riscv32(
-          thread,
-          std::make_unique<RegisterInfoPOSIX_riscv32>(arch, opt_regsets),
+          thread, std::make_unique<RegisterInfoPOSIXDynamic_riscv32>(arch),
           gpregset, notes));
 }
 
 RegisterContextCorePOSIX_riscv32::RegisterContextCorePOSIX_riscv32(
-    Thread &thread, std::unique_ptr<RegisterInfoPOSIX_riscv32> register_info,
+    Thread &thread,
+    std::unique_ptr<RegisterInfoPOSIXDynamic_riscv32> register_info,
     const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
-    : RegisterContextPOSIX_riscv32(thread, std::move(register_info)) {
+    : RegisterContext(thread, 0), m_reg_infos_up(std::move(register_info)) {
+  // Compute the maximum register counts for GPR, FPR, and CSR.
+  uint32_t k_num_gpr_registers = (sizeof(g_register_infos_riscv32_gpr) /
----------------
JDevlieghere wrote:

Assuming `g_register_infos_riscv32_gpr` is `constexpr`, these should be as well, especially given their `k_` prefix which suggests they're constants but the code allows them to be mutated.

https://github.com/llvm/llvm-project/pull/142932


More information about the lldb-commits mailing list