Added information about decoding native stack traces
authorSam Lantinga <slouken@libsdl.org>
Wed, 12 Jan 2011 12:31:51 -0800
changeset 4973067b6ec8b751
parent 4972 0a9a77f3d552
child 4974 1cd0a891b69a
Added information about decoding native stack traces
README.android
     1.1 --- a/README.android	Wed Jan 12 11:55:02 2011 -0800
     1.2 +++ b/README.android	Wed Jan 12 12:31:51 2011 -0800
     1.3 @@ -123,6 +123,35 @@
     1.4  You can push files to the SD Card at /sdcard, for example:
     1.5  	adb push moose.dat /sdcard/moose.dat
     1.6  
     1.7 +You can see the complete command line that ndk-build is using by passing V=1 on the command line:
     1.8 +	ndk-build V=1
     1.9 +
    1.10 +If your application crashes in native code, you can use addr2line to convert the addresses in the stack trace to lines in your code.
    1.11 +
    1.12 +For example, if your crash looks like this:
    1.13 +I/DEBUG   (   31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
    1.14 +I/DEBUG   (   31):  r0 00000000  r1 00001000  r2 00000003  r3 400085d4
    1.15 +I/DEBUG   (   31):  r4 400085d0  r5 40008000  r6 afd41504  r7 436c6a7c
    1.16 +I/DEBUG   (   31):  r8 436c6b30  r9 435c6fb0  10 435c6f9c  fp 4168d82c
    1.17 +I/DEBUG   (   31):  ip 8346aff0  sp 436c6a60  lr afd1c8ff  pc afd1c902  cpsr 60000030
    1.18 +I/DEBUG   (   31):          #00  pc 0001c902  /system/lib/libc.so
    1.19 +I/DEBUG   (   31):          #01  pc 0001ccf6  /system/lib/libc.so
    1.20 +I/DEBUG   (   31):          #02  pc 000014bc  /data/data/org.libsdl.app/lib/libmain.so
    1.21 +I/DEBUG   (   31):          #03  pc 00001506  /data/data/org.libsdl.app/lib/libmain.so
    1.22 +
    1.23 +You can see that there's a crash in the C library being called from the main code.  I run addr2line with the debug version of my code:
    1.24 +	arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
    1.25 +and then paste in the number after "pc" in the call stack, from the line that I care about:
    1.26 +000014bc
    1.27 +
    1.28 +I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23.
    1.29 +
    1.30 +You can add logging to your code to help show what's happening:
    1.31 +
    1.32 +#include <android/log.h>
    1.33 +
    1.34 +	__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
    1.35 +
    1.36  
    1.37  ================================================================================
    1.38   Known issues