summaryrefslogtreecommitdiff
path: root/libstdc++-v3/python
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-02 16:01:30 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-02 16:01:30 +0000
commit1fcecb123d804ed63241f44f3d12b8ba0864f0c6 (patch)
tree58fd11f14c1d56ddb2194ca1ae6b3aad93daf788 /libstdc++-v3/python
parent2f40fa7eb018b9a2edff806bdfdca396c0795f1d (diff)
downloadgcc-1fcecb123d804ed63241f44f3d12b8ba0864f0c6.tar.gz
PR libstdc++/59476
* python/libstdcxx/v6/printers.py (get_value_from_Rb_tree_node): New function to handle both C++03 and C++11 _Rb_tree_node implementations. (StdRbtreeIteratorPrinter, StdMapPrinter, StdSetPrinter): Use it. * testsuite/libstdc++-prettyprinters/simple.cc: Update comment to refer to... * testsuite/libstdc++-prettyprinters/simple11.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210008 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r--libstdc++-v3/python/libstdcxx/v6/printers.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 05da17b61ea..1f1f860a5b0 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -375,6 +375,22 @@ class RbtreeIterator:
self.node = node
return result
+def get_value_from_Rb_tree_node(node):
+ """Returns the value held in an _Rb_tree_node<_Val>"""
+ try:
+ member = node.type.fields()[1].name
+ if member == '_M_value_field':
+ # C++03 implementation, node contains the value as a member
+ return node['_M_value_field']
+ elif member == '_M_storage':
+ # C++11 implementation, node stores value in __aligned_buffer
+ p = node['_M_storage']['_M_storage'].address
+ p = p.cast(node.type.template_argument(0).pointer())
+ return p.dereference()
+ except:
+ pass
+ raise ValueError, "Unsupported implementation for %s" % str(node.type)
+
# This is a pretty printer for std::_Rb_tree_iterator (which is
# std::map::iterator), and has nothing to do with the RbtreeIterator
# class above.
@@ -387,7 +403,8 @@ class StdRbtreeIteratorPrinter:
def to_string (self):
typename = str(self.val.type.strip_typedefs()) + '::_Link_type'
nodetype = gdb.lookup_type(typename).strip_typedefs()
- return self.val.cast(nodetype).dereference()['_M_value_field']
+ node = self.val.cast(nodetype).dereference()
+ return get_value_from_Rb_tree_node(node)
class StdDebugIteratorPrinter:
"Print a debug enabled version of an iterator"
@@ -417,7 +434,8 @@ class StdMapPrinter:
def next(self):
if self.count % 2 == 0:
n = self.rbiter.next()
- n = n.cast(self.type).dereference()['_M_value_field']
+ n = n.cast(self.type).dereference()
+ n = get_value_from_Rb_tree_node(n)
self.pair = n
item = n['first']
else:
@@ -458,7 +476,8 @@ class StdSetPrinter:
def next(self):
item = self.rbiter.next()
- item = item.cast(self.type).dereference()['_M_value_field']
+ item = item.cast(self.type).dereference()
+ item = get_value_from_Rb_tree_node(item)
# FIXME: this is weird ... what to do?
# Maybe a 'set' display hint?
result = ('[%d]' % self.count, item)