FYI: fix 2 MI-related pretty-printer bugs
Tom Tromey
tromey@redhat.com
Mon Jun 15 21:14:00 GMT 2009
I'm checking this in.
Terry Parker, a gdb user, found a couple of bugs in the libstdc++
pretty printers. The problem was that the MI output failed to update
after a "next".
The bug is that it is not valid for a printer to cache any iterator it
creates. It must make a new iterator in response to each new call to
'children'.
Tom
2009-06-15 Tom Tromey <tromey@redhat.com>
* python/libstdcxx/v6/printers.py (StdMapPrinter.__init__): Don't
set self.iter.
(StdMapPrinter.to_string): Make a new iterator.
(StdMapPrinter.children): Likewise.
(StdSetPrinter.__init__): Don't set self.iter.
(StdSetPrinter.to_string): Make a new iterator.
(StdSetPrinter.children): Likewise.
Index: python/libstdcxx/v6/printers.py
===================================================================
--- python/libstdcxx/v6/printers.py (revision 148505)
+++ python/libstdcxx/v6/printers.py (working copy)
@@ -277,17 +277,17 @@
def __init__ (self, typename, val):
self.typename = typename
self.val = val
- self.iter = RbtreeIterator (val)
def to_string (self):
- return '%s with %d elements' % (self.typename, len (self.iter))
+ return '%s with %d elements' % (self.typename,
+ len (RbtreeIterator (self.val)))
def children (self):
keytype = self.val.type.template_argument(0).const()
valuetype = self.val.type.template_argument(1)
nodetype = gdb.lookup_type('std::_Rb_tree_node< std::pair< %s, %s > >' % (keytype, valuetype))
nodetype = nodetype.pointer()
- return self._iter (self.iter, nodetype)
+ return self._iter (RbtreeIterator (self.val), nodetype)
def display_hint (self):
return 'map'
@@ -317,15 +317,15 @@
def __init__ (self, typename, val):
self.typename = typename
self.val = val
- self.iter = RbtreeIterator (val)
def to_string (self):
- return '%s with %d elements' % (self.typename, len (self.iter))
+ return '%s with %d elements' % (self.typename,
+ len (RbtreeIterator (self.val)))
def children (self):
keytype = self.val.type.template_argument(0)
nodetype = gdb.lookup_type('std::_Rb_tree_node< %s >' % keytype).pointer()
- return self._iter (self.iter, nodetype)
+ return self._iter (RbtreeIterator (self.val), nodetype)
class StdBitsetPrinter:
"Print a std::bitset"
More information about the Gcc-patches
mailing list