This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Don't print register fields when asked for a specific format
ClosedPublic

Authored by DavidSpickett on Apr 20 2023, 3:34 AM.

Details

Summary

Previously if a register had fields we would always print them after the
value if the register was asked for by name.

(lldb) register read MDCR_EL3
MDCR_EL3 = 0x00000000
         = {
             ETBAD = 0
<...>
             RLTE = 0
           }

This can be quite annoying if there are a whole lot of fields but you
want to see the register in a specific format.

(lldb) register read MDCR_EL3 -f i
MDCR_EL3 = 0x00000000   unknown     udf    #0x0
         = {
             ETBAD = 0
<...lots of fields...>

Since it pushes the interesting bit far up the terminal. To solve this,
don't print fields if the user passes --format. If they're doing that
then I think it's reasonable to assume they know what they want and only
want to see that output.

This also gives users a way to silence fields, but not change the format.
By doing register read foo -f x. In case they are not useful or perhaps
they are trying to work around a crash.

I have customised the help text for --format for register read to explain this:

-f <format> ( --format <format> )
     Specify a format to be used for display. If this is set, register fields will not be dispayed.

Diff Detail

Event Timeline

DavidSpickett created this revision.Apr 20 2023, 3:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 3:34 AM
DavidSpickett requested review of this revision.Apr 20 2023, 3:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 3:34 AM

Use the getter for the format value instead of adding a WasSet to the group class.

One alternative was to come up with a list of formats where printing fields afterwards makes sense. Hex makes sense, instruction does not. However it would be hard to judge and it doesn't solve the main issue where you want to see what you asked for without extras.

This does mean that you will only be able to get the default format if you want fields, but I think that will cover the majority of use cases for now. If it doesn't we could add an option that enables fields which defaults to on when no format is set, and off when one is.

jasonmolenda accepted this revision.Apr 20 2023, 4:33 PM

This seems fine to me; it's nice to have a way to quiet these when they get in the way, even if it's maybe not the first thing you'd look for, it's an uncommon enough use case that I'm not worried about that.

lldb/source/Commands/CommandObjectRegister.cpp
50

displayed

This revision is now accepted and ready to land.Apr 20 2023, 4:33 PM

dispayed -> displayed

DavidSpickett marked an inline comment as done.Apr 21 2023, 3:25 AM
This revision was landed with ongoing or failed builds.Apr 21 2023, 4:47 AM
This revision was automatically updated to reflect the committed changes.