Android调用堆栈跟踪实例分析
本文实例讲述了Android调用堆栈跟踪的方法。分享给大家供大家参考。具体如下:
Android开发中,我们也会经常遇到段错误,也就是SIGSEGV(11),这个时候libc的backtrace会打印出对应的堆栈信息,而你看到的仅仅是一对数字,好像无从查起。
如下面这一从串断错误:
ActivityManager(1105):Displayedactivitycom.android.browser/.BrowserActivity:2460ms(total2460ms) I/DEBUG(13002):************************************************ I/DEBUG(13002):Buildfingerprint:'unknown' I/DEBUG(13002):pid:20363,tid:20375>>>com.android.browser<<< I/DEBUG(13002):signal11(SIGSEGV),faultaddrffc00000 I/DEBUG(13002):r0059fc2a0r14a3bcef8r2e59fc2a0r34a3bcc58 I/DEBUG(13002):r44a3bc101r54ebe0a3cr64a3bc120r7012fff10 I/DEBUG(13002):r8500de101r9500ee12d10a87dfb20fp4ebe58e0 I/DEBUG(13002):ipffc00000sp4ebe0a30lr4a3bcc58pca862f3a0cpsr00000030 I/DEBUG(13002):d00000001100000011d10000001100000011 I/DEBUG(13002):d20000001100000011d30000001100000011 I/DEBUG(13002):d40000001100000011d50000001100000011 I/DEBUG(13002):d60000001100000011d74060000000000080 I/DEBUG(13002):d841d3d1762e40d70ad941d3d1762e440a3d I/DEBUG(13002):d100000000000000000d110000000000000000 I/DEBUG(13002):d120000000000000000d130000000000000000 I/DEBUG(13002):d140000000000000000d150000000000000000 I/DEBUG(13002):d163ff0000000000000d173ff0000000000000 I/DEBUG(13002):d1840cd268000000000d193f3b9cc1b0bac000 I/DEBUG(13002):d203ff0000000000000d218000000000000000 I/DEBUG(13002):d220000000000000000d230000000000000000 I/DEBUG(13002):d243ff0000000000000d250000000000000000 I/DEBUG(13002):d260000000000000000d270000000000000000 I/DEBUG(13002):d280000000000000000d293ff0000000000000 I/DEBUG(13002):d300000000000000000d313ff0000000000000 I/DEBUG(13002):scr60000013 I/DEBUG(13002): I/DEBUG(13002):#00pc0032f3a0/system/lib/libwebcore.so I/DEBUG(13002):#01pc003243b0/system/lib/libwebcore.so I/DEBUG(13002):#02pc003167b2/system/lib/libwebcore.so I/DEBUG(13002):#03pc0038f2de/system/lib/libwebcore.so I/DEBUG(13002):#04pc0038f416/system/lib/libwebcore.so I/DEBUG(13002):#05pc0030d392/system/lib/libwebcore.so I/DEBUG(13002):#06pc003796e2/system/lib/libwebcore.so I/DEBUG(13002):#07pc0038e36a/system/lib/libwebcore.so I/DEBUG(13002):#08pc003189f0/system/lib/libwebcore.so I/DEBUG(13002):#09pc00377f82/system/lib/libwebcore.so I/DEBUG(13002):#10pc0037ae0c/system/lib/libwebcore.so I/DEBUG(13002):#11pc0038e254/system/lib/libwebcore.so I/DEBUG(13002):#12pc003189f0/system/lib/libwebcore.so I/DEBUG(13002):#13pc0031cf2c/system/lib/libwebcore.so I/DEBUG(13002):#14pc0038e52a/system/lib/libwebcore.so I/DEBUG(13002):#15pc0038c2d0/system/lib/libwebcore.so I/DEBUG(13002):#16pc0031cf76/system/lib/libwebcore.so I/DEBUG(13002):#17pc0038e546/system/lib/libwebcore.so I/DEBUG(13002):#18pc003189f0/system/lib/libwebcore.so I/DEBUG(13002):#19pc0031ca40/system/lib/libwebcore.so I/DEBUG(13002):#20pc0038e3be/system/lib/libwebcore.so I/DEBUG(13002):#21pc0038c2d0/system/lib/libwebcore.so I/DEBUG(13002):#22pc0031cf76/system/lib/libwebcore.so I/DEBUG(13002):#23pc0038e546/system/lib/libwebcore.so I/DEBUG(13002):#24pc0038c2d0/system/lib/libwebcore.so I/DEBUG(13002):#25pc00379054/system/lib/libwebcore.so I/DEBUG(13002):#26pc0031d254/system/lib/libwebcore.so I/DEBUG(13002):#27pc0030d5d6/system/lib/libwebcore.so I/DEBUG(13002):#28pc0030d7d2/system/lib/libwebcore.so I/DEBUG(13002):#29pc0031e354/system/lib/libwebcore.so I/DEBUG(13002):#30pc0034ab3c/system/lib/libwebcore.so I/DEBUG(13002): I/DEBUG(13002):codearoundpc: I/DEBUG(13002):a862f380469e4694cc04f8530e04f1a3510cea4f I/DEBUG(13002):a862f390f41c0d09bf080f0044714249c008f8d1 I/DEBUG(13002):a862f3a0e000f8dc0c1ff10ebf0842b82d04f853 I/DEBUG(13002):a862f3b00d0105100f00f4124249bf08f8c2185a I/DEBUG(13002):a862f3c0e006c008d1042b0c99019b0518426818 I/DEBUG(13002): I/DEBUG(13002):codearoundlr: I/DEBUG(13002):4a3bcc38e58d0000e49d0004e598200be582002f I/DEBUG(13002):4a3bcc48e52d0004e31000010a000018e3a03030 I/DEBUG(13002):4a3bcc58e59fc2a0e002100ce59fc29ce151000c I/DEBUG(13002):4a3bcc680a000012e59fc294e002100ce0813003 I/DEBUG(13002):4a3bcc78e1a03123e1c2200ce3530b02ba000004 I/DEBUG(13002): I/DEBUG(13002):stack: I/DEBUG(13002):4ebe09f050bfd848 I/DEBUG(13002):4ebe09f450bfd858 I/DEBUG(13002):4ebe09f850bfd834 I/DEBUG(13002):4ebe09fcafd19a05/system/lib/libc.so I/DEBUG(13002):4ebe0a0050bd3264 I/DEBUG(13002):4ebe0a04a86510ef/system/lib/libwebcore.so I/DEBUG(13002):4ebe0a0800000004 I/DEBUG(13002):4ebe0a0c50bfd854 I/DEBUG(13002):4ebe0a10002ece20[heap] I/DEBUG(13002):4ebe0a144a3ba000 I/DEBUG(13002):4ebe0a184ebe0a3c I/DEBUG(13002):4ebe0a1c4ebe0a3c I/DEBUG(13002):4ebe0a204a3bc101 I/DEBUG(13002):4ebe0a244ebe0a3c I/DEBUG(13002):4ebe0a28df002777 I/DEBUG(13002):4ebe0a2ce3a070ad I/DEBUG(13002):#004ebe0a30002ece20[heap] I/DEBUG(13002):4ebe0a3449f627d0 I/DEBUG(13002):4ebe0a38a87d63c0/system/lib/libwebcore.so I/DEBUG(13002):4ebe0a3c4a3bd0e7 I/DEBUG(13002):4ebe0a404a3bd0b8 I/DEBUG(13002):4ebe0a444a3bcc58 I/DEBUG(13002):4ebe0a4800000003 I/DEBUG(13002):4ebe0a4c00000000 I/DEBUG(13002):4ebe0a5000001100 I/DEBUG(13002):4ebe0a540000001f I/DEBUG(13002):4ebe0a5800001074 I/DEBUG(13002):4ebe0a5c4ebe0b04 I/DEBUG(13002):4ebe0a60a87d63c0/system/lib/libwebcore.so I/DEBUG(13002):4ebe0a644ebe0acc I/DEBUG(13002):4ebe0a684a3bc101 I/DEBUG(13002):4ebe0a6ca86243b5/system/lib/libwebcore.so I/DEBUG(13002):#014ebe0a704ebe0b38 I/DEBUG(13002):4ebe0a7400000064 I/DEBUG(13002):4ebe0a78003f0914[heap] I/DEBUG(13002):4ebe0a7cfffffc00 I/DEBUG(13002):4ebe0a8050bfd834 I/DEBUG(13002):4ebe0a84a87d63c0/system/lib/libwebcore.so I/DEBUG(13002):4ebe0a884ebe0b38 I/DEBUG(13002):4ebe0a8c4ebe0b04 I/DEBUG(13002):4ebe0a904ebe0acc I/DEBUG(13002):4ebe0a94a86167b7/system/lib/libwebcore.so
我们的板子上的lib经常被strip过了,没有了符号信息。不过我们可以通过编译时候生成的库来获取对应的符号信息。编译器也为我们提供了相应的工具:addr2line全名为:arm-eabi-addr2line,可在对应板子源码目录找到。
通过上面的断错误分析,位于system/lib/libwebcore.so这个库出现了断错误,可以将其pull下来正逐行分析。命令为:arm-eabi-addr2line-f-e~/桌面/libwebcore.so0038f2de
这种分析法同样适用于使用jni开发的库。
希望本文所述对大家的Android程序设计有所帮助。