这几天同事的一个库崩溃,基本要把他整崩溃了,试着帮他定位一下。
拿到日志
2019-05-14 11:51:53.638 28080-28080/? A/DEBUG: Build fingerprint: 'Android/rk3399_firefly_aio_lvds_mid/rk3399_firefly_aio_lvds_mid:8.1.0/OPM6.171019.030.B1/110155:userdebug/test-keys'
2019-05-14 11:51:53.638 28080-28080/? A/DEBUG: Revision: '0'
2019-05-14 11:51:53.638 28080-28080/? A/DEBUG: ABI: 'arm'
2019-05-14 11:51:53.638 28080-28080/? A/DEBUG: pid: 27554, tid: 27848, name: Thread-6 >>> <<<
2019-05-14 11:51:53.638 28080-28080/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xfffffffc
2019-05-14 11:51:53.638 28080-28080/? A/DEBUG: r0 fffffff4 r1 00000000 r2 fffffffc r3 ef62cae1
2019-05-14 11:51:53.638 28080-28080/? A/DEBUG: r4 c04df760 r5 c04df75c r6 c04df730 r7 c04df5c8
2019-05-14 11:51:53.638 28080-28080/? A/DEBUG: r8 c04e7398 r9 c04e3638 sl c04df738 fp c04df730
2019-05-14 11:51:53.638 28080-28080/? A/DEBUG: ip bec42cd4 sp c04df5b8 lr be2f7449 pc beadcce4 cpsr 80070030
E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_6
注意最后一行,崩溃日志的位置。
通过 adb 执行:
adb root
adb pull /data/tombstones/ ./
这个目录下的文件把拖下来;如果是windows一般在C:\Users\Administrator 这个目录下:
打开 tombstone_6
Build fingerprint: 'rockchip/rk3399_firefly_aio_lvds_box/rk3399_firefly_aio_lvds_box:7.1.2/NHG47K/liangk08091540:userdebug/test-keys'
Revision: '0'
ABI: 'arm'
pid: 18192, tid: 19090, name: Thread-6 >>> com.xxxxxxx <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x40080000
r0 00000000 r1 40080000 r2 c40c867c r3 c3c03580
r4 bf70e614 r5 bf70e618 r6 bf70e610 r7 bf70e5c8
r8 c43c1259 r9 c39020b2 sl 450147b7 fp c3e48305
ip 00000000 sp bf70a4c0 lr bcc8f8a5 pc bcc8faa0 cpsr 200e0030
d0 4082607140000000 d1 c39020b2c40c867c
d2 4097d5a644fb6438 d3 4082db99c351e161
d4 4097d5a6c393a1ad d5 3fe0aba344bead32
d6 c078b1c7c3c569f9 d7 4082d251c3c03580
d8 3e5236a04415a322 d9 3f055d1f43607d0f
d10 c3e483053f000000 d11 c338f291c2cfd268
d12 44788000c32745fe d13 43f2dc184388ec46
d14 426566c044c2c5c5 d15 c43c12593f541ab7
d16 bfeeb31f445aa523 d17 bfeeb31f445aa523
d18 3ff0000000000000 d19 3fa4f28315ad5a4e
d20 3feeb0d7cea52a5b d21 3c5a626331000000
d22 3f7b6ca377b310c3 d23 0000000400000004
d24 40001b8400000000 d25 3fd5558841f82cae
d26 3f7b552b00000000 d27 3fdb6df51da55c96
d28 000080c2000012a6 d29 0000c3e60000bafd
d30 bff0000009e56e13 d31 00000000042444fb
scr 80000013
backtrace:
#00 pc 007eaaa0 /data/app/com.xxxxxx/lib/arm/libXXXXX.so (_Z15irPackageCheck2RN5boost10shared_ptrIN3pcl10PointCloudINS1_8PointXYZEEEEERSt6vectorIdSaIdEERN2cv3MatESA_R7CCuboid+1695)
#01 pc 3ffffffd <unknown>
这里我们主要需要 #00 pc 007eaaa0 这是最后崩溃的地方:
在NDK 中找到 arm-linux-androideabi-addr2line.exe(注意这个是 32位的,如果你是64,请用64位的)
我的文件位置:E:\ndk\android-ndk-r17b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin
做一个批处理文件,把你的so 拷贝到这个文件,下面是批处理文件内容:
arm-linux-androideabi-addr2line.exe -C -f -e libxxxx.so 007eaaa0
pause
注意:libxxxx.so, 007eaaa0 替换成你的 so,和 pc address
执行可以得到崩溃的具体函数;
这个查了一下是 double 变量溢出了,唉不小心。
别人写的一个批处理文件不错 tool_addr2line.bat:
@echo off
rem current direction
set cur_dir=%cd%
rem addr2line tool path
set add2line_path=E:\ndk\android-ndk-r17b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-addr2line.exe
rem debug file
set /p debug_file=input debug filename:
rem debug_file_path
set debug_file_path=%cur_dir%\%debug_file%
rem debug address
set /p debug_addr=PC address:
echo ----------------------- addr2line ------------------------
echo debug file path: %debug_file_path% PC=%debug_addr%
if exist %debug_file_path% (
%add2line_path% -e %debug_file_path% -f %debug_addr%
) else (
echo debug file is no exist.
)
echo ---------------------------------------------------------
pause
一个更全的: