Author: Charles Zablit Date: 2026-06-30T23:49:47+01:00 New Revision: 1f7a93d088f0b8549156aa2d4a241cdf8e36a066
URL: https://github.com/llvm/llvm-project/commit/1f7a93d088f0b8549156aa2d4a241cdf8e36a066 DIFF: https://github.com/llvm/llvm-project/commit/1f7a93d088f0b8549156aa2d4a241cdf8e36a066.diff LOG: [lldb][Windows] Fix "Invalid register name" for eax on x86_64 attach (#203498) On Windows, when attaching to a process with no pre-existing target, lldb reports "Invalid register name" for sub-registers like eax. This is due to a bug in `ABIX86::AugmentRegisterInfo`, which determines the GPR base size by reading `Target::GetArchitecture().GetAddressByteSize()`. During attach, the target's architecture has not yet been set when `AugmentRegisterInfo` runs, so the lookup returns 0, the process is treated as 32-bit, and the x86_64 sub-registers are never added. This patch removes the dependency on the target's architecture: the X86 ABI plugins already know their own bitness, so `ABIX86_64` and `ABIX86_i386` now report it directly via a new `Is64Bit()` virtual. 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`. rdar://180307995 Added: Modified: lldb/source/Plugins/ABI/X86/ABIX86.cpp lldb/source/Plugins/ABI/X86/ABIX86.h lldb/source/Plugins/ABI/X86/ABIX86_64.h lldb/source/Plugins/ABI/X86/ABIX86_i386.h Removed: ################################################################################ diff --git a/lldb/source/Plugins/ABI/X86/ABIX86.cpp b/lldb/source/Plugins/ABI/X86/ABIX86.cpp index db170700d3f65..de7eefab58d1b 100644 --- a/lldb/source/Plugins/ABI/X86/ABIX86.cpp +++ b/lldb/source/Plugins/ABI/X86/ABIX86.cpp @@ -205,11 +205,10 @@ void ABIX86::AugmentRegisterInfo( if (!process_sp) return; - uint32_t gpr_base_size = - process_sp->GetTarget().GetArchitecture().GetAddressByteSize(); + uint32_t gpr_base_size = Is64Bit() ? 8 : 4; // primary map from a base register to its subregisters - BaseRegToRegsMap base_reg_map = makeBaseRegMap(gpr_base_size == 8); + BaseRegToRegsMap base_reg_map = makeBaseRegMap(Is64Bit()); // set used for fast matching of register names to subregisters llvm::SmallDenseSet<llvm::StringRef, 64> subreg_name_set; // convenience array providing access to all subregisters of given kind, diff --git a/lldb/source/Plugins/ABI/X86/ABIX86.h b/lldb/source/Plugins/ABI/X86/ABIX86.h index 1114084fbc5d8..05985c9e1f5b1 100644 --- a/lldb/source/Plugins/ABI/X86/ABIX86.h +++ b/lldb/source/Plugins/ABI/X86/ABIX86.h @@ -21,6 +21,8 @@ class ABIX86 : public lldb_private::MCBasedABI { void AugmentRegisterInfo( std::vector<lldb_private::DynamicRegisterInfo::Register> ®s) override; + virtual bool Is64Bit() const = 0; + private: using lldb_private::MCBasedABI::MCBasedABI; }; diff --git a/lldb/source/Plugins/ABI/X86/ABIX86_64.h b/lldb/source/Plugins/ABI/X86/ABIX86_64.h index 8fc98507adeeb..761f0670bc860 100644 --- a/lldb/source/Plugins/ABI/X86/ABIX86_64.h +++ b/lldb/source/Plugins/ABI/X86/ABIX86_64.h @@ -18,6 +18,8 @@ class ABIX86_64 : public ABIX86 { return name; } + bool Is64Bit() const override { return true; } + private: using ABIX86::ABIX86; }; diff --git a/lldb/source/Plugins/ABI/X86/ABIX86_i386.h b/lldb/source/Plugins/ABI/X86/ABIX86_i386.h index cb3baa5150fc3..feb92dbc6d5e1 100644 --- a/lldb/source/Plugins/ABI/X86/ABIX86_i386.h +++ b/lldb/source/Plugins/ABI/X86/ABIX86_i386.h @@ -15,6 +15,9 @@ class ABIX86_i386 : public ABIX86 { public: uint32_t GetGenericNum(llvm::StringRef name) override; +protected: + bool Is64Bit() const override { return false; } + private: using ABIX86::ABIX86; }; _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
