Let's say that logcat show you the following crash log (this is from one of my projects ):
Log Code
- I/debug (31 ): **************************************** ********
- I/debug (31): Build fingerprint: 'generic/SDK/generic: 2.3/grh55/79397: Eng/test-keys'
- I/debug (31): PID: 378, TID: 386 >>>com. example. gltest <
- I/debug (31): Signal 11 (SIGSEGV), Code 1 (segv_maperr), fault ADDR 00000000
- I/debug (31): R0 001dbdc0 R1 00000001 R2 00000000 R3 00000000
- I/debug (31): R4 00000000 R5 40a40000 R6 4051a424r7 42ddbee8
- I/debug (31): R8 43661b24 R9 42ddbed0 10 42 ddbebc FP 41e462d8
- I/debug (31): IP 00000001 SP 437919d0 LR 83a12f5d PC 8383deb4 CPSR 20000010
- I/debug (31): #00 PC 0003deb4/data/COM. example. gltest/lib/libnativemaprender. So
- I/debug (31): #01 PC 00039b76/data/COM. example. gltest/lib/libnativemaprender. So
- I/debug (31): #02 PC 00017d34/system/lib/libdvm. So
I/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***I/DEBUG ( 31): Build fingerprint: 'generic/sdk/generic:2.3/GRH55/79397:eng/test-keys'I/DEBUG ( 31): pid: 378, tid: 386 >>> com.example.gltest <<<I/DEBUG ( 31): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000I/DEBUG ( 31): r0 001dbdc0 r1 00000001 r2 00000000 r3 00000000I/DEBUG ( 31): r4 00000000 r5 40a40000 r6 4051a480 r7 42ddbee8I/DEBUG ( 31): r8 43661b24 r9 42ddbed0 10 42ddbebc fp 41e462d8I/DEBUG ( 31): ip 00000001 sp 436619d0 lr 83a12f5d pc 8383deb4 cpsr 20000010I/DEBUG ( 31): #00 pc 0003deb4 /data/data/com.example.gltest/lib/libnativemaprender.soI/DEBUG ( 31): #01 pc 00039b76 /data/data/com.example.gltest/lib/libnativemaprender.soI/DEBUG ( 31): #02 pc 00017d34 /system/lib/libdvm.so
Look at the last 3 lines; this is your callstack. 'pc' is the program counter, and the PC for stack frame #00 gives you the address where the crash occurred. this is the number to pass to addr2line.
I'm using ndk R5, so the executable I'm using is located$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
; Make sure that is in your
$PATH
. The command to use looks like
CMD code
- Arm-linux-androideabi-addr2line-C-f-e OBJ/local/armeabi/libxxx. So <address>
arm-linux-androideabi-addr2line -C -f -e obj/local/armeabi/libXXX.so <address>
Or, for the case above:
CMD code
- Arm-linux-androideabi-addr2line-C-f-e OBJ/local/armeabi/libnativemaprender. So 0003deb4
arm-linux-androideabi-addr2line -C -f -e obj/local/armeabi/libnativemaprender.so 0003deb4
Which gives you the location of the crash.
Note:
- The-C flag is to demangle C ++ code
- Use the. So file under OBJ/local/armeabi, since this is the non-stripped version
Also, when using ndk R5 with a 2.3 AVD, it is actually possible to debug multithreaded code.
Refer:
Http://stackoverflow.com/questions/5314036/how-to-use-addr2line-in-android
Http://www.codexperiments.com/android/2010/08/tips-tricks-debugging-android-ndk-stack-traces/