From 0fbc5893bfc34d2a2fbe41566cc85e67047b156d Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Fri, 21 May 2021 02:14:19 -0700 Subject: Meta: Add GDB pretty printer for AK::InlineLinkedList This allows a developer to easily dump a InlineLinkedList in the debugger without having to manually running the list. I needed this for a recent bug investigation in the Kernel. --- Meta/serenity_gdb.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Meta/serenity_gdb.py') diff --git a/Meta/serenity_gdb.py b/Meta/serenity_gdb.py index 380037ee63..ce4e6e6ac2 100644 --- a/Meta/serenity_gdb.py +++ b/Meta/serenity_gdb.py @@ -159,6 +159,25 @@ class AKHashMapPrettyPrinter: return elements +class AKInlineLinkedList: + def __init__(self, val): + self.val = val + + def to_string(self): + return self.val.type.name + + def children(self): + node_type_ptr = self.val.type.template_argument(0).pointer() + + elements = [] + node = self.val["m_head"] + while node != 0: + elements.append(node.cast(node_type_ptr)) + node = node["m_next"] + + return [(f"[{i}]", elements[i].dereference()) for i in range(len(elements))] + + class VirtualAddress: def __init__(self, val): self.val = val @@ -187,6 +206,8 @@ class SerenityPrettyPrinterLocator(gdb.printing.PrettyPrinter): return AKAtomic(val) elif klass == 'AK::DistinctNumeric': return AKDistinctNumeric(val) + elif klass == 'AK::InlineLinkedList': + return AKInlineLinkedList(val) elif klass == 'AK::HashMap': return AKHashMapPrettyPrinter(val) elif klass == 'AK::RefCounted': -- cgit v1.2.3