Skip to contentSkip to conversation

scripts/gdb: add a Radix Tree Parser

PATCH New [email protected] 1 participant 1 message May 23, 2016 GDB kernel debugging helper scripts

lore
Share & tools
lore
#0 lore raw

PATCH 59/84 scripts/gdb: add a Radix Tree Parser

From: Kieran Bingham <[email protected]>
Subject: scripts/gdb: add a Radix Tree Parser

Linux makes use of the Radix Tree data structure to store pointers indexed by integer values. This structure is utilised across many structures in the kernel including the IRQ descriptor tables, and several filesystems.

This module provides a method to lookup values from a structure given its head node.

Usage:

The function lx_radix_tree_lookup, must be given a symbol of type struct radix_tree_root, and an index into that tree.

The object returned is a generic integer value, and must be cast correctly to the type based on the storage in the data structure.

For example, to print the irq descriptor in the sparse irq_desc_tree at index 18, try the following:

(gdb) print (struct irq_desc)$lx_radix_tree_lookup(irq_desc_tree, 18)

---

 scripts/gdb/linux/constants.py.in |    7 ++
 scripts/gdb/linux/radixtree.py    |   97 ++++++++++++++++++++++++++++
 scripts/gdb/vmlinux-gdb.py        |    1 
 3 files changed, 105 insertions(+)
scripts/gdb/linux/constants.py.in renamed from scripts/gdb/linux/constants.py.in~scripts-gdb-add-a-radix-tree-parser +7 -0
diff -puN scripts/gdb/linux/constants.py.in~scripts-gdb-add-a-radix-tree-parser scripts/gdb/linux/constants.py.in
@@ -14,6 +14,7 @@
 
 #include <linux/fs.h>
 #include <linux/mount.h>
+#include <linux/radix-tree.h>
 
 /* We need to stringify expanded macros so that they can be parsed */
 
@@ -50,3 +51,9 @@ LX_VALUE(MNT_NOEXEC)
 LX_VALUE(MNT_NOATIME)
 LX_VALUE(MNT_NODIRATIME)
 LX_VALUE(MNT_RELATIME)
+
+/* linux/radix-tree.h */
+LX_VALUE(RADIX_TREE_INDIRECT_PTR)
+LX_GDBPARSED(RADIX_TREE_HEIGHT_MASK)
+LX_GDBPARSED(RADIX_TREE_MAP_SHIFT)
+LX_GDBPARSED(RADIX_TREE_MAP_MASK)
scripts/gdb/linux/radixtree.py new file +97 -0

97 lines not on this page · raw message

scripts/gdb/vmlinux-gdb.py renamed from scripts/gdb/vmlinux-gdb.py~scripts-gdb-add-a-radix-tree-parser +1 -0
diff -puN scripts/gdb/vmlinux-gdb.py~scripts-gdb-add-a-radix-tree-parser scripts/gdb/vmlinux-gdb.py
@@ -31,3 +31,4 @@ else:
     import linux.lists
     import linux.proc
     import linux.constants
+    import linux.radixtree

_