MINOR: debug: improve backtrace() on aarch64 and possibly other systems
authorWilly Tarreau <w@1wt.eu>
Wed, 4 Mar 2020 06:44:06 +0000 (07:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2020 15:09:20 +0000 (17:09 +0200)
commit6740eeafd2ab2c837fe53fca48360b07c3011304
tree7949f2798f815ade9240d7189b4f9fa31e827541
parentf71f2d562c3a1ef8d993070d04327a3209105529
MINOR: debug: improve backtrace() on aarch64 and possibly other systems

It happens that on aarch64 backtrace() only returns one entry (tested
with gcc 4.7.4, 5.5.0 and 7.4.1). Probably that it refrains from unwinding
the stack due to the risk of hitting a bad pointer. Here we can use
may_access() to know when it's safe, so we can actually unwind the stack
without taking risks. It happens that the faulting function (the one
just after the signal handler) is not listed here, very likely because
the signal handler uses a special stack and did not create a new frame.

So this patch creates a new my_backtrace() function in standard.h that
either calls backtrace() or does its own unrolling. The choice depends
on HA_HAVE_WORKING_BACKTRACE which is set in compat.h based on the build
target.

(cherry picked from commit 13faf16e1ebfc93e49dc5a8948519fad600e1136)
[wt: adjusted context in debug.c]
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/common/compat.h
include/common/standard.h
src/debug.c