赞
踩
直接来一个例子:(此为android模拟器启动过程中出现的错误,偶现,需要分析堆栈信息查看具体原因):
###################日志开始###################
.....
03-20 14:06:20.140 D/dalvikvm(18790): GC_EXPLICIT freed 17K, 2% free 1609K/1632K, paused 1ms+0ms, total 2ms
03-20 14:06:20.140 F/libc (18790): Fatal signal 4 (SIGILL) at 0xb5e62e19 (code=2), thread 18790 (zygote)
03-20 14:06:20.248 I/DEBUG ( 104): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-20 14:06:20.248 I/DEBUG ( 104): Build fingerprint: 'TTAndroid/ttVM_Hdragon/ttVM_Hdragon:4.3/tt/eng.ttvm.20150309.140302:userdebug/test-keys'
03-20 14:06:20.248 I/DEBUG ( 104): Revision: '0'
03-20 14:06:20.248 I/DEBUG ( 104): pid: 18790, tid: 18790, name: zygote >>> zygote <<<
03-20 14:06:20.248 I/DEBUG ( 104): signal 4 (SIGILL), code 2 (ILL_ILLOPN), fault addr b5e62e19
03-20 14:06:20.460 I/DEBUG ( 104): eax 000306c3 ebx 00000210 ecx 00000000 edx ffebfbff
03-20 14:06:20.460 I/DEBUG ( 104): esi ffebfbff edi 00000001
03-20 14:06:20.460 I/DEBUG ( 104): xcs 00000073 xds 0000007b xes 0000007b xfs 00000000 xss 0000007b
03-20 14:06:20.460 I/DEBUG ( 104): eip b5e62e19 ebp 7ffaf3bf esp bfa4043c flags 00210246
03-20 14:06:20.460 I/DEBUG ( 104):
03-20 14:06:20.460 I/DEBUG ( 104): backtrace:
03-20 14:06:20.460 I/DEBUG ( 104): #00 pc 00040e19 /system/lib/libcrypto.so (OPENSSL_ia32_cpuid+329)
03-20 14:06:20.460 I/DEBUG ( 104):
03-20 14:06:20.460 I/DEBUG ( 104): stack:
03-20 14:06:20.460 I/DEBUG ( 104): bfa403fc 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40400 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40404 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40408 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa4040c 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40410 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40414 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40418 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa4041c 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40420 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40424 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40428 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa4042c 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40430 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40434 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40438 00000000
03-20 14:06:20.460 I/DEBUG ( 104): #00 bfa4043c bfa404bc [stack]
03-20 14:06:20.460 I/DEBUG ( 104): bfa40440 9ecccddc
03-20 14:06:20.460 I/DEBUG ( 104): bfa40444 b5fd1e68 /system/lib/libcrypto.so
03-20 14:06:20.460 I/DEBUG ( 104): bfa40448 bfa404d8 [stack]
03-20 14:06:20.460 I/DEBUG ( 104): bfa4044c b5eb92dd /system/lib/libcrypto.so (OPENSSL_cpuid_setup+237)
03-20 14:06:20.460 I/DEBUG ( 104): bfa40450 b5f74d07 /system/lib/libcrypto.so
03-20 14:06:20.460 I/DEBUG ( 104): bfa40454 00000010
03-20 14:06:20.460 I/DEBUG ( 104): bfa40458 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa4045c 00000000
03-20 14:06:20.460 I/DEBUG ( 104): bfa40460 b5df30e7 /system/lib/libssl.so (ssl_load_ciphers+7)
03-20 14:06:20.460 I/DEBUG ( 104): bfa40464 b5e1da4c /system/lib/libssl.so
03-20 14:06:20.460 I/DEBUG ( 104): bfa40468 b5e0db03 /system/lib/libssl.so
03-20 14:06:20.460 I/DEBUG ( 104): bfa4046c b5dee83d /system/lib/libssl.so (SSL_library_init+493)
03-20 14:06:20.460 I/DEBUG ( 104): bfa40470 b5fd1e68 /system/lib/libcrypto.so
03-20 14:06:20.460 I/DEBUG ( 104): bfa40474 9ecccddc
03-20 14:06:20.460 I/DEBUG ( 104): bfa40478 bfa404bc [stack]
03-20 14:06:20.460 I/DEBUG ( 104):
03-20 14:06:20.460 I/DEBUG ( 104): memory map around fault addr b5e62e19:
03-20 14:06:20.460 I/DEBUG ( 104): b5e21000-b5e22000 r--
03-20 14:06:20.460 I/DEBUG ( 104): b5e22000-b5fc4000 r-x /system/lib/libcrypto.so
03-20 14:06:20.460 I/DEBUG ( 104): b5fc4000-b5fc5000 ---
03-20 14:06:20.532 I/ServiceManager( 98): service 'media.audio_flinger' died
03-20 14:06:20.532 I/ServiceManager( 98): service 'media.player' died
03-20 14:06:20.532 I/ServiceManager( 98): service 'media.camera' died
03-20 14:06:20.556 I/Netd (18795): Netd 1.0 starting
03-20 14:06:20.556 W/InterfaceController(18795): Warning (dlopen failed: library "/system/lib/libnetcmdiface.so" not found) while opening the net interface command library
03-20 14:06:20.644 I/mediaserver(18794): ServiceManager: 0xb94af450
03-20 14:06:20.644 I/AudioFlinger(18794): Using default 3000 mSec as standby time.
03-20 14:06:20.648 I/CameraService(18794): CameraService started (pid=18794)
03-20 14:06:20.744 V/EmulatedCamera_GenyCamera(18794): Initialize:
.......
######################################
分析:
backtrace:
03-20 14:06:20.460 I/DEBUG ( 104): #00 pc 00040e19 /system/lib/libcrypto.so (OPENSSL_ia32_cpuid+329)
从上述堆栈来看,出错的地方如上,出错类型为SIGILL,说明为非法指令错误,但是单从错误类型和出错地址00040e19来看,我们是看不出到底那条指令出错了,所以此时需要工具把这个出错的libcrypto.so库的信息导出来.
工具为: i686-linux-android-objdump,
路径如下:(android源码目录)/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7
导出错误信息:在shell下执行命令:
cd (android源码目录)/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7
i686-linux-android-objdum -d libcrypto.so >libcrypt_err.log
然后就可以查看日志了,具体是:
1>找到出错的函数OPENSSL_ia32_cpuid,然后加上149(329的16进制)=00040e19
如下
00040cd0 <OPENSSL_ia32_cpuid>:
40cd0: 55 push %ebp
40cd1: 53 push %ebx
40cd2: 56 push %esi
40cd3: 57 push %edi
40cd4: 31 d2 xor %edx,%edx
40cd6: 9c pushf
40cd7: 58 pop %eax
40cd8: 89 c1 mov %eax,%ecx
40cda: 35 00 00 20 00 xor $0x200000,%eax
40cdf: 50 push %eax
40ce0: 9d popf
40ce1: 9c pushf
40ce2: 58 pop %eax
40ce3: 31 c1 xor %eax,%ecx
40ce5: 31 c0 xor %eax,%eax
40ce7: 0f ba e1 15 bt $0x15,%ecx
40ceb: 0f 83 4e 01 00 00 jae 40e3f <OPENSSL_ia32_cpuid+0x16f>
40cf1: 0f a2 cpuid
40cf3: 89 c7 mov %eax,%edi
40cf5: 31 c0 xor %eax,%eax
40cf7: 81 fb 47 65 6e 75 cmp $0x756e6547,%ebx
40cfd: 0f 95 c0 setne %al
40d00: 89 c5 mov %eax,%ebp
40d02: 81 fa 69 6e 65 49 cmp $0x49656e69,%edx
40d08: 0f 95 c0 setne %al
40d0b: 09 c5 or %eax,%ebp
40d0d: 81 f9 6e 74 65 6c cmp $0x6c65746e,%ecx
40d13: 0f 95 c0 setne %al
40d16: 09 c5 or %eax,%ebp
40d18: 74 7b je 40d95 <OPENSSL_ia32_cpuid+0xc5>
40d1a: 81 fb 41 75 74 68 cmp $0x68747541,%ebx
40d20: 0f 95 c0 setne %al
40d23: 89 c6 mov %eax,%esi
40d25: 81 fa 65 6e 74 69 cmp $0x69746e65,%edx
40d2b: 0f 95 c0 setne %al
40d2e: 09 c6 or %eax,%esi
40d30: 81 f9 63 41 4d 44 cmp $0x444d4163,%ecx
40d36: 0f 95 c0 setne %al
40d39: 09 c6 or %eax,%esi
40d3b: 75 58 jne 40d95 <OPENSSL_ia32_cpuid+0xc5>
40d3d: b8 00 00 00 80 mov $0x80000000,%eax
40d42: 0f a2 cpuid
40d44: 3d 01 00 00 80 cmp $0x80000001,%eax
40d49: 72 4a jb 40d95 <OPENSSL_ia32_cpuid+0xc5>
40d4b: 89 c6 mov %eax,%esi
40d4d: b8 01 00 00 80 mov $0x80000001,%eax
40d52: 0f a2 cpuid
40d54: 09 cd or %ecx,%ebp
40d56: 81 e5 01 08 00 00 and $0x801,%ebp
40d5c: 81 fe 08 00 00 80 cmp $0x80000008,%esi
40d62: 72 31 jb 40d95 <OPENSSL_ia32_cpuid+0xc5>
40d64: b8 08 00 00 80 mov $0x80000008,%eax
40d69: 0f a2 cpuid
40d6b: 0f b6 f1 movzbl %cl,%esi
40d6e: 46 inc %esi
40d6f: b8 01 00 00 00 mov $0x1,%eax
40d74: 0f a2 cpuid
40d76: 0f ba e2 1c bt $0x1c,%edx
40d7a: 0f 83 81 00 00 00 jae 40e01 <OPENSSL_ia32_cpuid+0x131>
40d80: c1 eb 10 shr $0x10,%ebx
40d83: 81 e3 ff 00 00 00 and $0xff,%ebx
40d89: 39 f3 cmp %esi,%ebx
40d8b: 77 74 ja 40e01 <OPENSSL_ia32_cpuid+0x131>
40d8d: 81 e2 ff ff ff ef and $0xefffffff,%edx
40d93: eb 6c jmp 40e01 <OPENSSL_ia32_cpuid+0x131>
40d95: 83 ff 04 cmp $0x4,%edi
40d98: bf ff ff ff ff mov $0xffffffff,%edi
40d9d: 72 17 jb 40db6 <OPENSSL_ia32_cpuid+0xe6>
40d9f: b8 04 00 00 00 mov $0x4,%eax
40da4: b9 00 00 00 00 mov $0x0,%ecx
40da9: 0f a2 cpuid
40dab: 89 c7 mov %eax,%edi
40dad: c1 ef 0e shr $0xe,%edi
40db0: 81 e7 ff 0f 00 00 and $0xfff,%edi
40db6: b8 01 00 00 00 mov $0x1,%eax
40dbb: 0f a2 cpuid
40dbd: 81 e2 ff ff ef bf and $0xbfefffff,%edx
40dc3: 83 fd 00 cmp $0x0,%ebp
40dc6: 75 14 jne 40ddc <OPENSSL_ia32_cpuid+0x10c>
40dc8: 81 ca 00 00 00 40 or $0x40000000,%edx
40dce: 80 e4 0f and $0xf,%ah
40dd1: 80 fc 0f cmp $0xf,%ah
40dd4: 75 06 jne 40ddc <OPENSSL_ia32_cpuid+0x10c>
40dd6: 81 ca 00 00 10 00 or $0x100000,%edx
40ddc: 0f ba e2 1c bt $0x1c,%edx
40de0: 73 1f jae 40e01 <OPENSSL_ia32_cpuid+0x131>
40de2: 81 e2 ff ff ff ef and $0xefffffff,%edx
40de8: 83 ff 00 cmp $0x0,%edi
40deb: 74 14 je 40e01 <OPENSSL_ia32_cpuid+0x131>
40ded: 81 ca 00 00 00 10 or $0x10000000,%edx
40df3: c1 eb 10 shr $0x10,%ebx
40df6: 80 fb 01 cmp $0x1,%bl
40df9: 77 06 ja 40e01 <OPENSSL_ia32_cpuid+0x131>
40dfb: 81 e2 ff ff ff ef and $0xefffffff,%edx
40e01: 81 e5 00 08 00 00 and $0x800,%ebp
40e07: 81 e1 ff f7 ff ff and $0xfffff7ff,%ecx
40e0d: 89 d6 mov %edx,%esi
40e0f: 09 cd or %ecx,%ebp
40e11: 0f ba e1 1b bt $0x1b,%ecx
40e15: 73 1e jae 40e35 <OPENSSL_ia32_cpuid+0x165>
40e17: 31 c9 xor %ecx,%ecx
40e19: 0f 01 d0 xgetbv
40e1c: 83 e0 06 and $0x6,%eax
40e1f: 83 f8 06 cmp $0x6,%eax
.....
这样为xgetbv这条指令出错,此时就需要查看源码和分析具体的原因了,这里只是讲到定位分析到点的方法.
i686-linux-android-objdump工具的用法请直接执行查看
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。