[RFC PATCH] gdb/frame: Refine stack switch heuristic

Tom Tromey tom@tromey.com
Fri Mar 11 20:17:02 GMT 2022


>>>>> Keno Fischer via Gdb-patches <gdb-patches@sourceware.org> writes:

Hi.  Thank you for the patch.

> Here I propose the following extension to GDB's heuristic: If the
> CFA of a frame is declared using DW_CFA_def_cfa_expression, i.e.
> is a DWARF expression, then gdb disables the heuristic, because
> clearly something fancy is going on with the stacks.

I suppose I'm ok with this.

> An alternatively could
> be a more explicit way to mark stack switchers in the CFI that
> does not involve requiring a symbol lookup, but that would probably
> require more coordination with the standards authors and CFI
> producers, which doesn't seem worthwhile at this juncture.

Yeah, I wouldn't recommend attempting that.

> +  /* Set if we heuristically think that this function is a stack
> +     switcher */
> +  int stack_switch_heuristic;

Might as well use bool here, then true/false elsewhere.

> +    (*this_id) = frame_id_build_stack_switch (cache->cfa, get_frame_func (this_frame));

Probably have to line-break after the ",".

> +  if (fid->stack_status == FID_STACK_VALID || fid->stack_status == FID_ALLOW_STACK_SWITCH)

Should line-break before the "||".

Is there any reasonable way to write a test case for this?

Tom


More information about the Gdb-patches mailing list