This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: gdb pretty-printers for libstdc++
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: libstdc <libstdc++ at gcc dot gnu dot org>
- Date: Sat, 28 Feb 2009 19:02:44 +0000
- Subject: Re: gdb pretty-printers for libstdc++
- References: <m3eixj4o7d.fsf@fleche.redhat.com>
2009/2/27 Tom Tromey:
>
> Let me know what you think.
I'm very pleased to see this coming to gdb, I'll be trying it out as
soon as I can.
+ # C++0x stuff.
+ # array - the default seems reasonable
+ # smart_ptr? seems to only be in boost right now
There's no smart_ptr class, not sure what this means :-)
+ pretty_printers_dict[re.compile('^std::tr1::shared_ptr<.*>$')] =
lambda val: StdPointerPrinter ('std::shared_ptr', val)
+ pretty_printers_dict[re.compile('^std::tr1::weak_ptr<.*>$')] =
lambda val: StdPointerPrinter ('std::weak_ptr', val)
+ pretty_printers_dict[re.compile('^std::tr1::unique_ptr<.*>$')] =
UniquePointerPrinter
There's no std::tr1::unique_ptr, only std::unique_ptr.
shared_ptr, weak_ptr and the unordered_xxx containers exist in
namespace std as well as namespace std::tr1, so maybe the regex should
be '^std::(tr1::)?shared_ptr<.*>$' and similar.
Maybe I've misunderstood how it works, but in this printer:
+class StdPointerPrinter:
+ "Print a smart pointer of some kind"
+
+ def __init__ (self, typename, val):
+ self.typename = typename
+ self.val = val
+
+ def to_string (self):
+ return '%s (count %d) %s' % (self.typename, self.val['_M_refcount'],
+ self.val['_M_ptr'])
+
_M_refcount is a class containing a pointer, not the actual refcount.
Should it print _M_refcount._M_pi->_M_usecount instead? That will
work for std::shared_ptr and std::weak_ptr, and the std::tr1
counterparts.
I'd like to see the weak count too, but I'll take care of that at
some point once I've got these improvements from F11.
Jonathan