I was stuck with my app, as i am unable to debug as it is a multithreaded one and crashes with error SIGSEGV. I get lot of information on logcat, which gives me addresses in my native library. It'll helpfull if i can convert these addresses into my code.

Does anybody have any idea, how to use addr2line, which is provided with android-ndk?

Let's say that logcat show you the following crash log (this is from one of my projects):

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): signal11(SIGSEGV), code1(SEGV_MAPERR), fault addr00000000
I
/DEBUG ( 31): r0001dbdc0 r100000001 r200000000 r300000000
I
/DEBUG ( 31): r400000000 r540a40000 r64051a480 r742ddbee8
I
/DEBUG ( 31): r843661b24 r942ddbed0 1042ddbebc fp41e462d8
I
/DEBUG ( 31): ip00000001 sp436619d0 lr83a12f5d pc8383deb4 cpsr20000010
I
/DEBUG ( 31): #00 pc 0003deb4 /data/data/com.example.gltest/lib/libnativemaprender.so
I
/DEBUG ( 31): #01 pc 00039b76 /data/data/com.example.gltest/lib/libnativemaprender.so
I
/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 at $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

arm-linux-androideabi-addr2line -C -f -e obj/local/armeabi/libXXX.so <address> 

Or, for the case above:

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.



原文地址:http://stackoverflow.com/questions/5314036/how-to-use-addr2line-in-android

更多相关文章

  1. Android:官网ROM下载地址备份
  2. android 资料地址
  3. Android 5.1 API 22 所有sdk文件下载地址
  4. Android SDK ADT下载地址
  5. Android SDK/ADT 历史版本下载地址
  6. Android SDK大连东软镜像地址及地址列表
  7. android sdk 离线下载地址及对应映射关系
  8. Android 修改 以太网 IP地址
  9. 关于asp.net如何获取浏览器访问的IP地址?

随机推荐

  1. Windows php5.6安装Imagick库的方法详解
  2. 用PHP写一个计算器(附完整代码)
  3. php获取农历、节日、节气的方法(代码实例)
  4. PHP通过设置系统环境变量来区分测试与正
  5. php实现向mysql批量插入数据
  6. PHP是如何做垃圾回收的(图文)
  7. php如何构造随机ip访问
  8. 使用socket系列函数实现连接TCP服务
  9. php中mkdir的使用方法介绍
  10. 关于php多进程编程(代码详解)