Skip to contentSkip to conversation

scripts/gdb: Fix interrupts.py after maple tree conversion

PATCH Superseded Florian Fainelli 1 participant 2 messages Jun 20, 2025 GDB kernel debugging helper scripts

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/gdb: Fix interrupts.py after maple tree conversion

In commit 721255b9826b ("genirq: Use a maple tree for interrupt descriptor management"), the irq_desc_tree was replaced with a sparse_irqs tree using a maple tree structure. In the interest of providing both a minimal bugfix as well as something that is unlikely to break in the future, invoke the irq_to_desc() function directly from within GDB in order to obtain the interrupt number. This requires us to handle the gdb.error exception to continue walking the tree.

Fixes 721255b9826b ("genirq: Use a maple tree for interrupt descriptor management")
---
 scripts/gdb/linux/interrupts.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
scripts/gdb/linux/interrupts.py +6 -8
index 616a5f26377a..81bfa09f45fb 100644
@@ -7,7 +7,6 @@ import gdb
 from linux import constants
 from linux import cpus
 from linux import utils
-from linux import radixtree
 
 irq_desc_type = utils.CachedType("struct irq_desc")
 
@@ -23,12 +22,11 @@ def irqd_is_level(desc):
 def show_irq_desc(prec, irq):
     text = ""
 
-    desc = radixtree.lookup(gdb.parse_and_eval("&irq_desc_tree"), irq)
-    if desc is None:
-        return text
-
-    desc = desc.cast(irq_desc_type.get_type())
-    if desc is None:
+    try:
+        desc = gdb.parse_and_eval(f"irq_to_desc({irq})")
+        if desc == 0:
+            return text
+    except gdb.error:
         return text
 
     if irq_settings_is_hidden(desc):
@@ -221,7 +219,7 @@ class LxInterruptList(gdb.Command):
             gdb.write("CPU%-8d" % cpu)
         gdb.write("\n")
 
-        if utils.gdb_eval_or_none("&irq_desc_tree") is None:
+        if utils.gdb_eval_or_none("&irq_desc_tree") or utils.gdb_eval_or_none("&sparse_irqs") is None:
             return
 
         for irq in range(nr_irqs):
Signature · 1 line
2.43.0
#1 lore raw
Quoted 9 lines · Florian Fainelli

In commit 721255b9826b ("genirq: Use a maple tree for interrupt descriptor management"), the irq_desc_tree was replaced with a sparse_irqs tree using a maple tree structure. In the interest of providing both a minimal bugfix as well as something that is unlikely to break in the future, invoke the irq_to_desc() function directly from within GDB in order to obtain the interrupt number. This requires us to handle the gdb.error exception to continue walking the tree.

Quoted 1 line
Fixes 721255b9826b ("genirq: Use a maple tree for interrupt descriptor management")

Humm, looks like we might not have a choice than to be able to parse a maple tree within GDB. While this approach of calling irq_to_desc() worked correctly on x86 under QEMU, this failed on arm64.

pw-bot: cr

Signature · 1 line
Florian