Android调用堆栈跟踪实例分析
程序员文章站
2024-03-31 09:01:28
本文实例讲述了android调用堆栈跟踪的方法。分享给大家供大家参考。具体如下:
android开发中,我们也会经常遇到段错误,也就是sigsegv(11),这个时候li...
本文实例讲述了android调用堆栈跟踪的方法。分享给大家供大家参考。具体如下:
android开发中,我们也会经常遇到段错误,也就是sigsegv(11),这个时候libc的backtrace会打印出对应的堆栈信 息,而你看到的仅仅是一对数字,好像无从查起。
如下面这一从串断错误:
activitymanager( 1105): displayed activity com.android.browser/.browseractivity: 2460 ms (total 2460 ms) i/debug (13002): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** i/debug (13002): build fingerprint: 'unknown' i/debug (13002): pid: 20363, tid: 20375 >>> com.android.browser <<< i/debug (13002): signal 11 (sigsegv), fault addr ffc00000 i/debug (13002): r0 059fc2a0 r1 4a3bcef8 r2 e59fc2a0 r3 4a3bcc58 i/debug (13002): r4 4a3bc101 r5 4ebe0a3c r6 4a3bc120 r7 012fff10 i/debug (13002): r8 500de101 r9 500ee12d 10 a87dfb20 fp 4ebe58e0 i/debug (13002): ip ffc00000 sp 4ebe0a30 lr 4a3bcc58 pc a862f3a0 cpsr 00000030 i/debug (13002): d0 0000001100000011 d1 0000001100000011 i/debug (13002): d2 0000001100000011 d3 0000001100000011 i/debug (13002): d4 0000001100000011 d5 0000001100000011 i/debug (13002): d6 0000001100000011 d7 4060000000000080 i/debug (13002): d8 41d3d1762e40d70a d9 41d3d1762e440a3d i/debug (13002): d10 0000000000000000 d11 0000000000000000 i/debug (13002): d12 0000000000000000 d13 0000000000000000 i/debug (13002): d14 0000000000000000 d15 0000000000000000 i/debug (13002): d16 3ff0000000000000 d17 3ff0000000000000 i/debug (13002): d18 40cd268000000000 d19 3f3b9cc1b0bac000 i/debug (13002): d20 3ff0000000000000 d21 8000000000000000 i/debug (13002): d22 0000000000000000 d23 0000000000000000 i/debug (13002): d24 3ff0000000000000 d25 0000000000000000 i/debug (13002): d26 0000000000000000 d27 0000000000000000 i/debug (13002): d28 0000000000000000 d29 3ff0000000000000 i/debug (13002): d30 0000000000000000 d31 3ff0000000000000 i/debug (13002): scr 60000013 i/debug (13002): i/debug (13002): #00 pc 0032f3a0 /system/lib/libwebcore.so i/debug (13002): #01 pc 003243b0 /system/lib/libwebcore.so i/debug (13002): #02 pc 003167b2 /system/lib/libwebcore.so i/debug (13002): #03 pc 0038f2de /system/lib/libwebcore.so i/debug (13002): #04 pc 0038f416 /system/lib/libwebcore.so i/debug (13002): #05 pc 0030d392 /system/lib/libwebcore.so i/debug (13002): #06 pc 003796e2 /system/lib/libwebcore.so i/debug (13002): #07 pc 0038e36a /system/lib/libwebcore.so i/debug (13002): #08 pc 003189f0 /system/lib/libwebcore.so i/debug (13002): #09 pc 00377f82 /system/lib/libwebcore.so i/debug (13002): #10 pc 0037ae0c /system/lib/libwebcore.so i/debug (13002): #11 pc 0038e254 /system/lib/libwebcore.so i/debug (13002): #12 pc 003189f0 /system/lib/libwebcore.so i/debug (13002): #13 pc 0031cf2c /system/lib/libwebcore.so i/debug (13002): #14 pc 0038e52a /system/lib/libwebcore.so i/debug (13002): #15 pc 0038c2d0 /system/lib/libwebcore.so i/debug (13002): #16 pc 0031cf76 /system/lib/libwebcore.so i/debug (13002): #17 pc 0038e546 /system/lib/libwebcore.so i/debug (13002): #18 pc 003189f0 /system/lib/libwebcore.so i/debug (13002): #19 pc 0031ca40 /system/lib/libwebcore.so i/debug (13002): #20 pc 0038e3be /system/lib/libwebcore.so i/debug (13002): #21 pc 0038c2d0 /system/lib/libwebcore.so i/debug (13002): #22 pc 0031cf76 /system/lib/libwebcore.so i/debug (13002): #23 pc 0038e546 /system/lib/libwebcore.so i/debug (13002): #24 pc 0038c2d0 /system/lib/libwebcore.so i/debug (13002): #25 pc 00379054 /system/lib/libwebcore.so i/debug (13002): #26 pc 0031d254 /system/lib/libwebcore.so i/debug (13002): #27 pc 0030d5d6 /system/lib/libwebcore.so i/debug (13002): #28 pc 0030d7d2 /system/lib/libwebcore.so i/debug (13002): #29 pc 0031e354 /system/lib/libwebcore.so i/debug (13002): #30 pc 0034ab3c /system/lib/libwebcore.so i/debug (13002): i/debug (13002): code around pc: i/debug (13002): a862f380 469e4694 cc04f853 0e04f1a3 510cea4f i/debug (13002): a862f390 f41c0d09 bf080f00 44714249 c008f8d1 i/debug (13002): a862f3a0 e000f8dc 0c1ff10e bf0842b8 2d04f853 i/debug (13002): a862f3b0 0d010510 0f00f412 4249bf08 f8c2185a i/debug (13002): a862f3c0 e006c008 d1042b0c 99019b05 18426818 i/debug (13002): i/debug (13002): code around lr: i/debug (13002): 4a3bcc38 e58d0000 e49d0004 e598200b e582002f i/debug (13002): 4a3bcc48 e52d0004 e3100001 0a000018 e3a03030 i/debug (13002): 4a3bcc58 e59fc2a0 e002100c e59fc29c e151000c i/debug (13002): 4a3bcc68 0a000012 e59fc294 e002100c e0813003 i/debug (13002): 4a3bcc78 e1a03123 e1c2200c e3530b02 ba000004 i/debug (13002): i/debug (13002): stack: i/debug (13002): 4ebe09f0 50bfd848 i/debug (13002): 4ebe09f4 50bfd858 i/debug (13002): 4ebe09f8 50bfd834 i/debug (13002): 4ebe09fc afd19a05 /system/lib/libc.so i/debug (13002): 4ebe0a00 50bd3264 i/debug (13002): 4ebe0a04 a86510ef /system/lib/libwebcore.so i/debug (13002): 4ebe0a08 00000004 i/debug (13002): 4ebe0a0c 50bfd854 i/debug (13002): 4ebe0a10 002ece20 [heap] i/debug (13002): 4ebe0a14 4a3ba000 i/debug (13002): 4ebe0a18 4ebe0a3c i/debug (13002): 4ebe0a1c 4ebe0a3c i/debug (13002): 4ebe0a20 4a3bc101 i/debug (13002): 4ebe0a24 4ebe0a3c i/debug (13002): 4ebe0a28 df002777 i/debug (13002): 4ebe0a2c e3a070ad i/debug (13002): #00 4ebe0a30 002ece20 [heap] i/debug (13002): 4ebe0a34 49f627d0 i/debug (13002): 4ebe0a38 a87d63c0 /system/lib/libwebcore.so i/debug (13002): 4ebe0a3c 4a3bd0e7 i/debug (13002): 4ebe0a40 4a3bd0b8 i/debug (13002): 4ebe0a44 4a3bcc58 i/debug (13002): 4ebe0a48 00000003 i/debug (13002): 4ebe0a4c 00000000 i/debug (13002): 4ebe0a50 00001100 i/debug (13002): 4ebe0a54 0000001f i/debug (13002): 4ebe0a58 00001074 i/debug (13002): 4ebe0a5c 4ebe0b04 i/debug (13002): 4ebe0a60 a87d63c0 /system/lib/libwebcore.so i/debug (13002): 4ebe0a64 4ebe0acc i/debug (13002): 4ebe0a68 4a3bc101 i/debug (13002): 4ebe0a6c a86243b5 /system/lib/libwebcore.so i/debug (13002): #01 4ebe0a70 4ebe0b38 i/debug (13002): 4ebe0a74 00000064 i/debug (13002): 4ebe0a78 003f0914 [heap] i/debug (13002): 4ebe0a7c fffffc00 i/debug (13002): 4ebe0a80 50bfd834 i/debug (13002): 4ebe0a84 a87d63c0 /system/lib/libwebcore.so i/debug (13002): 4ebe0a88 4ebe0b38 i/debug (13002): 4ebe0a8c 4ebe0b04 i/debug (13002): 4ebe0a90 4ebe0acc i/debug (13002): 4ebe0a94 a86167b7 /system/lib/libwebcore.so
我们的板子上的lib 经常被strip过了,没有了符号信息。不过我们可以通过编译时候生成的库来获取对应的符号信息。编译器也为我们提供了相应的工具:addr2line 全名为:arm-eabi-addr2line ,可在对应板子源码目录找到。
通过上面的断错误分析,位于system/lib/libwebcore.so 这个库出现了断错误,可以将其pull下来正逐行分析。命令为:arm-eabi-addr2line -f -e ~/桌面/libwebcore.so 0038f2de
这种分析法同样适用于使用jni开发的库。
希望本文所述对大家的android程序设计有所帮助。