[Lldb-commits] [lldb] 91d09ca - [lldb] Look up register set children by their own name too (#223857)

via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 16 02:45:21 PDT 2026


Author: Charles Zablit
Date: 2026-09-16T10:45:14+01:00
New Revision: 91d09ca8162338ab5cccd7f199275db9805b95bd

URL: https://github.com/llvm/llvm-project/commit/91d09ca8162338ab5cccd7f199275db9805b95bd
DIFF: https://github.com/llvm/llvm-project/commit/91d09ca8162338ab5cccd7f199275db9805b95bd.diff

LOG: [lldb] Look up register set children by their own name too (#223857)

On Windows x86_64, LLDB's register tables only list the full width
registers, so the ABI adds the sub-registers itself and puts them in a
separate "supplementary registers" set. That set contains `sp`, but
looking up `sp` in it failed: the lookup first turns `sp` into `rsp`,
and `rsp` is in the general purpose set, not this one. Linux doesn't hit
this because its tables already define the sub-registers next to `rsp`.

Now the lookup falls back to matching the name as written against the
registers of that set, so a register you can reach with
`GetChildAtIndex` can also be found by name. Lookups that already worked
are unchanged.

Fixes https://ci-external.swift.org/job/lldb-windows/job/main/3879/

Added: 
    

Modified: 
    lldb/source/ValueObject/ValueObjectRegister.cpp
    lldb/test/API/python_api/value/TestValueAPI.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/ValueObject/ValueObjectRegister.cpp b/lldb/source/ValueObject/ValueObjectRegister.cpp
index 1a7a4560714bc..23f4f3deb5c87 100644
--- a/lldb/source/ValueObject/ValueObjectRegister.cpp
+++ b/lldb/source/ValueObject/ValueObjectRegister.cpp
@@ -138,18 +138,26 @@ ValueObjectRegisterSet::LookupChildWithName(llvm::StringRef name) {
 
   // See if the register exists at all in any set.
   const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoByName(name);
-  if (!reg_info)
-    return {};
 
-  // See if this register is in this register set.
+  // See if this register is in this register set, falling back to the name as
+  // written. The generic name may alias a register in another set while this
+  // set has a register of that exact name. A match on the name itself always
+  // wins over one on the alt name.
+  std::optional<std::pair<size_t, const RegisterInfo *>> match;
   for (size_t i = 0; i < m_reg_set->num_registers; ++i) {
     const RegisterInfo *contained_reg_info =
         m_reg_ctx_sp->GetRegisterInfoAtIndex(m_reg_set->registers[i]);
+    if (!contained_reg_info)
+      continue;
     if (IsSameRegister(contained_reg_info, reg_info))
       return std::make_pair(i, reg_info);
+    if (name.equals_insensitive(contained_reg_info->name))
+      match = std::make_pair(i, contained_reg_info);
+    else if (!match && name.equals_insensitive(contained_reg_info->alt_name))
+      match = std::make_pair(i, contained_reg_info);
   }
 
-  return {};
+  return match;
 }
 
 lldb::ValueObjectSP

diff  --git a/lldb/test/API/python_api/value/TestValueAPI.py b/lldb/test/API/python_api/value/TestValueAPI.py
index cdc8c46723803..f7fce24a149df 100644
--- a/lldb/test/API/python_api/value/TestValueAPI.py
+++ b/lldb/test/API/python_api/value/TestValueAPI.py
@@ -346,8 +346,12 @@ def test_register(self):
                     sp_with_name_index = reg_set.GetIndexOfChildWithName(reg_name)
                     self.assertTrue(sp_with_name_index < num_registers)
                     rsp_with_name_index = reg_set.GetIndexOfChildWithName("rsp")
-                    self.assertTrue(rsp_with_name_index < num_registers)
-                    self.assertEqual(sp_with_name_index, rsp_with_name_index)
+                    if rsp_with_name_index < num_registers:
+                        self.assertEqual(sp_with_name_index, rsp_with_name_index)
+                    else:
+                        # "rsp" is not in this set, so we get the architectural
+                        # "sp" instead.
+                        self.assertEqual(sp_with_name_index, child_idx)
 
                     continue
 


        


More information about the lldb-commits mailing list