summaryrefslogtreecommitdiff
path: root/libstdc++-v3/python
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-05 19:10:15 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-05 19:10:15 +0000
commit6c2e05ffa17a424b6243caf9d43d0e26a55fc4f8 (patch)
tree168584b38085315faf37c7293e1573279640990d /libstdc++-v3/python
parentcc798c0997a6ccb3c1949a919ad4dc1b14a13268 (diff)
downloadgcc-6c2e05ffa17a424b6243caf9d43d0e26a55fc4f8.tar.gz
PR libstdc++/51956
* python/libstdcxx/v6/printers.py (StdPointerPrinter): Rename to... (SharedPointerPrinter): This. Also show weak count. * testsuite/libstdc++-prettyprinters/shared_ptr.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183914 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r--libstdc++-v3/python/libstdcxx/v6/printers.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 4f34733ef46..f47da612d95 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -45,19 +45,24 @@ def find_type(orig, name):
raise ValueError, "Cannot find type %s::%s" % (str(orig), name)
typ = field.type
-class StdPointerPrinter:
- "Print a smart pointer of some kind"
+class SharedPointerPrinter:
+ "Print a shared_ptr or weak_ptr"
def __init__ (self, typename, val):
self.typename = typename
self.val = val
def to_string (self):
- if self.val['_M_refcount']['_M_pi'] == 0:
- return '%s (empty) %s' % (self.typename, self.val['_M_ptr'])
- return '%s (count %d) %s' % (self.typename,
- self.val['_M_refcount']['_M_pi']['_M_use_count'],
- self.val['_M_ptr'])
+ state = 'empty'
+ refcounts = self.val['_M_refcount']['_M_pi']
+ if refcounts != 0:
+ usecount = refcounts['_M_use_count']
+ weakcount = refcounts['_M_weak_count']
+ 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'])
class UniquePointerPrinter:
"Print a unique_ptr"
@@ -862,8 +867,8 @@ def build_libstdcxx_dictionary ():
# These are the TR1 and C++0x printers.
# For array - the default GDB pretty-printer seems reasonable.
- libstdcxx_printer.add_version('std::', 'shared_ptr', StdPointerPrinter)
- libstdcxx_printer.add_version('std::', 'weak_ptr', StdPointerPrinter)
+ libstdcxx_printer.add_version('std::', 'shared_ptr', SharedPointerPrinter)
+ libstdcxx_printer.add_version('std::', 'weak_ptr', SharedPointerPrinter)
libstdcxx_printer.add_container('std::', 'unordered_map',
Tr1UnorderedMapPrinter)
libstdcxx_printer.add_container('std::', 'unordered_set',
@@ -875,8 +880,8 @@ def build_libstdcxx_dictionary ():
libstdcxx_printer.add_container('std::', 'forward_list',
StdForwardListPrinter)
- libstdcxx_printer.add_version('std::tr1::', 'shared_ptr', StdPointerPrinter)
- libstdcxx_printer.add_version('std::tr1::', 'weak_ptr', StdPointerPrinter)
+ libstdcxx_printer.add_version('std::tr1::', 'shared_ptr', SharedPointerPrinter)
+ libstdcxx_printer.add_version('std::tr1::', 'weak_ptr', SharedPointerPrinter)
libstdcxx_printer.add_version('std::tr1::', 'unordered_map',
Tr1UnorderedMapPrinter)
libstdcxx_printer.add_version('std::tr1::', 'unordered_set',