android 死机原因查找

1、使用下面的脚本hy.panic.py查找死机函数(摘自其它人的博客)

  1. #!/usr/bin/python  
  2. # stack symbol parser  
  3. import os  
  4. import string  
  5. import sys  
  6.   
  7. #define android product name  
  8. ANDROID_PRODUCT_NAME = 'generic'  
  9.   
  10. ANDROID_WORKSPACE = os.getcwd()+"/"  
  11.   
  12. # addr2line tool path and symbol path  
  13. addr2line_tool = ANDROID_WORKSPACE + 'prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-addr2line'  
  14. symbol_dir = ANDROID_WORKSPACE + 'out/target/product/' + ANDROID_PRODUCT_NAME +'/symbols'  
  15. symbol_bin = symbol_dir + '/system/bin/'  
  16. symbol_lib = symbol_dir + '/system/lib/'  
  17.   
  18.   
  19. class ReadLog:  
  20.     def __init__(self,filename):  
  21.         self.logname = filename  
  22.     def parse(self):  
  23.         f = file(self.logname,'r')  
  24.         lines = f.readlines()  
  25.         if lines != []:  
  26.             print 'read file ok'  
  27.         else:  
  28.             print 'read file failed'  
  29.         result =[]  
  30.         for line in lines:  
  31.             if line.find('stack') != -1:  
  32.                 print 'stop search'  
  33.                 break  
  34.             elif line.find('system') != -1:  
  35.                 #print 'find one item' + line  
  36.                 result.append(line)  
  37.         return result  
  38.   
  39. class ParseContent:  
  40.     def __init__(self,addr,lib):  
  41.             self.address = addr # pc address  
  42.             self.exename = lib  # executable or shared library  
  43.     def addr2line(self):  
  44.         cmd = addr2line_tool + " -C -f -s -e " + symbol_dir + self.exename + " " + self.address  
  45.         #print cmd  
  46.         stream = os.popen(cmd)  
  47.         lines = stream.readlines();  
  48.         list = map(string.strip,lines)  
  49.         return list  
  50.       
  51. inputarg = sys.argv  
  52. if len(inputarg) < 2:  
  53.     print 'Please input panic log'  
  54.     exit()  
  55.   
  56. filename = inputarg[1]  
  57. readlog = ReadLog(filename)  
  58. inputlist = readlog.parse()  
  59.   
  60. for item in inputlist:  
  61.     itemsplit = item.split()  
  62.     test = ParseContent(itemsplit[-2],itemsplit[-1])  
  63.     list = test.addr2line()  
  64.     print "%-30s%s" % (list[1],list[0])  

把死机的地方保存到一个error.txt,内容类似如下:

  1. I/DEBUG   (  770):          #00  pc 0000dd50  /system/lib/libc.so  
  2. I/DEBUG   (  770):          #01  pc 0000f1aa  /system/lib/libc.so  
  3. I/DEBUG   (  770):          #02  pc 000009b0  /system/lib/libstdc++.so  
  4. I/DEBUG   (  770):          #03  pc 00134b90  /data/data/com.ipanel.portal/lib/libportal_jni.so  
  5. I/DEBUG   (  770):          #04  pc 00134bce  /data/data/com.ipanel.portal/lib/libportal_jni.so  
  6. I/DEBUG   (  770):          #05  pc 00134be6  /data/data/com.ipanel.portal/lib/libportal_jni.so  
  7. I/DEBUG   (  770):          #06  pc 0013d2f6  /data/data/com.ipanel.portal/lib/libportal_jni.so  
  8. I/DEBUG   (  770):          #07  pc 00147716  /data/data/com.ipanel.portal/lib/libportal_jni.so  
  9. I/DEBUG   (  770):          #08  pc 0013606c  /data/data/com.ipanel.portal/lib/libportal_jni.so  
  10. I/DEBUG   (  770):          #09  pc 00011cb4  /system/lib/libdvm.so  


然后执行:python hy.panic.py error.txt就可以知道在哪个地方死机了


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查看下内在情况


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值