debug/gdb/printers: appease PEP8 warnings

This commit is contained in:
Danny Robson 2019-01-19 11:37:58 +11:00
parent d455e820d8
commit 9c62ab5e7b

View File

@ -1,6 +1,5 @@
import re import re
import gdb import gdb
import sys
import struct import struct
@ -8,38 +7,33 @@ class CoordPrinter(object):
def __init__(self, val): def __init__(self, val):
self.val = val self.val = val
def to_string(self): def to_string(self) -> str:
return self.val return self.val
def display_hint(self): @staticmethod
def display_hint() -> str:
return 'array' return 'array'
class _iterator(object):
def __init__(self, data):
self.data = data
def __iter__(self):
indices = self.data.type.range()
for i in range(indices[0], indices[1] + 1):
res = (str(i), self.data[i])
yield res
raise StopIteration()
def children(self): def children(self):
return self._iterator(self.val['data']) data = self.val['data']
indices = data.type.range()
for i in range(indices[0], indices[1] + 1):
yield (str(i), data[i])
class ViewPrinter(object): class ViewPrinter(object):
def __init__(self, val): def __init__(self, val):
self.val = val self.val = val
def to_string(self): def to_string(self) -> str:
end = int(self.val["m_end"]) end = int(self.val["m_end"])
begin = int(self.val["m_begin"]) begin = int(self.val["m_begin"])
size = end - begin size = end - begin
return f"{size} elements" return f"{self.val.type.tag} of length {size}"
def display_hint(self): @staticmethod
def display_hint() -> str:
return 'array' return 'array'
def children(self): def children(self):
@ -50,12 +44,11 @@ class ViewPrinter(object):
while cursor != last: while cursor != last:
val = cursor.dereference() val = cursor.dereference()
res = ("[%d]" % index, val) res = ("[%d]" % index, val)
yield res
cursor = cursor + 1 cursor = cursor + 1
index = index + 1 index = index + 1
val = cursor.dereference()
yield res
class EndianValuePrinter(object): class EndianValuePrinter(object):
val: gdb.Type val: gdb.Type
@ -109,14 +102,14 @@ def build_cruft_dict():
def lookup(val): def lookup(val):
type = val.type t = val.type
if type.code == gdb.TYPE_CODE_REF: if t.code == gdb.TYPE_CODE_REF:
type = type.target() t = t.target()
type = type.unqualified().strip_typedefs() t = t.unqualified().strip_typedefs()
typename = type.tag typename = t.tag
if typename == None: if typename == None:
return None return None