This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Add table formatting for register fields
ClosedPublic

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

Details

Summary

This will be used by the "register info" command to show
the layout of register contents. For example if we have
these fields coming in from XML:

<field name="D" start="0" end="7"/>
<field name="C" start="8" end="15"/>
<field name="B" start="16" end="23"/>
<field name="A" start="24" end="31"/>

We get:

| 31-24 | 23-16 | 15-8 | 7-0 |
|-------|-------|------|-----|
|   A   |   B   |  C   |  D  |

Note that this is only the layout, not the values.
For values, use "register read".

The tables' columns are center padded (left bias
if there's an odd padding) and will wrap if the terminal width
is too low.

| 31-24 | 23-16 |
|-------|-------|
|   A   |   B   |

| 15-8 | 7-0 |
|------|-----|
|  C   |  D  |

This means we match the horizontal format seen in many architecture
manuals but don't spam the user with lots of misaligned text when the
output gets very long.

Diff Detail

Event Timeline

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

I'm aware we likely have 10s of adhoc table printing functions across llvm and I'm surprised someone hasn't unified them yet. Which is to say, today I am not that person though I would like to collect a list of places that could benefit from it.

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

LGTM.

lldb/include/lldb/Target/RegisterFlags.h
96

"Unnamed"

lldb/source/Target/RegisterFlags.cpp
149

"much"

This revision is now accepted and ready to land.Jun 14 2023, 1:27 PM
This revision was automatically updated to reflect the committed changes.
DavidSpickett marked 2 inline comments as done.Jun 21 2023, 2:35 AM

Sorry I missed the comments before landing, I've addressed those in https://github.com/llvm/llvm-project/commit/c7759df03825f63f8334d88c9525d655acfab685.