https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/203498
`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`. >From a3c29c43098bcd8ff36938d837a7bc977b3ad835 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Fri, 12 Jun 2026 11:28:22 +0100 Subject: [PATCH] [lldb] Infer GPR base size from registers when target arch is unset --- lldb/source/Plugins/ABI/X86/ABIX86.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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); _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
