在android开发过程中,经常出现运行写的程序后机子立马死机,然后打了一堆不认识的log,如下所示:
I/DEBUG ( 161): Build fingerprint: 'unknown' I/DEBUG ( 161): pid: 758, tid: 765 >>> com.oppo.wallpaper <<< I/DEBUG ( 161): signal 11 (SIGSEGV), fault addr 49f23000 I/DEBUG ( 161): r0 4a1ba240 r1 49f22ff8 r2 000006a0 r3 00000000 I/DEBUG ( 161): r4 00000000 r5 00000000 r6 00000960 r7 00000001 I/DEBUG ( 161): r8 00100000 r9 a9e169b5 10 49e23000 fp 49f22e48 I/DEBUG ( 161): ip 80f09130 sp 49f22aa0 lr 80f02828 pc afd0f1ec cpsr 20000010 I/DEBUG ( 161): d0 643a64696f72646e d1 6472656767756265 I/DEBUG ( 161): d2 0000000000000000 d3 0000000000000000 I/DEBUG ( 161): d4 0000000000000000 d5 0000000000000000 I/DEBUG ( 161): d6 0000000000000000 d7 0000000000000000 I/DEBUG ( 161): d8 0000000000000000 d9 0000000000000000 I/DEBUG ( 161): d10 0000000000000000 d11 0000000000000000 I/DEBUG ( 161): d12 0000000000000000 d13 0000000000000000 I/DEBUG ( 161): d14 0000000000000000 d15 0000000000000000 I/DEBUG ( 161): d16 0000000000000000 d17 beb1bcce06c829e8 I/DEBUG ( 161): d18 bf29ff2fd6cab8b8 d19 3ec6cd878c3b46a7 I/DEBUG ( 161): d20 bf6681d6ffb6f084 d21 3f3937f8a97fa389 I/DEBUG ( 161): d22 3fcdee92c0000000 d23 3ef99342e0ee5069 I/DEBUG ( 161): d24 3ef99342e0ee5069 d25 be3dd3baa0000000 I/DEBUG ( 161): d26 be3dd3baa0000000 d27 3ef99342e0ee5069 I/DEBUG ( 161): d28 0000000000000000 d29 0000000000000000 I/DEBUG ( 161): d30 0000000000000000 d31 0000000000000000 I/DEBUG ( 161): scr 80000013 I/DEBUG ( 161): I/DEBUG ( 161): #00 pc 0000f1ec /system/lib/libc.so I/DEBUG ( 161): #01 pc 00002824 /system/lib/libgsl.so I/DEBUG ( 161): #02 pc 00088e8c /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #03 pc 00090f94 /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #04 pc 0005f8e2 /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #05 pc 000623ca /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #06 pc 00082622 /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #07 pc 00020772 /system/lib/libRS.so I/DEBUG ( 161): #08 pc 000207be /system/lib/libRS.so I/DEBUG ( 161): #09 pc 0001f4dc /system/lib/libRS.so I/DEBUG ( 161): I/DEBUG ( 161): code around pc: I/DEBUG ( 161): afd0f1cc f5d1f000 f5d1f020 e2522040 3a000009 I/DEBUG ( 161): afd0f1dc f5d1f040 f5d1f060 f5d1f080 f421020d I/DEBUG ( 161): afd0f1ec f421420d f5d1f080 e2522040 f400022d I/DEBUG ( 161): afd0f1fc f400422d 2afffff8 e2822040 e2522020 I/DEBUG ( 161): afd0f20c 3a000003 f421020d e2522020 f400022d I/DEBUG ( 161): I/DEBUG ( 161): code around lr: I/DEBUG ( 161): 80f02808 e5901008 e0836005 e1560001 8a000006 I/DEBUG ( 161): 80f02818 e5903000 e1a0100c e0830005 eb00099c I/DEBUG ( 161): 80f02828 e1a00004 e28dd008 e8bd8070 e59f004c I/DEBUG ( 161): 80f02838 e1a02005 e59fc048 e58d1000 e79e0000 I/DEBUG ( 161): 80f02848 e08e100c e28000a8 ebffff44 e3e00000 I/DEBUG ( 161): I/DEBUG ( 161): stack: I/DEBUG ( 161): 49f22a60 0028a9a0 [heap] I/DEBUG ( 161): 49f22a64 002f0d68 [heap] I/DEBUG ( 161): 49f22a68 00000004 I/DEBUG ( 161): 49f22a6c 81a5f8e7 /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): 49f22a70 00000000 I/DEBUG ( 161): 49f22a74 81b9b26c /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): 49f22a78 00000000 I/DEBUG ( 161): 49f22a7c afd102e4 /system/lib/libc.so I/DEBUG ( 161): 49f22a80 afd4373c /system/lib/libc.so I/DEBUG ( 161): 49f22a84 00000050 I/DEBUG ( 161): 49f22a88 002f1170 [heap] I/DEBUG ( 161): 49f22a8c 81bc8740 /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): 49f22a90 00100000 [heap] I/DEBUG ( 161): 49f22a94 a9e169b5 /system/lib/libRS.so I/DEBUG ( 161): 49f22a98 df002777 I/DEBUG ( 161): 49f22a9c e3a070ad I/DEBUG ( 161): #00 49f22aa0 4a1b9fc0 /dev/zero (deleted) I/DEBUG ( 161): 49f22aa4 80f02828 /system/lib/libgsl.so I/DEBUG ( 161): #01 49f22aa8 00281c40 [heap] I/DEBUG ( 161): 49f22aac 00000960 I/DEBUG ( 161): 49f22ab0 002f1170 [heap] I/DEBUG ( 161): 49f22ab4 0028a9a0 [heap] I/DEBUG ( 161): 49f22ab8 002f118c [heap] I/DEBUG ( 161): 49f22abc 81a88e8f /system/lib/egl/libGLESv2_adreno200.so
1.首先取以上log信息中的从#00开始连续的那一部分,保存为error.txt(文档名可以随便取)
I/DEBUG ( 161): #00 pc 0000f1ec /system/lib/libc.so I/DEBUG ( 161): #01 pc 00002824 /system/lib/libgsl.so I/DEBUG ( 161): #02 pc 00088e8c /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #03 pc 00090f94 /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #04 pc 0005f8e2 /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #05 pc 000623ca /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #06 pc 00082622 /system/lib/egl/libGLESv2_adreno200.so I/DEBUG ( 161): #07 pc 00020772 /system/lib/libRS.so I/DEBUG ( 161): #08 pc 000207be /system/lib/libRS.so I/DEBUG ( 161): #09 pc 0001f4dc /system/lib/libRS.so2.将该txt文档和我附录给的hy.panic.py文件都拷入到android源码的根目录下,之后修改hy.panic.py中的ANDROID_PRODUCT_NAME 为你目前的手机固件名
3.在linux终端中进入源码根目录,然后执行./hy.panic.py error.txt,完了就会显示在哪个文件的哪行代码调用出问题 ,注意第一个点后面没有空格
有时运行后会出现如下错误:
read file ok /home/android/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-addr2line: '/home/android/out/target/product/msm7630_surf/symbols/system/lib/libRS.so': No such file Traceback (most recent call last): File "./hy.panic.py", line 64, in <module> print "%-30s%s" % (list[1],list[0]) IndexError: list index out of range
#!/usr/bin/python # stack symbol parser import os import string import sys #define android product name ANDROID_PRODUCT_NAME = 'msm7630_surf' ANDROID_WORKSPACE = os.getcwd()+"/" # addr2line tool path and symbol path addr2line_tool = ANDROID_WORKSPACE + 'prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-addr2line' symbol_dir = ANDROID_WORKSPACE + 'out/target/product/' + ANDROID_PRODUCT_NAME +'/symbols' symbol_bin = symbol_dir + '/system/bin/' symbol_lib = symbol_dir + '/system/lib/' class ReadLog: def __init__(self,filename): self.logname = filename def parse(self): f = file(self.logname,'r') lines = f.readlines() if lines != []: print 'read file ok' else: print 'read file failed' result =[] for line in lines: if line.find('stack') != -1: print 'stop search' break elif line.find('system') != -1: #print 'find one item' + line result.append(line) return result class ParseContent: def __init__(self,addr,lib): self.address = addr # pc address self.exename = lib # executable or shared library def addr2line(self): cmd = addr2line_tool + " -C -f -s -e " + symbol_dir + self.exename + " " + self.address #print cmd stream = os.popen(cmd) lines = stream.readlines(); list = map(string.strip,lines) return list inputarg = sys.argv if len(inputarg) < 2: print 'Please input panic log' exit() filename = inputarg[1] readlog = ReadLog(filename) inputlist = readlog.parse() for item in inputlist: itemsplit = item.split() test = ParseContent(itemsplit[-2],itemsplit[-1]) list = test.addr2line() print "%-30s%s" % (list[1],list[0])