[디버깅] ndk stack 사용법

|

I made a bit of a progress and I want to share what I did.

When you get errors like this on the LogCat, they are saved on $PROJECT_PATH/obj/local/armeabi where $PROJECT_PATH is the path to your cocos2d-x android project. To symbolicate the messages to something understandable, you can use the ndk-stack tool.

Open up the Terminal (or Cygwin, not sure though) and type in

cd $ANDROID_NDK
adb logcat | ./ndk-stack -sym $PROJECT_PATH/obj/local/armeabi 

where:
$ANDROID_NDK is the path to your android NDK
PROJECT_PATH is the path to your cocos2d-x android project

After that, you will get a stack trace which points to certain files and line number where the crash occurred. Something like this:

********** Crash dump: **********
Build fingerprint: 'generic/blaze/blaze:2.3.4/GINGERBREAD/6.3.1_user_4107920:user/release-keys'
pid: 16346, tid: 16354  >>> com.mycompany.myapp <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
Stack frame #00  pc 002a13f0  /data/data/com.mycompany.myapp/lib/libmyapp.so: Unable to locate routine information for address 2a13f0 in module
Stack frame #01  pc 0012e81e  /data/data/com.mycompany.myapp/lib/libmyapp.so: Routine updateNode in jni/../../Classes/TowerObj.cpp:150
Stack frame #02  pc 000f3648  /data/data/com.mycompany.myapp/lib/libmyapp.so: Routine updateLayer in jni/../../Classes/BuilderLayer.cpp:107
Stack frame #03  pc 0010bb94  /data/data/com.mycompany.myapp/lib/libmyapp.so: Routine updateGame in jni/../../Classes/MainGameLayer.cpp:172

( more here pointing to cocos2d-x classes )

From the dump above, you can see that on Stack frame #01 points to TowerObj.cpp:150, so I can now go to TowerObj.cpp at line 150 and fix stuff.

Hope this helps.


Trackback 0 And Comment 0