diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-05-22 12:01:48 +0430 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-05-22 13:21:00 +0430 |
commit | 3d0786f96b9157b959409f43a8eb5312ec847e04 (patch) | |
tree | 6d1ddc0f6083a6e50627cd162e652e95aa3e7f8c /Meta/serenity_gdb.py | |
parent | 37651a28e185857abfd5cab5139d36d9eee643bb (diff) | |
download | serenity-3d0786f96b9157b959409f43a8eb5312ec847e04.zip |
Meta: Add GDB pretty printer for AK::Variant
Diffstat (limited to 'Meta/serenity_gdb.py')
-rw-r--r-- | Meta/serenity_gdb.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Meta/serenity_gdb.py b/Meta/serenity_gdb.py index 7e3f7d1d7f..5cd6aef5db 100644 --- a/Meta/serenity_gdb.py +++ b/Meta/serenity_gdb.py @@ -40,6 +40,8 @@ def handler_class_for_type(type, re=re.compile('^([^<]+)(<.*>)?$')): return AKStringView elif klass == 'AK::StringImpl': return AKStringImpl + elif klass == 'AK::Variant': + return AKVariant elif klass == 'AK::Vector': return AKVector elif klass == 'VirtualAddress': @@ -186,6 +188,40 @@ class AKRefPtr: return f'AK::RefPtr<{handler_class_for_type(contained_type).prettyprint_type(contained_type)}>' +class AKVariant: + def __init__(self, val): + self.val = val + self.index = int(self.val["m_index"]) + self.contained_types = self.resolve_types(self.val.type) + + def to_string(self): + return AKVariant.prettyprint_type(self.val.type) + + def children(self): + data = self.val["m_data"] + ty = self.contained_types[self.index] + return [(ty.name, data.cast(ty.pointer()).referenced_value())] + + @classmethod + def resolve_types(cls, ty): + contained_types = [] + type_resolved = ty.strip_typedefs() + index = 0 + while True: + try: + arg = type_resolved.template_argument(index) + index += 1 + contained_types.append(arg) + except RuntimeError: + break + return contained_types + + @classmethod + def prettyprint_type(cls, ty): + names = ", ".join(handler_class_for_type(t).prettyprint_type(t) for t in AKVariant.resolve_types(ty)) + return f'AK::Variant<{names}>' + + class AKVector: def __init__(self, val): self.val = val |