用ndk-stack分析应用native程序异常crash掉

这几天在做android下的音频播放器,使用ffmpeg做解码器,过程中出现一个问题,执行的时候出现下面这个问题:
03-24 15:05:37.094: I/DEBUG(3223): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-24 15:05:37.094: I/DEBUG(3223): Build fingerprint: 'MOTO/olympus/olympus:2.3.5/4.5.3-118_OLY-14/111106:user/release-keys'
03-24 15:05:37.094: I/DEBUG(3223): pid: 3214, tid: 3222  >>> com.lrc.tingjue <<<
03-24 15:05:37.094: I/DEBUG(3223): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000008
03-24 15:05:37.094: I/DEBUG(3223):  r0 afd464e4  r1 00000002  r2 00000002  r3 afd464b0
03-24 15:05:37.094: I/DEBUG(3223):  r4 00000000  r5 afd464b0  r6 000b2808  r7 00000004
03-24 15:05:37.094: I/DEBUG(3223):  r8 45738858  r9 4557ed78  10 002c1ea0  fp 00000000
03-24 15:05:37.094: I/DEBUG(3223):  ip afd464d4  sp 457387e0  lr afd11108  pc afd13fd4  cpsr 00000030
03-24 15:05:37.094: I/DEBUG(3223):  d0  000000f043700000  d1  3ff0000043700000
03-24 15:05:37.094: I/DEBUG(3223):  d2  4d8666d6424ca6a3  d3  00540ff04a2c08c0
03-24 15:05:37.094: I/DEBUG(3223):  d4  3fbc71c7002b0230  d5  3fe999999999999a
03-24 15:05:37.094: I/DEBUG(3223):  d6  3fe8000000000000  d7  3fc000003f4ccccd
03-24 15:05:37.094: I/DEBUG(3223):  d8  0000000000000000  d9  0000000000000000
03-24 15:05:37.094: I/DEBUG(3223):  d10 0000000000000000  d11 0000000000000000
03-24 15:05:37.094: I/DEBUG(3223):  d12 0000000000000000  d13 0000000000000000
03-24 15:05:37.094: I/DEBUG(3223):  d14 0000000000000000  d15 0000000000000000
03-24 15:05:37.094: I/DEBUG(3223):  scr 60000012
03-24 15:05:37.143: W/ActivityManager(1634): Activity pause timeout for HistoryRecord{4064de78 com.motorola.blur.home/.HomeActivity}
03-24 15:05:37.495: I/DEBUG(3223):          #00  pc 00013fd4  /system/lib/libc.so
03-24 15:05:37.495: I/DEBUG(3223):          #01  pc 0001478a  /system/lib/libc.so
03-24 15:05:37.495: I/DEBUG(3223):          #02  pc 00002a28  /data/data/com.lrc.tingjue/lib/libSuperPlayer.so
03-24 15:05:37.495: I/DEBUG(3223):          #03  pc 00001f08  /data/data/com.lrc.tingjue/lib/libSuperPlayer.so
03-24 15:05:37.495: I/DEBUG(3223):          #04  pc 00002824  /data/data/com.lrc.tingjue/lib/libSuperPlayer.so
03-24 15:05:37.495: I/DEBUG(3223):          #05  pc 00001180  /data/data/com.lrc.tingjue/lib/libtingjue.so
03-24 15:05:37.495: I/DEBUG(3223):          #06  pc 00011e74  /system/lib/libdvm.so
03-24 15:05:37.495: I/DEBUG(3223):          #07  pc 000435ec  /system/lib/libdvm.so
03-24 15:05:37.495: I/DEBUG(3223):          #08  pc 00017088  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #09  pc 0001c210  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #10  pc 0001b0f8  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #11  pc 00059dae  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #12  pc 00061a76  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #13  pc 00017088  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #14  pc 0001c210  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #15  pc 0001b0f8  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #16  pc 00059c0c  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #17  pc 00059e24  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #18  pc 0004e186  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):          #19  pc 00011b94  /system/lib/libc.so
03-24 15:05:37.503: I/DEBUG(3223):          #20  pc 0001173c  /system/lib/libc.so
03-24 15:05:37.503: I/DEBUG(3223): code around pc:
03-24 15:05:37.503: I/DEBUG(3223): afd13fb4 681f447b f102fa37 d01d0788 0101f001 
03-24 15:05:37.503: I/DEBUG(3223): afd13fc4 0c24f103 0001f081 eb0c1881 688400c1 
03-24 15:05:37.503: I/DEBUG(3223): afd13fd4 68d568a2 d17d42a5 d1064290 fa102001 
03-24 15:05:37.503: I/DEBUG(3223): afd13fe4 ea27f201 601f0702 691be004 d371429a 
03-24 15:05:37.503: I/DEBUG(3223): afd13ff4 60d06082 e0a500c9 42ac689d 808ef240 
03-24 15:05:37.503: I/DEBUG(3223): code around lr:
03-24 15:05:37.503: I/DEBUG(3223): afd110e8 e2166903 1a000018 e5945000 e1a02004 
03-24 15:05:37.503: I/DEBUG(3223): afd110f8 e2055a02 e1a00005 e3851001 ebffed92 
03-24 15:05:37.503: I/DEBUG(3223): afd11108 e3500000 13856002 1a000001 ea000009 
03-24 15:05:37.503: I/DEBUG(3223): afd11118 ebfffe50 e1a01004 e1a00006 ebffed92 
03-24 15:05:37.503: I/DEBUG(3223): afd11128 e1a01005 e1550000 e1a02006 e3a03000 
03-24 15:05:37.503: I/DEBUG(3223): stack:
03-24 15:05:37.503: I/DEBUG(3223):     457387a0  45638f01  
03-24 15:05:37.503: I/DEBUG(3223):     457387a4  002c1f80  
03-24 15:05:37.503: I/DEBUG(3223):     457387a8  fffffe8c  
03-24 15:05:37.503: I/DEBUG(3223):     457387ac  405442a8  
03-24 15:05:37.503: I/DEBUG(3223):     457387b0  00000018  
03-24 15:05:37.503: I/DEBUG(3223):     457387b4  aca4ef45  /system/lib/libdvm.so
03-24 15:05:37.503: I/DEBUG(3223):     457387b8  405442a8  
03-24 15:05:37.503: I/DEBUG(3223):     457387bc  00000000  
03-24 15:05:37.503: I/DEBUG(3223):     457387c0  00000004  
03-24 15:05:37.503: I/DEBUG(3223):     457387c4  afd464b0  
03-24 15:05:37.503: I/DEBUG(3223):     457387c8  000b2808  
03-24 15:05:37.503: I/DEBUG(3223):     457387cc  000b2808  
03-24 15:05:37.503: I/DEBUG(3223):     457387d0  45738858  
03-24 15:05:37.503: I/DEBUG(3223):     457387d4  4557ed78  
03-24 15:05:37.503: I/DEBUG(3223):     457387d8  df002777  
03-24 15:05:37.503: I/DEBUG(3223):     457387dc  e3a070ad  
03-24 15:05:37.503: I/DEBUG(3223): #00 457387e0  81304190  /data/data/com.lrc.tingjue/lib/libSuperPlayer.so
03-24 15:05:37.503: I/DEBUG(3223):     457387e4  000b2820  
03-24 15:05:37.503: I/DEBUG(3223):     457387e8  000b2808  
03-24 15:05:37.503: I/DEBUG(3223):     457387ec  000b2808  
03-24 15:05:37.503: I/DEBUG(3223):     457387f0  45738858  
03-24 15:05:37.503: I/DEBUG(3223):     457387f4  afd1478d  /system/lib/libc.so
03-24 15:05:37.503: I/DEBUG(3223): #01 457387f8  81304190  /data/data/com.lrc.tingjue/lib/libSuperPlayer.so
03-24 15:05:37.503: I/DEBUG(3223):     457387fc  81302a2c  /data/data/com.lrc.tingjue/lib/libSuperPlayer.so
03-24 15:05:37.773: I/System.out(2725): Receive:android.intent.action.PACKAGE_ADDED
03-24 15:05:37.773: I/System.out(2725): DataString:package:com.lrc.tingjue
03-24 15:05:38.136: I/WindowManager(1634): adjustConfigurationLw fontScale=1.0


都是一些寄存器以及函数地址,真不知道怎么找具体哪个函数出错了,后来网上看到ndk-stack这个工具,很快就定位到错误了

ndk-stack需要log作为输入来分析

adb logcat | $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi
也可以把log直接拿出来,再用ndk-stack分析
adb logcat > /tmp/foo.txt
$NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi -dump foo.txt

你可能感兴趣的:(native)