mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
Meta: Add a gdb pretty printer for AK::Array
This commit is contained in:
parent
b11a34330a
commit
8c2a88e492
Notes:
sideshowbarker
2024-07-18 02:11:41 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/8c2a88e492f Pull-request: https://github.com/SerenityOS/serenity/pull/10528 Reviewed-by: https://github.com/alimpfard
1 changed files with 27 additions and 2 deletions
|
@ -12,11 +12,13 @@ def handler_class_for_type(type, re=re.compile('^([^<]+)(<.*>)?$')):
|
|||
|
||||
match = re.match(typename)
|
||||
if not match:
|
||||
return None
|
||||
return UnhandledType
|
||||
|
||||
klass = match.group(1)
|
||||
|
||||
if klass == 'AK::Atomic':
|
||||
if klass == 'AK::Array':
|
||||
return AKArray
|
||||
elif klass == 'AK::Atomic':
|
||||
return AKAtomic
|
||||
elif klass == 'AK::DistinctNumeric':
|
||||
return AKDistinctNumeric
|
||||
|
@ -257,6 +259,29 @@ class AKVector:
|
|||
return f'AK::Vector<{handler_class_for_type(template_type).prettyprint_type(template_type)}>'
|
||||
|
||||
|
||||
class AKArray:
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
self.storage_type = self.val.type.template_argument(0)
|
||||
self.array_size = self.val.type.template_argument(1)
|
||||
|
||||
def to_string(self):
|
||||
return AKArray.prettyprint_type(self.val.type)
|
||||
|
||||
def children(self):
|
||||
data_array = self.val["__data"]
|
||||
storage_type_ptr = self.storage_type.pointer()
|
||||
elements = data_array.cast(storage_type_ptr)
|
||||
|
||||
return [(f"[{i}]", elements[i]) for i in range(self.array_size)]
|
||||
|
||||
@classmethod
|
||||
def prettyprint_type(cls, type):
|
||||
template_type = type.template_argument(0)
|
||||
template_size = type.template_argument(1)
|
||||
return f'AK::Array<{template_type}, {template_size}>'
|
||||
|
||||
|
||||
class AKHashMapPrettyPrinter:
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
|
|
Loading…
Add table
Reference in a new issue