On 04/01/18 11:22 +0100, Juraj Oršulić wrote:
Hi Jonathan (and the libstdc++ list). Can we revive this? I sent the
patches for improving the smart pointer pretty printers in March. They
haven't been reviewed.
Thanks for the reminder. I'm testing the attached patch, which has
been rebased on trunk, but I'm getting test failures for the
shared_ptr printers.
I can't see any difference between the expected output and what GDB
prints, so I think it's some DejaGnu or Tcl/Tk oddity. The actual
printer seems to work OK.
Regards, and happy 2018,
Juraj
On Mon, Mar 27, 2017 at 6:05 PM, Jonathan Wakely <jwak...@redhat.com> wrote:
On 27/03/17 17:34 +0200, Juraj Oršulić wrote:
On Mon, Mar 27, 2017 at 5:15 PM, Jonathan Wakely <jwak...@redhat.com> wrote:
I think we're probably too close to the gcc7 release to make this
change now, sorry.
No problem, I think it's most important that it entered the pipeline,
since it's been completely dead for 4 years :-)
Just a reminder, I added this only for those smart pointers that I
needed at the moment - the unique and shared pointer, and for the
vector iterator. When you (or someone else) will be doing a review of
the patch, let me know if you think this should be expanded for other
iterators as well.
Will do, thanks.
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 6da8508d944..7b999ee6db4 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -120,6 +120,10 @@ class SharedPointerPrinter:
def __init__ (self, typename, val):
self.typename = strip_versioned_namespace(typename)
self.val = val
+ self.pointer = val['_M_ptr']
+
+ def children (self):
+ return [('get()', self.pointer)]
def to_string (self):
state = 'empty'
@@ -130,25 +134,29 @@ class SharedPointerPrinter:
if usecount == 0:
state = 'expired, weak %d' % weakcount
else:
- state = 'count %d, weak %d' % (usecount, weakcount - 1)
- return '%s (%s) %s' % (self.typename, state, self.val['_M_ptr'])
+ state = 'use count %d, weak count %d' % (usecount, weakcount - 1)
+ return '%s<%s> (%s)' % (self.typename, str(self.pointer.type.target().strip_typedefs()), state)
class UniquePointerPrinter:
"Print a unique_ptr"
def __init__ (self, typename, val):
self.val = val
-
- def to_string (self):
- impl_type = self.val.type.fields()[0].type.tag
+ impl_type = val.type.fields()[0].type.tag
if is_specialization_of(impl_type, '__uniq_ptr_impl'): # New implementation
- v = self.val['_M_t']['_M_t']['_M_head_impl']
+ self.pointer = val['_M_t']['_M_t']['_M_head_impl']
elif is_specialization_of(impl_type, 'tuple'):
- v = self.val['_M_t']['_M_head_impl']
+ self.pointer = val['_M_t']['_M_head_impl']
else:
+ self.pointer = None
+
+ def children (self):
+ return [('get()', self.pointer)]
+
+ def to_string (self):
+ if not self.pointer:
raise ValueError("Unsupported implementation for unique_ptr: %s" % self.val.type.fields()[0].type.tag)
- return 'std::unique_ptr<%s> containing %s' % (str(v.type.target()),
- str(v))
+ return ('std::unique_ptr<%s>' % (str(self.pointer.type.target())))
def get_value_from_aligned_membuf(buf, valtype):
"""Returns the value held in a __gnu_cxx::__aligned_membuf."""