[Lldb-commits] [lldb] [lldb] Infer GPR base size from registers when target arch is unset (PR #203498)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 12 03:44:12 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Charles Zablit (charles-zablit)
<details>
<summary>Changes</summary>
`ABIX86::AugmentRegisterInfo()` picks between the i386 and amd64 register maps using `process->GetTarget().GetArchitecture().GetAddressByteSize()`. However, on Windows, `process attach -p` reaches this code with an empty Target ArchSpec. `GetAddressByteSize()` returns 0 and lldb falls through to the i386 map.
This patch falls back to scanning the register list itself:
- `rax/rsp/rip`: amd64
- `eax/esp/eip`: i386.
This patch fixes `TestRegisters::test_convenience_registers_with_process_attach` and `TestRegisters::test_convenience_registers_16bit_with_process_attach` on Windows using `LLDB_USE_LLDB_SERVER=1`.
---
Full diff: https://github.com/llvm/llvm-project/pull/203498.diff
1 Files Affected:
- (modified) lldb/source/Plugins/ABI/X86/ABIX86.cpp (+14)
``````````diff
diff --git a/lldb/source/Plugins/ABI/X86/ABIX86.cpp b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
index db170700d3f65..e905aed21d1af 100644
--- a/lldb/source/Plugins/ABI/X86/ABIX86.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
@@ -207,6 +207,20 @@ void ABIX86::AugmentRegisterInfo(
uint32_t gpr_base_size =
process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
+ // Determine the GPR base size. Prefer the target architecture, but fall
+ // back to the register list itself when the target arch isn't set yet
+ if (gpr_base_size == 0) {
+ for (const auto ® : regs) {
+ if (reg.name == "rax" || reg.name == "rsp" || reg.name == "rip") {
+ gpr_base_size = 8;
+ break;
+ }
+ if (reg.name == "eax" || reg.name == "esp" || reg.name == "eip") {
+ gpr_base_size = 4;
+ break;
+ }
+ }
+ }
// primary map from a base register to its subregisters
BaseRegToRegsMap base_reg_map = makeBaseRegMap(gpr_base_size == 8);
``````````
</details>
https://github.com/llvm/llvm-project/pull/203498
More information about the lldb-commits
mailing list