[PATCH v4 2/5] elf: Add SFrame stack tracing

Florian Weimer fweimer@redhat.com
Fri Apr 18 15:09:37 GMT 2025


* claudiu zissulescu-ianculescu:

> +/* Initialize the SFrame backtrace routine, and try to backtrace the
> +   current stack using SFrame info.  The return value of SFrame stack
> +   tracer must be larger than one to consider the SFrame backtrace
> +   valid. Otherwise, there may be the case that glibc is compiled
> +   using SFrame but the application not.   */
> +
> +#define DO_SFRAME_BACKTRACE(ARRAY, SIZE)			\
> +  do								\
> +    {								\
> +      int cnt;							\
> +      frame frame;						\
> +      frame.pc = getPC();					\
> +      frame.sp = getSP();					\
> +      frame.fp = (_Unwind_Ptr) __builtin_frame_address (0);	\
> +      cnt = stacktrace_sframe (ARRAY, SIZE, &frame);		\
> +      if (cnt > 1)						\
> +	return cnt;						\
> +    }								\
> +  while(0)

Shouldn't this switch to DWARF backtracing to avoid a truncated
backtrace?  Otherwise std::stacktrace::current() will not work anymore
once glibc and libstdc++ are upgraded, I think.

Thanks,
Florian



More information about the Libc-alpha mailing list