Android系统异常Native堆栈分析工具addr2line

我们在开发Android产品或设备时或多或少遇到系统的Native本地异常,导致系统不能正常启动,如下信息:

错误的堆栈信息:

Build fingerprint: 'Coolpad/Y803-8/Y803-8:5.1/LMY47D/5.1.033.P2.160602.Y803_8-LC:user/release-keys' 
Revision: '0' 
ABI: 'arm64' 
pid: 10476, tid: 10476, name: surfaceflinger  >>> /system/bin/surfaceflinger <<< 
signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0x3e8000028ec 
Abort message: 'eglSwapBuffers(0x1, 0x7f956a0040) failed with 0x00003003' 
ALOGE("eglSwapBuffers(%p, %p) failed with 0x%08x", mDisplay, mSurface, error); 


backtrace: 
    #00 pc 000000000000d5a4  /system/lib64/libcutils.so (__android_log_assert+236) 
    #01 pc 000000000001e98c  /system/lib64/libsurfaceflinger.so 
    #02 pc 0000000000030304  /system/lib64/libsurfaceflinger.so 
    #03 pc 000000000002eb14  /system/lib64/libsurfaceflinger.so 
    #04 pc 000000000002d12c  /system/lib64/libsurfaceflinger.so 
    #05 pc 000000000002cde8  /system/lib64/libsurfaceflinger.so 
    #06 pc 000000000001b600  /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+300) 
    #07 pc 000000000001b91c  /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+76) 
    #08 pc 00000000000291c0  /system/lib64/libsurfaceflinger.so 
    #09 pc 000000000002c868  /system/lib64/libsurfaceflinger.so (_ZN7android14SurfaceFlinger3runEv+20) 
    #10 pc 0000000000000f5c  /system/bin/surfaceflinger 
    #11 pc 00000000000196cc  /system/lib64/libc.so (__libc_init+96) 
    #12 pc 0000000000001048  /system/bin/surfaceflinger

这个时候可以使用MTK平台提供的工具GAT工具包中的aarch64-linux-android-addr2line(64位系统)或arm-linux-androideabi-addr2line(32位系统)来分析,具体工具可以从我百度网盘下载(https://pan.baidu.com/s/1Zg8kAmRfJK_sirjmqc_j7Q  密码:zx0n),具体使用方法如下:

命令:

linux环境: 
aarch64-linux-android-addr2line  –f –C –e libAddress address 

windows环境:

aarch64-linux-android-addr2line.exe –f –C –e libAddress address 

例如(以下是linux环境中):

命令格式: 
linux环境: 
aarch64-linux-android-addr2line  –f –C –e libAddress address
windows环境:
aarch64-linux-android-addr2line.exe –f –C –e libAddress address 

//命令:
zhaojr@zhaojr-OptiPlex-7040:~$ /home/zhaojr/project/soft/gat-linux-x86_64-3/prebuilt/android-sdk/bin/aarch64-linux-android-addr2line -f -C -e
/home/zhaojr/project/test_8227l/8227LGO_20190111/out/target/product/8227LGO_demo\symbols\system\lib64\libsurfaceflinger.so 000000000001e98c 
//输出结果:
android::DisplayDevice::swapBuffers(android::HWComposer&) const  /home/system4/MTK_5.1/CPY803_8_Volte_5.1_Int/mydroid/frameworks/native/services/surfaceflinger/DisplayDevice.cpp:285

//命令:
zhaojr@zhaojr-OptiPlex-7040:~$  /home/zhaojr/project/soft/gat-linux-x86_64-3/prebuilt/android-sdk/bin/aarch64-linux-android-addr2line -f -C -e
/home/zhaojr/project/test_8227l/8227LGO_20190111/out/target/product/8227LGO_demo/symbols/system/lib64/libcutils.so 000000000000d5a4 
//输出结果:
__android_log_assert/home/system4/MTK_5.1/MTK_5.1_Volte_Dev/mydroid/system/core/liblog/logd_write_kern.c:438

这样我们就可以知道出现问题的函数入口点,跟踪代码很容易就定位到问题的原因。

你可能感兴趣的:(Android,系统开发)