Re: [PATCH] scripts/gdb: Fix radix tree lookup pointer handling
From: Andrew Morton
Date: Sat Oct 10 2026 - 17:17:18 EST
On Wed, 7 Oct 2026 02:31:24 -0700 Ting-Han Hou <ue081723@xxxxxxxxx> wrote:
> lookup() casts each slot to a pointer to a node pointer and then
> dereferences it. Since the slot already contains an entry pointer,
> this reads the entry's contents as another pointer instead of
> returning the entry itself.
>
> Internal entries also need their tag bits removed before descending
> to the next node.
>
> Return non-internal entries directly and use entry_to_node() when
> descending through internal entries. Remove the explicit shift
> counter, as traversal now follows the entry type.
>
> Fixes: b7235d6bb516 ("scripts/gdb: add a Radix Tree Parser")
> Assisted-by: LLM
> Signed-off-by: Ting-Han Hou <ue081723@xxxxxxxxx>
> ---
> Tested with GDB 15.1 against standalone GCC-built C fixtures using the
> xarray/xa_node field layout, with XA_CHUNK_SHIFT=4 and 6. These are
> synthetic debugger fixtures, not a booted kernel or a kernel core dump.
>
> Before the fix, a one-level lookup returned the payload 0x12345678
> instead of its address; a two-level lookup missed a populated slot.
> After the fix, all 33 checks passed for each slot configuration (66
> total), including empty/direct roots, one- to three-level trees,
> zero-filled payloads, value entries, absent/out-of-range indices,
> struct/pointer roots, and the GDB convenience function.
>
> This does not test multi-index entries or concurrent updates/retry
> entries. The change is limited to the debugger lookup helper.
Thanks. Sashiko expressed a concern:
https://sashiko.dev/#/patchset/CA+NtrhTyE4J-C2=hSUXYc+NJBsQeYvbwJb+-ROHE1QQP-_gYzg@xxxxxxxxxxxxxx
your other patch doesn't apply due to word-wrapping.
Please turn these into a 2-patch series.