【玩转cocos2d-x之三十八】如何使用NDK-STACK tool来恢复Cocos2d-x安卓错误堆栈信息
生活随笔
收集整理的這篇文章主要介紹了
【玩转cocos2d-x之三十八】如何使用NDK-STACK tool来恢复Cocos2d-x安卓错误堆栈信息
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
很多童鞋在糾結(jié)在Cocos2d-x中安卓項(xiàng)目如何調(diào)試JNI部分的C++代碼,在吃完2個(gè)茶葉蛋后我決定放大招。。。
本文翻譯自: http://www.cocos2d-x.org/forums/6/topics/46225
在adb logcat的輸出區(qū),你可以看到類似下面的信息,但是在此之前我們必須先先對(duì)它進(jìn)行解析。
[cpp]?view plaincopy 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?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):??
adb?logcat?|?$NDK/ndk-stack?-sym?$PROJECT_PATH/obj/local/armeabi??
adb?logcat?>?/tmp/foo.txt?? $NDK/ndk-stack?-sym?$PROJECT_PATH/obj/local/armeabi?-dump?foo.txt??
**********?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??
***?***?***?***?***?***?***?***?***?***?***?***?***?***?***?***??
目前對(duì)各平臺(tái)(linux/windows/mac)的NDK(可見 Android Developer ),NDK-STACK都是有效的。
本文翻譯自: http://www.cocos2d-x.org/forums/6/topics/46225
1.安卓 NDK-STACK tool
NDK-Stack 是一個(gè)非常易用的工具,它通過將信息顯示到adb logcat中來輔助你分析堆棧追蹤,然后用相應(yīng)的值(哪篇源碼的哪一行)來替代靜態(tài)鏈接庫(kù)中的地址。在adb logcat的輸出區(qū),你可以看到類似下面的信息,但是在此之前我們必須先先對(duì)它進(jìn)行解析。
[cpp]?view plaincopy
2.如何使用這個(gè)工具?
如果你成功地編譯了一個(gè)Cocos2d-x安卓項(xiàng)目,它將會(huì)在$PROJECT_PATH/obj/local/<abi>目錄下生產(chǎn)一個(gè)靜態(tài)鏈接庫(kù),這里的<abi>代表你的設(shè)備的ABI(比如,默認(rèn)為armeabi)。你可以將輸出結(jié)果作為輸入,就像下面這樣:
[cpp]?view plaincopy
或者你也可以使用 -dump選項(xiàng)將指定logcat保存為文件作為輸入,就像下面這樣:
[cpp]?view plaincopy
最后,你就可以得到更多有效可讀的輸出信息:
[cpp]?view plaincopy
3.重要提示
NDK-STACK tool的logcat輸出需要有一個(gè)初始化行,比如像下面這樣:
[cpp]?view plaincopy
當(dāng)復(fù)制/粘帖追蹤信息時(shí),不要忘記把這個(gè)初始化行也給帶上,否則NDK-STACK tool將不會(huì)正常的工作。
目前對(duì)各平臺(tái)(linux/windows/mac)的NDK(可見 Android Developer ),NDK-STACK都是有效的。
4.參考文檔
$NDK_ROOT/docs/NDK-STACK.html
總結(jié)
以上是生活随笔為你收集整理的【玩转cocos2d-x之三十八】如何使用NDK-STACK tool来恢复Cocos2d-x安卓错误堆栈信息的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【玩转cocos2d-x之三十七】粒子系
- 下一篇: VS快捷键小技巧