分享

Android ndk-stack tool

 univasity 2014-02-11

‘ndk-stack’ is a good and simple  tool that allows you to analize stack traces as they appear in the output of ‘adb logcat’ and replace any address inside a stripped shared library with the corresponding <file name>:<line number>. In a nutshell, it will decode the log  of native crash as in the example :

I/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** **
I/DEBUG ( 31): signal 11 (SIGSEGV), fault addr 0d9f00d8
I/DEBUG ( 31): r0 0000af88 r1 0000a008 r2 baadf00d r3 0d9f00d8
I/DEBUG ( 31): r4 00000004 r5 0000a008 r6 0000af88 r7 00013c44
I/DEBUG ( 31): r8 00000000 r9 00000000 10 00000000 fp 00000000
I/DEBUG ( 31): ip 0000959c sp be956cc8 lr 00008403 pc 0000841e cpsr 60000030
I/DEBUG ( 31): #00 pc 0000841e /data/local/ndk-tests/crasher
I/DEBUG ( 31): #01 pc 000083fe /data/local/ndk-tests/crasher
I/DEBUG ( 31): #02 pc 000083f6 /data/local/ndk-tests/crasher
I/DEBUG ( 31): #03 pc 000191ac /system/lib/libc.so
I/DEBUG ( 31): #04 pc 000083ea /data/local/ndk-tests/crasher
I/DEBUG ( 31): #05 pc 00008458 /data/local/ndk-tests/crasher
I/DEBUG ( 31): #06 pc 0000d362 /system/lib/libc.so
I/DEBUG ( 31):

Into the more readable output:

********** Crash dump: **********
Build fingerprint: ‘generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys’
pid: 351, tid: 351 >>> /data/local/ndk-tests/crasher <<<

signal 11 (SIGSEGV), fault addr 0d9f00d8
Stack frame #00 pc 0000841e /data/local/ndk-tests/crasher : Routine zoo in /tmp/foo/crasher/jni/zoo.c:13
Stack frame #01 pc 000083fe /data/local/ndk-tests/crasher : Routine bar in /tmp/foo/crasher/jni/bar.c:5
Stack frame #02 pc 000083f6 /data/local/ndk-tests/crasher : Routine my_comparison in /tmp/foo/crasher/jni/foo.c:9
Stack frame #03 pc 000191ac /system/lib/libc.so
Stack frame #04 pc 000083ea /data/local/ndk-tests/crasher : Routine foo in /tmp/foo/crasher/jni/foo.c:14
Stack frame #05 pc 00008458 /data/local/ndk-tests/crasher : Routine main in /tmp/foo/crasher/jni/main.c:19
Stack frame #06 pc 0000d362 /system/lib/libc.so

How to use this tool.

To do this, you will first need a directory containing symbolic versions of your application’s shared libraries. If you use the NDK build system (i.e. ndk-build),

You can use this tool in to ways.

1)  adb logcat |  ndk-stack -sym <Path to  your shared libraries>

2)  ndk-stack -sym <Path to  your shared libraries> -dump <file name containing the  crash logs>

Now both the versions(linux/windows/mac) of ndk-stack are available  at Android Developer .

References:    StackOverflow and Android Developer 

Regards

YS

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多