mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +00:00
Meta: Add a gdb pretty-printer for FixedArray
This commit is contained in:
parent
49e6414c58
commit
4e0b52d009
1 changed files with 41 additions and 0 deletions
|
@ -22,6 +22,8 @@ def handler_class_for_type(type, re=re.compile('^([^<]+)(<.*>)?$')):
|
||||||
return AKAtomic
|
return AKAtomic
|
||||||
elif klass == 'AK::DistinctNumeric':
|
elif klass == 'AK::DistinctNumeric':
|
||||||
return AKDistinctNumeric
|
return AKDistinctNumeric
|
||||||
|
elif klass == 'AK::FixedArray':
|
||||||
|
return AKFixedArrayPrinter
|
||||||
elif klass == 'AK::HashMap':
|
elif klass == 'AK::HashMap':
|
||||||
return AKHashMapPrettyPrinter
|
return AKHashMapPrettyPrinter
|
||||||
elif klass == 'AK::RefCounted':
|
elif klass == 'AK::RefCounted':
|
||||||
|
@ -91,6 +93,45 @@ class AKDistinctNumeric:
|
||||||
return f'AK::DistinctNumeric<{handler_class_for_type(contained_type).prettyprint_type(contained_type)}>'
|
return f'AK::DistinctNumeric<{handler_class_for_type(contained_type).prettyprint_type(contained_type)}>'
|
||||||
|
|
||||||
|
|
||||||
|
class AKFixedArrayPrinter:
|
||||||
|
def __init__(self, val):
|
||||||
|
self.val = val
|
||||||
|
|
||||||
|
def get_storage(self):
|
||||||
|
storage = self.val["m_storage"]
|
||||||
|
|
||||||
|
return None if int(storage) == 0 else storage
|
||||||
|
|
||||||
|
def to_string(self):
|
||||||
|
storage = self.get_storage()
|
||||||
|
if storage is not None:
|
||||||
|
size = storage["size"]
|
||||||
|
else:
|
||||||
|
size = 0
|
||||||
|
|
||||||
|
return f'{AKFixedArrayPrinter.prettyprint_type(self.val.type)} of size {size}'
|
||||||
|
|
||||||
|
def children(self):
|
||||||
|
storage = self.get_storage()
|
||||||
|
|
||||||
|
if storage is None:
|
||||||
|
return []
|
||||||
|
else:
|
||||||
|
size = storage["size"]
|
||||||
|
elements = storage["elements"]
|
||||||
|
|
||||||
|
# Very arbitrary limit, just to catch UAF'd and garbage vector values with a silly number of elements
|
||||||
|
if size > 373373:
|
||||||
|
return []
|
||||||
|
|
||||||
|
return [(f"[{i}]", elements[i]) for i in range(size)]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def prettyprint_type(cls, type):
|
||||||
|
template_type = type.template_argument(0)
|
||||||
|
return f'AK::FixedArray<{handler_class_for_type(template_type).prettyprint_type(template_type)}>'
|
||||||
|
|
||||||
|
|
||||||
class AKRefCounted:
|
class AKRefCounted:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue