This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: fix 2 MI-related pretty-printer bugs


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"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]