debug/gdb/printers: add a pretty printer for 'view'

This commit is contained in:
Danny Robson 2018-08-03 16:49:47 +10:00
parent 0cea64fa14
commit b31f4dd094

View File

@ -28,6 +28,41 @@ class CoordPrinter(object):
return self._iterator(self.val['data'])
class ViewPrinter(object):
def __init__(self, title, val):
self.title = title
self.val = val
def to_string(self):
return self.title
def display_hint(self):
return 'array'
class _iterator(object):
def __init__(self, first, last):
self.cursor = first
self.last = last
self.index = 0
def __iter__(self):
return self
def __next__(self):
if self.cursor == self.last:
raise StopIteration
val = self.cursor.dereference()
self.cursor = self.cursor + 1
self.index = self.index + 1
return ("[%d]" % self.index, val)
def children(self):
return self._iterator(
self.val["m_begin"],
self.val["m_end"]
)
def build_cruft_dict():
pretty_printers_dict[re.compile('^util::point.*$') ] = lambda title, val: CoordPrinter(title, val)
@ -35,6 +70,8 @@ def build_cruft_dict():
pretty_printers_dict[re.compile('^util::extent.*$')] = lambda title, val: CoordPrinter(title, val)
pretty_printers_dict[re.compile('^util::colour.*$')] = lambda title, val: CoordPrinter(title, val)
pretty_printers_dict[re.compile('^util::view')] = lambda title, val: ViewPrinter(title, val)
def lookup(val):
type = val.type