This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdb pretty-printers for libstdc++

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<.*>$')] =

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

 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]