This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug debug/59161] GDB pretty printers: iterator->reference not printed
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 15 Dec 2016 10:33:02 +0000
- Subject: [Bug debug/59161] GDB pretty printers: iterator->reference not printed
- Auto-submitted: auto-generated
- References: <bug-59161-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59161
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That seems quite arbitrary and inconsistent. In other contexts if I return a
gdb.Value it gets stringified as expected, e.g the
StdListPrinter._iterator.__next__ method does:
return ('[%d]' % count, val)
where val is a gdb.Value, but gdb automatically converts that to a string via
something like: "%s = %s" % ('[%d]' % count, val) and so the gdb.Value is
converted properly.
But when a gdb.Value is returned directly the simplified form is used.
Returning gdb.Value directly is a documented part of the API:
https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing-API.html
> Otherwise, if this method returns an instance of gdb.Value, then gdb prints this value.
And I can't see what possible use it is to print { ref = } for this object,
ever.
Paul's change is intended to suppress the address in his example at
https://sourceware.org/ml/gdb/2009-11/msg00105.html but by the reasoning above
he should have made his pretty-printer do:
return str(self.val['whybother']['contents'])
Also, in his case he was getting the address *and* the string contents, but in
this reference example we *only* print the address, not the value. Suppressing
the address in that case seems undesirable.