libgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPC
authorRaphael Moreira Zinsly <rzinsly@linux.ibm.com>
Tue, 5 Oct 2021 18:32:52 +0000 (15:32 -0300)
committerSegher Boessenkool <segher@kernel.crashing.org>
Thu, 14 Oct 2021 20:00:44 +0000 (20:00 +0000)
commitb7561b5d2443f1d5f54f5177f0fb1a13c4205856
treeb146d395c0cf2844e5f122eae30920805ea723ea
parentb47490c572c5938f887b54240af6096a7c90f640
libgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPC

Without dwarf2 unwind tables available _Unwind_Backtrace() is not
able to return the full backtrace.
This patch adds a fallback function on powerpc to get the backtrace
by doing a backchain, this code was originally at glibc.

libgcc/ChangeLog:

* config/rs6000/linux-unwind.h (struct rt_sigframe): Move it to
outside of get_regs() in order to use it in another function, this
is done twice: for __powerpc64__ and for !__powerpc64__.
(struct trace_arg): New struct.
(struct layout): New struct.
(ppc_backchain_fallback): New function.
* unwind.inc (_Unwind_Backtrace): Look for _URC_NORMAL_STOP code
state and call MD_BACKCHAIN_FALLBACK.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/unwind-backchain.c: New test.
gcc/testsuite/gcc.target/powerpc/unwind-backchain.c [new file with mode: 0644]
libgcc/config/rs6000/linux-unwind.h
libgcc/unwind.inc