Improved pretty printing for smart pointers

Tom Tromey tromey@redhat.com
Tue Apr 23 18:01:00 GMT 2013


>>>>> "Michael" == Michael Marte <informarte@freenet.de> writes:

Michael> I found the pretty printers for std::shared_ptr, std::weak_ptr and
Michael> std::unique_ptr (as provided by
Michael> svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python) not sufficient
Michael> for daily use as they only generate a description (including the
Michael> address of the pointee) but do not pretty print the pointee
Michael> itself. This behaviour implies that one has to copy the address of the
Michael> pointee, cast it to the pointee's type, and dereference the result. To
Michael> improve on the current state of affairs, I improved the pretty
Michael> printers to generate children. For std::shared_ptr and std::weak_ptr,
Michael> three children are generated, namely "Use count", "Weak count", and
Michael> "Managed value". For std::unique_ptr, one child is generated, namely
Michael> "Managed value". Using this solution with an IDE like kdevelop or
Michael> Eclipse CTD, it only needs two clicks to see the value managed by a
Michael> smart pointer.

Michael> I attached my patch in the hope that you will find it interesting and
Michael> that it will be integrated into your suite of GCC STL pretty printers.

This patch should go to the libstdc++ list.
The printers are maintained there.

Tom



More information about the Gdb mailing list