I'm developing the native application that works with Android via the NDK.
I need to call the backtrace()
function when there is a crash. The problem is that there is no <execinfo.h>
for the NDK.
Is there any other way to get that back trace?
backtrace()
is a non-standard Glibc extension, and even then somewhat shaky on ARM (you need to have built everything with -funwind-tables
, I think, and then have a somewhat new Glibc?)
As far as I know, this function is not included in the Bionic C library used by Android.
You could try pulling the source for Glibc backtrace into your project, and then rebuilding the interesting things with the unwind table, but it sounds like hard work to me.
If you have debug info, you could try launching GDB with a script that attaches to your process, and prints a backtrace that way, but I have no idea if GDB works on Android (although Android is basically Linux, so that much id fine, the installation details may be problematic?) You may get further by dumping core somehow (does Bionic support that?) and analysing it after-the-fact.