mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
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:
parent
6b25842b10
commit
0fbc5893bf
Notes:
sideshowbarker
2024-07-18 17:38:07 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/0fbc5893bfc Pull-request: https://github.com/SerenityOS/serenity/pull/7342 Reviewed-by: https://github.com/gunnarbeutner ✅
1 changed files with 21 additions and 0 deletions
|
@ -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':
|
||||
|
|
Loading…
Reference in a new issue