1. android NDK-STACK toolNDK-Stack is a very easy-to-use tool that displays information to adb logcat to help you analyze Stack tracing, and then use the corresponding value (which line of the source code) to replace the address in the static Link Library.
In the output area of adb logcat, You can see information similar to the following, but before that, we must first parse it.
I/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***I/DEBUG ( 31): Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'I/DEBUG ( 31): pid: 351, tid: 351 %gt;%gt;%gt; /data/local/ndk-tests/crasher <<<I/DEBUG ( 31): signal 11 (SIGSEGV), fault addr 0d9f00d8I/DEBUG ( 31): r0 0000af88 r1 0000a008 r2 baadf00d r3 0d9f00d8I/DEBUG ( 31): r4 00000004 r5 0000a008 r6 0000af88 r7 00013c44I/DEBUG ( 31): r8 00000000 r9 00000000 10 00000000 fp 00000000I/DEBUG ( 31): ip 0000959c sp be956cc8 lr 00008403 pc 0000841e cpsr 60000030I/DEBUG ( 31): #00 pc 0000841e /data/local/ndk-tests/crasherI/DEBUG ( 31): #01 pc 000083fe /data/local/ndk-tests/crasherI/DEBUG ( 31): #02 pc 000083f6 /data/local/ndk-tests/crasherI/DEBUG ( 31): #03 pc 000191ac /system/lib/libc.soI/DEBUG ( 31): #04 pc 000083ea /data/local/ndk-tests/crasherI/DEBUG ( 31): #05 pc 00008458 /data/local/ndk-tests/crasherI/DEBUG ( 31): #06 pc 0000d362 /system/lib/libc.soI/DEBUG ( 31):
2. How to use this tool? If you successfully compile an android Cocos2d-x project, it will produce a static link library under the $ PROJECT_PATH/obj/local/directory, this indicates the ABI of your device (for example, the default value is armeabi ).
You can use the output result as the input, as shown below:
adb logcat | $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi
Alternatively, you can use the-dump option to save the specified logcat as a file as the input, as shown below:
adb logcat > /tmp/foo.txt$NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi -dump foo.txt
Finally, you can get more valid and readable output information:
********** 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 0d9f00d8Stack frame #00 pc 0000841e /data/local/ndk-tests/crasher : Routine zoo in /tmp/foo/crasher/jni/zoo.c:13Stack frame #01 pc 000083fe /data/local/ndk-tests/crasher : Routine bar in /tmp/foo/crasher/jni/bar.c:5Stack frame #02 pc 000083f6 /data/local/ndk-tests/crasher : Routine my_comparison in /tmp/foo/crasher/jni/foo.c:9Stack frame #03 pc 000191ac /system/lib/libc.soStack frame #04 pc 000083ea /data/local/ndk-tests/crasher : Routine foo in /tmp/foo/crasher/jni/foo.c:14Stack frame #05 pc 00008458 /data/local/ndk-tests/crasher : Routine main in /tmp/foo/crasher/jni/main.c:19Stack frame #06 pc 0000d362 /system/lib/libc.so
3. Important
The logcat output of the NDK-STACK tool requires an initialization line, as shown below:
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
When copying/pasting tracing information, do not forget to include this initialization line, otherwise the NDK-STACK tool will not work properly.
At present, for all platforms (linux/windows/mac) NDK (visible Android Developer), NDK-STACK is effective.
4. References
$ NDK_ROOT/docs/NDK-STACK.html
Support original, original post address: http://www.cocoachina.com/bbs/read.php? Tid = 195644