Android under no execinfo.h, you can't print the back trace method under glibc.
Glic print back trace see: http://blog.csdn.net/span76/article/details/11927551
I have written the following method for reference:
#include <signal.h> #include <corkscrew/backtrace.h>static void Pnpdumpnativestack (int sig) {#if defined (have_android_os) | | (Defined (Have_alien) &&!defined (ALIEN_LIBC)) const size_t max_depth = 32; backtrace_frame_t Backtrace[max_depth]; ssize_t frames = Unwind_backtrace_thread (tid, backtrace, 0, max_depth); if (Frames > 0) {backtrace_symbol_t backtrace_symbols[max_depth]; Get_backtrace_symbols (BackTrace, frames, backtrace_symbols); for (size_t i = 0; i < size_t (frames); i++) {char line[max_backtrace_line_length]; Format_backtrace_line (i, &backtrace[i], &backtrace_symbols[i], line, max_backtrace_line_length) ; Aloge ("==================%s\n", line); } free_backtrace_symbols (Backtrace_symbols, frames); } #endif}...void dvmcollectgarbageinternal (const gcspec* spec) {signal (SIGSEGV, pnpdumpnativestack); ...
Android is using a similar Execinfo method provided by Libcorkscrew to get backtrace information.
Unfortunately, every time I print the print is not complete, such as the following 2, for reasons to be identified.
09-30 03:38:49.821 137 137 E DALVIKVM: ================== #00 pc 00026edb/. /system/lib/libdvm.so
09-30 03:38:49.821 137 137 E DALVIKVM: ================== #01 pc 00000400 [VDSO]
Android under Print BackTrace