This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add register field tables to the "register info" command
ClosedPublic

Authored by DavidSpickett on Jun 14 2023, 6:50 AM.

Details

Summary

This teaches DumpRegisterInfo to generate a table from the register
flags type. It just calls a method on RegisterFlags.

As such, the extra tests are minimal and only show that the intergration
works. Exhaustive formatting tests are done with RegisterFlags itself.

Example:

(lldb) register info cpsr
       Name: cpsr
       Size: 4 bytes (32 bits)
    In sets: general (index 0)

| 31 | 30 | 29 | 28 | 27-26 | 25  | 24  | 23  | 22  | 21 | 20 | 19-13 |  12  | 11-10 | 9 | 8 | 7 | 6 | 5 |  4  | 3-2 | 1 | 0  |
|----|----|----|----|-------|-----|-----|-----|-----|----|----|-------|------|-------|---|---|---|---|---|-----|-----|---|----|
| N  | Z  | C  | V  |       | TCO | DIT | UAO | PAN | SS | IL |       | SSBS |       | D | A | I | F |   | nRW | EL  |   | SP |

LLDB limits the max terminal width to 80 chars by default.
So to get that full width output you will need to change the "term-width"
setting to something higher.

Diff Detail

Event Timeline

DavidSpickett created this revision.Jun 14 2023, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2023, 6:50 AM
DavidSpickett requested review of this revision.Jun 14 2023, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2023, 6:50 AM

This is the major use case for the command. With these diagrams matching the architecture manual (mostly) you can use them to work out what mask/shift you need. You'll be able to print a register, see that the field isn't the right value, then "register info" and realise what you did wrong. The audience for it is small but when I was one of that audience (different debugger though) I really appreciated not having to leave the debugger to do this.

jasonmolenda accepted this revision.Jun 14 2023, 1:29 PM

LGTM. Putting this in register info is good, it's not too easily discoverable (to be honest I didn't know this command existed today), but as you say, the number of people who want to see this are relatively small so putting it in a more mainstream command like register read may not be the best choice. We can start with only in register info.

This revision is now accepted and ready to land.Jun 14 2023, 1:29 PM