Using NDK-STACK to Debug Cocos2dx Android Project

'ndk-stack' is a simple tool that allows you to analyze stack traces as they appear in the output of 'adb logcat' and replace any address inside a shared library with the corresponding:values.

In the output of 'adb logcat', you may see something like the followings, and we must translate those:

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):

How to use this tool


If you succeed in building Cocos2d-x android project, it will generate shared libraries in $PROJECT_PATH/obj/local/abi, where 'abi' stands for your device's ABI (i.e.'armeabi' by default);

You can feed the logcat text either as direct input to the program, e.g.:

adb logcat | $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi

Or you can use the -dump option to specify the logcat as an input file, e.g.:

adb logcat > /tmp/foo.txt
$NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi -dump foo.txt

After that, you will get 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

IMPORTANT


The tool looks for the initial line containing starts in the logcat output, i.e.something this looks like:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

When copy/pasting traces, don't forget this line from the traces, or ndk-stack won't work correctly.

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

References


$NDK_ROOT/docs/NDK-STACK.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌呆躲,老刑警劉巖页徐,帶你破解...
    沈念sama閱讀 221,273評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件墅垮,死亡現(xiàn)場離奇詭異筏餐,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)廓鞠,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,349評論 3 398
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來谣旁,“玉大人床佳,你說我怎么就攤上這事¢螅” “怎么了砌们?”我有些...
    開封第一講書人閱讀 167,709評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長搁进。 經(jīng)常有香客問我浪感,道長,這世上最難降的妖魔是什么饼问? 我笑而不...
    開封第一講書人閱讀 59,520評論 1 296
  • 正文 為了忘掉前任影兽,我火速辦了婚禮,結(jié)果婚禮上莱革,老公的妹妹穿的比我還像新娘峻堰。我一直安慰自己,他們只是感情好盅视,可當(dāng)我...
    茶點故事閱讀 68,515評論 6 397
  • 文/花漫 我一把揭開白布捐名。 她就那樣靜靜地躺著,像睡著了一般闹击。 火紅的嫁衣襯著肌膚如雪桐筏。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,158評論 1 308
  • 那天拇砰,我揣著相機(jī)與錄音梅忌,去河邊找鬼。 笑死除破,一個胖子當(dāng)著我的面吹牛牧氮,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播瑰枫,決...
    沈念sama閱讀 40,755評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼踱葛,長吁一口氣:“原來是場噩夢啊……” “哼丹莲!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起尸诽,我...
    開封第一講書人閱讀 39,660評論 0 276
  • 序言:老撾萬榮一對情侶失蹤甥材,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后性含,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體洲赵,經(jīng)...
    沈念sama閱讀 46,203評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,287評論 3 340
  • 正文 我和宋清朗相戀三年商蕴,在試婚紗的時候發(fā)現(xiàn)自己被綠了叠萍。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,427評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡绪商,死狀恐怖苛谷,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情格郁,我是刑警寧澤腹殿,帶...
    沈念sama閱讀 36,122評論 5 349
  • 正文 年R本政府宣布,位于F島的核電站例书,受9級特大地震影響赫蛇,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜雾叭,卻給世界環(huán)境...
    茶點故事閱讀 41,801評論 3 333
  • 文/蒙蒙 一悟耘、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧织狐,春花似錦暂幼、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,272評論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至厨埋,卻和暖如春邪媳,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背荡陷。 一陣腳步聲響...
    開封第一講書人閱讀 33,393評論 1 272
  • 我被黑心中介騙來泰國打工雨效, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人废赞。 一個月前我還...
    沈念sama閱讀 48,808評論 3 376
  • 正文 我出身青樓徽龟,卻偏偏與公主長得像,于是被迫代替她去往敵國和親唉地。 傳聞我的和親對象是個殘疾皇子据悔,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,440評論 2 359

推薦閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,556評論 0 23
  • 是什么讓我義無反顧的闖 是什么遮蓋了你目送的光 是什么讓我百感交集的傷 是我自負(fù)的以為如你所想 是我離開的腳步太過...
    巴東牧心閱讀 251評論 0 1
  • 薄唇輕抿玲瓏传透,畫中覺、碧玉簪上銀鉤映腮紅极颓。 一場酥蔥指朱盐、點滴的琴怨,一縷輕飄的惆悵菠隆,月伴黃昏兵琳。 新蝶乘風(fēng),折柳的襟...
    輕淺vv時光閱讀 422評論 0 0