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 gdb
import sys
import struct
@ -8,38 +7,33 @@ class CoordPrinter(object):
def __init__(self, val):
self.val = val
def to_string(self):
def to_string(self) -> str:
return self.val
def display_hint(self):
@staticmethod
def display_hint() -> str:
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):
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):
def __init__(self, val):
self.val = val
def to_string(self):
def to_string(self) -> str:
end = int(self.val["m_end"])
begin = int(self.val["m_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'
def children(self):
@ -50,12 +44,11 @@ class ViewPrinter(object):
while cursor != last:
val = cursor.dereference()
res = ("[%d]" % index, val)
yield res
cursor = cursor + 1
index = index + 1
val = cursor.dereference()
yield res
class EndianValuePrinter(object):
val: gdb.Type
@ -109,14 +102,14 @@ def build_cruft_dict():
def lookup(val):
type = val.type
t = val.type
if type.code == gdb.TYPE_CODE_REF:
type = type.target()
if t.code == gdb.TYPE_CODE_REF:
t = t.target()
type = type.unqualified().strip_typedefs()
t = t.unqualified().strip_typedefs()
typename = type.tag
typename = t.tag
if typename == None:
return None