debug/gdb/printers: appease PEP8 warnings
This commit is contained in:
parent
d455e820d8
commit
9c62ab5e7b
@ -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
|
||||||
@ -83,7 +76,7 @@ class EndianValuePrinter(object):
|
|||||||
8: 'Q',
|
8: 'Q',
|
||||||
}[self.val.type.sizeof]
|
}[self.val.type.sizeof]
|
||||||
|
|
||||||
def to_string (self):
|
def to_string(self):
|
||||||
# Construct format specifiers for converting to bytes, then from
|
# Construct format specifiers for converting to bytes, then from
|
||||||
# bytes, so that we can perform the byte reversal.
|
# bytes, so that we can perform the byte reversal.
|
||||||
to_bytes = f"{self.order}{self.size}"
|
to_bytes = f"{self.order}{self.size}"
|
||||||
@ -98,7 +91,7 @@ class EndianValuePrinter(object):
|
|||||||
|
|
||||||
|
|
||||||
def build_cruft_dict():
|
def build_cruft_dict():
|
||||||
pretty_printers_dict[re.compile('^cruft::point.*$') ] = lambda val: CoordPrinter(val)
|
pretty_printers_dict[re.compile('^cruft::point.*$')] = lambda val: CoordPrinter(val)
|
||||||
pretty_printers_dict[re.compile('^cruft::vector.*$')] = lambda val: CoordPrinter(val)
|
pretty_printers_dict[re.compile('^cruft::vector.*$')] = lambda val: CoordPrinter(val)
|
||||||
pretty_printers_dict[re.compile('^cruft::extent.*$')] = lambda val: CoordPrinter(val)
|
pretty_printers_dict[re.compile('^cruft::extent.*$')] = lambda val: CoordPrinter(val)
|
||||||
pretty_printers_dict[re.compile('^cruft::colour.*$')] = lambda val: CoordPrinter(val)
|
pretty_printers_dict[re.compile('^cruft::colour.*$')] = lambda val: CoordPrinter(val)
|
||||||
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user