Improved pretty printing for smart pointers
Michael Marte
informarte@freenet.de
Tue Apr 16 10:38:00 GMT 2013
Hello *,
I found the pretty printers for std::shared_ptr, std::weak_ptr and
std::unique_ptr (as provided by
svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python) not sufficient for
daily use as they only generate a description (including the address of
the pointee) but do not pretty print the pointee itself. This behaviour
implies that one has to copy the address of the pointee, cast it to the
pointee's type, and dereference the result. To improve on the current
state of affairs, I improved the pretty printers to generate children.
For std::shared_ptr and std::weak_ptr, three children are generated,
namely "Use count", "Weak count", and "Managed value". For
std::unique_ptr, one child is generated, namely "Managed value". Using
this solution with an IDE like kdevelop or Eclipse CTD, it only needs
two clicks to see the value managed by a smart pointer.
I attached my patch in the hope that you will find it interesting and
that it will be integrated into your suite of GCC STL pretty printers.
Best regards,
Michael Marte
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb_printers_smart_pointer.patch
Type: text/x-patch
Size: 2826 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20130416/855ce851/attachment.bin>
More information about the Gdb
mailing list