1、使用下面的脚本hy.panic.py查找死机函数(摘自其它人的博客)
#!/usr/bin/python # stack symbol parser import os import string import sys #define android product name ANDROID_PRODUCT_NAME = 'generic' 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])
I/DEBUG ( 770): #00 pc 0000dd50 /system/lib/libc.so I/DEBUG ( 770): #01 pc 0000f1aa /system/lib/libc.so I/DEBUG ( 770): #02 pc 000009b0 /system/lib/libstdc++.so I/DEBUG ( 770): #03 pc 00134b90 /data/data/com.ipanel.portal/lib/libportal_jni.so I/DEBUG ( 770): #04 pc 00134bce /data/data/com.ipanel.portal/lib/libportal_jni.so I/DEBUG ( 770): #05 pc 00134be6 /data/data/com.ipanel.portal/lib/libportal_jni.so I/DEBUG ( 770): #06 pc 0013d2f6 /data/data/com.ipanel.portal/lib/libportal_jni.so I/DEBUG ( 770): #07 pc 00147716 /data/data/com.ipanel.portal/lib/libportal_jni.so I/DEBUG ( 770): #08 pc 0013606c /data/data/com.ipanel.portal/lib/libportal_jni.so I/DEBUG ( 770): #09 pc 00011cb4 /system/lib/libdvm.so
2、系统变慢
a)、top -m 4 -d 1 查看下是哪个进程 占用了比较高的CPU;
b)、top -t -d 1 -m 10查看哪个线程占用了比较多的CPU
通过prctl(PR_SET_NAME, (unsigned long)"main_mgr_thread", 0, 0, 0);在线程函数开始设置线程的名字
c)、cat /proc/meminfo查看下内在情况