summaryrefslogtreecommitdiff
path: root/Meta/serenity_gdb.py
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-10-17 13:22:10 -0700
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-10-18 03:27:27 -0700
commit8c2a88e492ff1afb229fda20d54324ad822a120f (patch)
tree57e90b6f150e8054818dcb8cb3b1b4029514d2a5 /Meta/serenity_gdb.py
parentb11a34330a1ddab811419a696056e10448e7991b (diff)
downloadserenity-8c2a88e492ff1afb229fda20d54324ad822a120f.zip
Meta: Add a gdb pretty printer for AK::Array
Diffstat (limited to 'Meta/serenity_gdb.py')
-rw-r--r--Meta/serenity_gdb.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/Meta/serenity_gdb.py b/Meta/serenity_gdb.py
index 8b489a3532..d68c3584b9 100644
--- a/Meta/serenity_gdb.py
+++ b/Meta/serenity_gdb.py
@@ -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