How to get longer stack dump (tombstone) from android?

前端 未结 2 1655
情歌与酒
情歌与酒 2020-12-23 15:29

As I have noticed, logcat returns always 34 lines of crashlog, like this:

4cf7c700  401c0000 
4cf7c704  48463ff0 
4cf7c708  44d11f7c  
4cf7c70c  afd0cd89 
4         


        
相关标签:
2条回答
  • 2020-12-23 16:00

    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
    
    0 讨论(0)
  • 2020-12-23 16:11

    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.

    0 讨论(0)
提交回复
热议问题