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.
This commit is contained in:
Brian Gianforcaro 2021-05-21 02:14:19 -07:00 committed by Andreas Kling
parent 6b25842b10
commit 0fbc5893bf
Notes: sideshowbarker 2024-07-18 17:38:07 +09:00

View file

@ -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':