diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-08 12:34:00 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-08 12:34:00 +0000 |
commit | 3c80034b37df052d4834ef5738d3c348cf5794ac (patch) | |
tree | e0cc1633b49e1a0648f3dbf0903811828f655fcd /libstdc++-v3/python | |
parent | 891960c57ebeb2516aa18d9461b924e138783cdb (diff) | |
download | gcc-3c80034b37df052d4834ef5738d3c348cf5794ac.tar.gz |
* python/libstdcxx/v6/printers.py (StdForwardListPrinter): Add.
* testsuite/libstdc++-prettyprinters/cxx11.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182989 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r-- | libstdc++-v3/python/libstdcxx/v6/printers.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 4197c081d9c..81c33c733e6 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -687,6 +687,49 @@ class Tr1UnorderedMapPrinter: def display_hint (self): return 'map' +class StdForwardListPrinter: + "Print a std::forward_list" + + class _iterator: + def __init__(self, nodetype, head): + self.nodetype = nodetype + self.base = head['_M_next'] + self.count = 0 + + def __iter__(self): + return self + + def next(self): + if self.base == 0: + raise StopIteration + elt = self.base.cast(self.nodetype).dereference() + self.base = elt['_M_next'] + count = self.count + self.count = self.count + 1 + return ('[%d]' % count, elt['_M_value']) + + def __init__(self, typename, val): + self.val = val + self.typename = typename + + def children(self): + itype = self.val.type.template_argument(0) + # If the inferior program is compiled with -D_GLIBCXX_DEBUG + # some of the internal implementation details change. + if self.typename == "std::forward_list": + nodetype = gdb.lookup_type('std::_Fwd_list_node<%s>' % itype).pointer() + elif self.typename == "std::__debug::list": + nodetype = gdb.lookup_type('std::__norm::_Fwd_list_node<%s>' % itype).pointer() + else: + raise ValueError, "Cannot cast forward_list node for forward_list printer." + return self._iterator(nodetype, self.val['_M_impl']['_M_head']) + + def to_string(self): + if self.val['_M_impl']['_M_head']['_M_next'] == 0: + return 'empty %s' % (self.typename) + return '%s' % (self.typename) + + # A "regular expression" printer which conforms to the # "SubPrettyPrinter" protocol from gdb.printing. class RxPrinter(object): @@ -812,6 +855,7 @@ def build_libstdcxx_dictionary (): libstdcxx_printer.add('std::unordered_set', Tr1UnorderedSetPrinter) libstdcxx_printer.add('std::unordered_multimap', Tr1UnorderedMapPrinter) libstdcxx_printer.add('std::unordered_multiset', Tr1UnorderedSetPrinter) + libstdcxx_printer.add('std::forward_list', StdForwardListPrinter) libstdcxx_printer.add('std::tr1::shared_ptr', StdPointerPrinter) libstdcxx_printer.add('std::tr1::weak_ptr', StdPointerPrinter) @@ -833,6 +877,8 @@ def build_libstdcxx_dictionary (): Tr1UnorderedMapPrinter) libstdcxx_printer.add('std::__debug::unordered_multiset', Tr1UnorderedSetPrinter) + libstdcxx_printer.add('std::__debug::forward_list', + StdForwardListPrinter) # Extensions. |