[Lldb-commits] [lldb] [lldb] Parse and display register field enums (PR #95768)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 21 03:29:46 PDT 2024


DavidSpickett wrote:

> The only thing I could suggest is that we check the specified fields/size are less than 64 bits when reading the enum field definitions, but that means I can specify fields above 32 bits and then associate that with a 32-bit cpsr register and it won't be detected.

I have updated the test `test_evalue_value_limits` to check that we are able to parse an `evalue` that is the maximum 64 bit unsigned value, and that anything above that is rejected.

The other part is covered by the test `test_enum_value_range`.

So you could define an enum with a > 32 bit evalue, then assign that to a 32 bit register that had a single 32 bit field. lldb would check that all the evalues of that enum fit into that field. They do not, so it will ignore the enum.

Any other 64 bit registers with fields large enough to be compatible can still use the enum.

```
<enum id="some_enum" size="8">
  <evalue name="min" value="0"/>
  <evalue name="max" value="0xffffffffffffffff"/>
</enum>
<flags id="x0_flags" size="8">
  <!-- This works because all the evalues of some_enum fit into this 64 bit field -->
  <field name="foo" start="0" end="63" type="some_enum"/>
 </flags>
<reg name="x0" regnum="0" bitsize="64" type="x0_flags"/>
<flags id="cpsr_flags" size="4">
  <!-- The type here is ignored because the evalue "max" won't fit into the field. The field will just be treated as an unsigned integer. -->
  <field name="foo" start="0" end="31" type="some_enum"/>
</flags>
<reg name="cpsr" regnum="33" bitsize="32" type="cpsr_flags"/>
```

There are log messages for both these scenarios.

https://github.com/llvm/llvm-project/pull/95768


More information about the lldb-commits mailing list