[PATCH v2][PR gdb/24052] Implement 'set print zero-values on|off'
Hannes Domani
ssbssa@yahoo.de
Sun May 31 16:33:40 GMT 2020
Am Sonntag, 31. Mai 2020, 17:21:16 MESZ hat Pedro Alves <palves@redhat.com> Folgendes geschrieben:
> On 5/31/20 3:58 PM, Hannes Domani via Gdb-patches wrote:
> > Am Sonntag, 31. Mai 2020, 15:39:05 MESZ hat Pedro Alves <palves@redhat.com> Folgendes geschrieben:
>
> >> The thing is that an enum does not measure a quantity or offset.
> >> "0" has no usual particular significance compared to
> >> other enumerators. While with pointers and integrals, usually
> >> "0" has significance, meaning no quantity, no offset or no object,
> >> or in general absence of the property being measured by the variable.
> >>
> >> For example, here's GDB's auto_boolean:
> >>
> >> /* * A generic, not quite boolean, enumeration. This is used for
> >> set/show commands in which the options are on/off/automatic. */
> >> enum auto_boolean
> >> {
> >> AUTO_BOOLEAN_TRUE,
> >> AUTO_BOOLEAN_FALSE,
> >> AUTO_BOOLEAN_AUTO
> >> };
> >>
> >> I'd think it confusing that "zero-values off" would hide
> >> AUTO_BOOLEAN_TRUE, but not AUTO_BOOLEAN_FALSE.
> >>
> >> Here:
> >>
> >> extern enum language_mode
> >> {
> >> language_mode_auto, language_mode_manual
> >> }
> >> language_mode;
> >>
> >> What's the significance of hiding auto but not manual?
> >>
> >> Here:
> >>
> >> /* alignment enum */
> >> enum ui_align
> >> {
> >> ui_left = -1,
> >> ui_center,
> >> ui_right,
> >> ui_noalign
> >> };
> >>
> >> Why hide ui_center, instead of the other enumerators?
> >>
> >> Etc.
> >
> > It seems we have very different views about this.
> > I don't think it's confusing at all to hide AUTO_BOOLEAN_TRUE/
> > language_mode_auto/ui_center in these cases.
> >
>
> OK, if such different views are both reasonable, then this
> normally means that the larger set of users will also contain
> people with such opposing views, which calls for making it
> optional. Maybe:
>
> set print zero-values all / non-enums / none
>
> > (For me it's more confusing that AUTO_BOOLEAN_TRUE is first in this enum.)
> >
> > If you don't want to hide it, just don't use -zero-values off.
> >
>
> Even the original reporter in the PR suggested only removing
> zero enums under an option:
>
> "Optionally also removing those enums which evaluate to zero would
> save even more unneeded information."
>
> >> (gdb) p g_out
> >> $1 = {pad1 = {c = 0 '\000', i = 0}, pad2 = {c = 0 '\000', i = 0}}
> >> (gdb) p out
> >> $2 = {pad1 = {c = 0 '\000', i = 0}, pad2 = {c = 0 '\000', i = 0}}
> >>
> >> (gdb) p -zero-values off -- g_out
> >> $3 = {}
> >> (gdb) p -zero-values off -- out
> >> $4 = {pad1 = {}, pad2 = {}}
> >>
> >> As you see, $3 and $4 gave different outputs, due to the padding.
> >
> > I agree that this might be weird, but I kinda see this as a feature.
>
> What's the value of the feature? I think it's a hard to justify feature,
> because garbage in padding happens randomly, and naturally, and doesn't
> affect the value at the language level. I very much question the value
> in wanting a different output here, and I hazard a guess that you were
> initially surprised with this case too. IMO it's just a bug not to
> consider it.
>
> >> Why print "static_field = 0" when zero-values is off?
> >
> > When printing structures, I usually don't care about the static members.
> >
> > And with -zero-values off it should just display the parts that have some kind
> > of value.
> > So now I kinda want to hide all static members when -zero-values off, no
> > matter what their real value is.
>
> NAK. Let's keep options orthogonal.
OK.
I will first try to fix the padding and static members.
Once I got that, enums.
But I have no idea how python pretty printers could be handled.
Hannes
More information about the Gdb-patches
mailing list