Play cocos2d-x 38 how to use NDK-STACK tool to restore Cocos2d-x Android error stack information

Source: Internet
Author: User

A lot of kids shoes in the tangle In the Cocos2d-x Android project how to debug the JNI part of the C ++ code, after eating 2 Tea egg I decided to enlarge the move...

Http://www.cocos2d-x.org/forums/6/topics/46225

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 in the $ PROJECT_PATH/obj/local/<abi> directory, <abi> indicates the ABI of your device (for example, armeabi by default ).

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.