Re: [PATCH v3 07/19] unwind: Add user space unwinding API
From: Josh Poimboeuf
Date: Mon Dec 09 2024 - 15:55:05 EST
On Fri, Dec 06, 2024 at 11:29:21AM +0100, Jens Remus wrote:
> On 28.10.2024 22:47, Josh Poimboeuf wrote:
> > + if (ra == prev_ip)
> > + goto the_end;
>
> This seems too restrictive to me, as it effectively prevents
> unwinding from recursive functions, e.g. Glibc internal merge sort
> msort_with_tmp():
>
> $ perf record -F 9999 --call-graph fp /usr/bin/objdump -wdWF /usr/bin/objdump
> $ perf script
> ...
> objdump 8314 236064.515562: 100010 task-clock:ppp:
> 100630a compare_symbols+0x2a (/usr/bin/objdump)
> 3ffb9e58e7c msort_with_tmp.part.0+0x15c (/usr/lib64/libc.so.6)
> 3ffb9e58d76 msort_with_tmp.part.0+0x56 (/usr/lib64/libc.so.6)
> [unwinding unexpectedly stops]
>
> Would it be an option to only stop unwinding if both the IP and SP do
> not change?
>
> if (sp == prev_sp && ra == prev_ra)
> gote the_end;
Good point, I've already fixed that for the next version (not yet
posted). I believe the only thing we really need to check here is that
the unwind is heading in the right direction:
if (cfa <= state->sp)
goto the_end;
--
Josh