How to get longer stack dump (tombstone) from android?
The crash handling program in android, which is called debuggerd, only writes a portion of the stack into the log, but writes the full stack into the tombstone file. This is hardcoded in system/core/debuggerd/debuggerd.c.
Look in the routine debug_stack_and_code() for the calls to _LOG(). The second parameter to _LOG controls whether stuff goes only to the tombstone, or to the log and the tombstone.
Where you see (sp_depth>2||only_in_tombstone)
, you can change the 2 to something else to get deeper stack frames reported in the log. This assumes that you can re-compile debuggerd and replace it on your system. If not, you're stuck with examining the tombstone files themselves for the longer stack dumps.
The dumps are created by debuggerd when a program crashes under Linux. When this happens, the kernel will send a signal to the dying program. This signal is caught by a special signal handler installed in every native Android app. by the bionic C library. The signal handler contacts debuggerd (via a named pipe), which then connects back to the dying program using ptrace to read registers and memory to produce the tombstone and log entries.
I suggest debugging the stack trace found in the tombstone file like the example below.
Example:
#00 pc 00010a20 /system/lib/libc.so#01 pc 0000b332 /system/lib/libc.so#02 pc 0000ca62 /system/lib/bluez-plugin/audio.so#03 pc 0000d1ce /system/lib/bluez-plugin/audio.so#04 pc 0000e0ba /system/lib/bluez-plugin/audio.so
You can use the command below to know the function name, file name and line no.
$(android-root)prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/addr2line -f -e /out/product/xxx/symbols/system/<SO filename> <PC address>
Example:
$(android-root)prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/addr2line -f -e /out/product/xxx/symbols/system/libc.so 0x00010a20