commit 0f63cb5027505c26b2f90aeeb1275f459c3d2fbd
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Dec 16 13:42:48 2016 +0000
Make iterator printers fail more gracefully
* python/libstdcxx/v6/printers.py (StdListIteratorPrinter.to_string):
Handle exception from failed type lookup and return user-friendly
string.
(StdRbtreeIteratorPrinter.__init__): Handle exception from failed
type lookup.
(StdRbtreeIteratorPrinter.to_string): Return user-friendly string.
@@ -202,10 +202,13 @@ class StdListIteratorPrinter:
def to_string(self):
if not self.val['_M_node']:
return 'non-dereferenceable iterator for std::list'
- nodetype = find_type(self.val.type, '_Node')
- nodetype = nodetype.strip_typedefs().pointer()
- node = self.val['_M_node'].cast(nodetype).dereference()
- return str(get_value_from_list_node(node))
+ try:
+ nodetype = find_type(self.val.type, '_Node')
+ nodetype = nodetype.strip_typedefs().pointer()
+ node = self.val['_M_node'].cast(nodetype).dereference()
+ return str(get_value_from_list_node(node))
+ except ValueError:
+ return '<insufficient debuginfo for std::list iterator>'
class StdSlistPrinter:
"Print a __gnu_cxx::slist"
@@ -496,12 +499,18 @@ class StdRbtreeIteratorPrinter:
def __init__ (self, typename, val):
self.val = val
valtype = self.val.type.template_argument(0).strip_typedefs()
- nodetype = gdb.lookup_type('std::_Rb_tree_node<' + str(valtype) + '>')
- self.link_type = nodetype.strip_typedefs().pointer()
+ try:
+ # Throws gdb.error if debuginfo for _Rb_tree_node is missing:
+ nodetype = gdb.lookup_type('std::_Rb_tree_node<%s>' % str(valtype))
+ self.link_type = nodetype.strip_typedefs().pointer()
+ except RuntimeError:
+ self.link_type = None
def to_string (self):
if not self.val['_M_node']:
return 'non-dereferenceable iterator for associative container'
+ if self.link_type is None:
+ return "<insufficient debuginfo for associative container iterator>"
node = self.val['_M_node'].cast(self.link_type).dereference()
return str(get_value_from_Rb_tree_node(node))