Re: [PATCH v2 9/9] gdb, mi: Add -shadow-stack-list-frames command

Tom Tromey
2026-02-19T18:27:13Z

>>>>> Christina Schimpe <christina.schimpe@intel.com> writes:

> +void
> +mi_cmd_shadow_stack_list_frames (const char *command,
> + const char *const *argv,
> + int argc)

> + /* Check if START_SSP points to a shadow stack memory range and use
> + the returned range to determine when to stop unwinding.
> + Note that a shadow stack memory range can change, due to shadow stack
> + switches for instance on x86 for an inter-privilege far call or when
> + calling an interrupt/exception handler at a higher privilege level.
> + Shadow stack for userspace is supported for amd64 linux starting with
> + Linux kernel v6.6. However, shadow stack switches are not supported
> + due to missing kernel space support. We therefore implement this
> + command without support for shadow stack switches for now. */
> + std::pair<CORE_ADDR, CORE_ADDR> range;
> + if (!gdbarch_address_in_shadow_stack_memory_range (gdbarch, *start_ssp,
> + &range))
> + {
> + /* If START_SSP points off the shadow stack memory range, we cannot
> + print the shadow stack backtrace. This is possible, for
> + instance, on x86 if NEW_SSP points to the end of RANGE which
> + means that the shadow stack is empty. */
> + return;
> + }

It seems like more of this could be shared with the earlier patch.
Replicating a lot of the logic doesn't seem good.

The gdb_printfs in the other code can be handled by changing them to use
ui_out::text or ui_out::message instead.

> + if (!curr.has_value ())
> + error (_("-shadow-stack-list-frames: Not enough frames on the shadow "
> + "stack."));

For things like this maybe the API has to be changed a little but that
seems fine.

Tom