DavidSpickett · GitHub

I found this testing Arm32 but it applies to AArch64 as well and is likely a generic bug.

(Pdb) fpr.GetNumChildren()
81
(Pdb) fpr.GetChildAtIndex(80)
(unsigned char __attribute__((ext_vector_type(16)))) q15 = (0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
(Pdb) fpr.GetIndexOfChildWithName("q15")
97

The FPR register set claims to have 81 registers in it, which is correct. The child at index 80 is q15 which is the last register in the set:

Floating Point Registers:
<...>
    q15 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}

So if I look up q15 by name, I should get an index of 81 but I don't I get 97 which is beyond the size of the set. 97-81 = 16, but we start at index 0 so it's actually 17 off. There are 17 registers in the gpr set which is set 0. 16 r registers plus cpsr.

If GetChildAtIndex N gives me register A, GetIndexOfChildWithName should return N. It does not for anything beyond the first set.

Using an API script I checked all the registers:

(lldb) command script import check_register_indices.py
Installed command: check-register-indices
(lldb) check-register-indices
General Purpose Registers: 17 registers
  All indices agree.
Floating Point Registers: 81 registers
  s0: child index 0, reported index 17
<... more mismatches...>
  q15: child index 80, reported index 97
Thread Local Storage Registers: 1 registers
  tpidruro: child index 0, reported index 98

Nothing beyond GPR is correct.

Same thing on AArch64:

(lldb) check-register-indices
General Purpose Registers: 63 registers
  All indices agree.
Floating Point Registers: 98 registers
  v0: child index 0, reported index 63
<...>
  fpcr: child index 97, reported index 160
Scalable Vector Extension Registers: 50 registers
  vg: child index 0, reported index 161
<...>
  ffr: child index 49, reported index 210
Pointer Authentication Registers: 2 registers
  data_mask: child index 0, reported index 211
  code_mask: child index 1, reported index 212
Thread Local Storage Registers: 1 registers
  tpidr: child index 0, reported index 213

Same thing done via. the script command:

>>> lldb.frame.GetRegisters()[1].GetNumChildren()
98
>>> lldb.frame.GetRegisters()[1].GetChildAtIndex(0)
(unsigned char __attribute__((ext_vector_type(16)))) v0 = (0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f)
>>> lldb.frame.GetRegisters()[1].GetIndexOfChildWithName("v0")
63

Read the original on github.com ↗