美文网首页
Android系统稳定性Log分析

Android系统稳定性Log分析

作者: momxmo | 来源:发表于2021-06-29 11:47 被阅读0次

    前言:
    在平时我们开发工作中,经常会遇到系统死机、黑屏卡死、冻屏等各种莫名其妙的问题,这对于我们系统开发工作者是一大挑战,除了我们需要有处理问题经验和能力外,我们需要借助Google提供的各种log分析,提高我们定位处理问题的能力!


    各种常见问题:

    1、应用冻结/崩溃

    App这里问题比较常见,表现的现象为ANR、Crash、OOM等情况,可以通过Log日志分析:

    1.捕获通用日志
    logcat log (main, system, event, radio)
    
    2.抓取内核日志(Dmesg/kernel logs)
    adb shell  " cat  /proc/kmsg "  或者 adb shell dmesg
    
    3.获取系统ANR日志(Trace file /data/anr) 
    adb pull /data/anr/  .\anr
    
    4.获取系统墓碑日志(tombstones )
    adb pull /data/tombstones  .\tombstones
    
    5.过滤运行时异常和DEBUG异常
    adb logcat  -s AndroidRuntime,DEBUG > crash.txt
    
    2、系统重启

    这属于系统的稳定系,出现在system server死锁问题,然后Android的WatchDog看门狗检测到了,然后重启Android相关进程导致,可以通过以下手段捕获奔溃日志:

    1.捕获通用日志
    logcat log (main, system, event, radio)
    
    2.抓取内核日志(Dmesg/kernel logs)
    adb shell  " cat  /proc/kmsg "  或者 adb shell dmesg
    
    3.抓取bugreport信息(该信息是Android为了方便开发人员分析整个系统平台和某个app在运行一段时间之内的所有信息,专门开发了bugreport工具)
    adb shell bugreport  > bugreport.txt
    
    4.抓取dumpstate信息(dumpstate类似于dumpsys都是android提供给开发者的帮助了解系统运行状态的利器)
    adb shell dumpstate > dumpstate.txt
    
    5.抓取dumpsate(dumpsys都是android提供给开发者的帮助了解系统运行状态的利器)
    adb shell dumpsys > dumpsys.txt
    
    6.抓取Binder传输日志
    adb pull /d/binder/ .\binder
    
    7.获取系统ANR日志(Trace file /data/anr) 
    adb pull /data/anr/  .\anr
    
    8.获取系统墓碑日志(tombstones )
    adb pull /data/tombstones  .\tombstones
    
    3、手机黑屏(Black screen)

    终端黑屏(Black screen)这种系统稳定性问题,一般出现问题时,此时power按键一般能用,可以通过adb shell getevent查看到input事件信息,可以通过如下手段捕获崩溃日志:

    1.捕获通用日志
    logcat log (main, system, event, radio)
    
    2.抓取内核日志(Dmesg/kernel logs)
    adb shell  " cat  /proc/kmsg "  或者 adb shell dmesg
    
    3.抓取bugreport信息(该信息是Android为了方便开发人员分析整个系统平台和某个app在运行一段时间之内的所有信息,专门开发了bugreport工具)
    adb shell bugreport  > bugreport.txt
    
    4.抓取dumpstate信息(dumpstate类似于dumpsys都是android提供给开发者的帮助了解系统运行状态的利器)
    adb shell dumpstate > dumpstate.txt
    
    5.抓取dumpsate(dumpsys都是android提供给开发者的帮助了解系统运行状态的利器)
    adb shell dumpsys > dumpsys.txt
    
    6.抓取Binder传输日志
    adb pull /d/binder/ .\binder
    
    7.获取系统ANR日志(Trace file /data/anr) 
    adb pull /data/anr/  .\anr
    
    8.获取系统墓碑日志(tombstones )
    adb pull /data/tombstones  .\tombstones
    
    9.获取meminfo日志(Meminfo log) 
    adb shell cat proc/meminfo >meminfo.txt 
    
    10.获取Procrank信息 (Procrank log) 
    adb shell procrank >procrank.txt 
    
    11 获取top信息日志(Top log) 
    adb shell top -m 10  >top.txt 
    
    12.Add below information: 
    •Adb workable or not, ANR or not 
    •CTP workable or not
     -> touch screen and observe the output of
     "adb shell getevent". 
    •Display driver workable or not
     -> Use the screencast to see
     if the screen can be displayed 
    •Power key/volume key work or not? 
    Menu/back/home key work or not? 
    
    13 .查看kernel的线程函数栈
    adb shell "echo t > /proc/sysrq-trigger"
    adb shell "cat /proc/kmsg" > ./kmsg_trigger.txt
    
    4、系统卡死/屏幕卡死(System Freeze/ Touch Panel Freeze)

    这是Android系统稳定性里面最严重的,此时一般按Power按键、菜单键等都是失效的,此时可以通过adb shell getevent查看不到到input事件信息,看不到任何信息了,我们这是可以通过如下手段捕获日志:

    1.捕获通用日志
    logcat log (main, system, event, radio)
    
    2.抓取内核日志(Dmesg/kernel logs)
    adb shell  " cat  /proc/kmsg "  或者 adb shell dmesg
    
    3.抓取bugreport信息(该信息是Android为了方便开发人员分析整个系统平台和某个app在运行一段时间之内的所有信息,专门开发了bugreport工具)
    adb shell bugreport  > bugreport.txt
    
    4.抓取dumpstate信息(dumpstate类似于dumpsys都是android提供给开发者的帮助了解系统运行状态的利器)
    adb shell dumpstate > dumpstate.txt
    
    5.抓取dumpsate(dumpsys都是android提供给开发者的帮助了解系统运行状态的利器)
    adb shell dumpsys > dumpsys.txt
    
    6.抓取Binder传输日志
    adb pull /d/binder/ .\binder
    
    7.获取系统ANR日志(Trace file /data/anr) 
    adb pull /data/anr/  .\anr
    
    8.获取系统墓碑日志(tombstones )
    adb pull /data/tombstones  .\tombstones
    
    9.获取meminfo日志(Meminfo log) 
    adb shell cat proc/meminfo >meminfo.txt 
    
    10.获取Procrank信息 (Procrank log) 
    adb shell procrank >procrank.txt 
    
    11 获取top信息日志(Top log) 
    adb shell top -m 10  >top.txt 
    
    12.Add below information: 
    •Adb workable or not, ANR or not 
    •CTP workable or not
     -> touch screen and observe the output of
     "adb shell getevent". 
    •Display driver workable or not
     -> Use the screencast to see
     if the screen can be displayed 
    •Power key/volume key work or not? 
    Menu/back/home key work or not? 
    
    13 .查看kernel的线程函数栈
    adb shell "echo t > /proc/sysrq-trigger"
    adb shell "cat /proc/kmsg" > ./kmsg_trigger.txt
    
    14.抓取窗口信息 (Dumpsys window log)
    adb shell dumpsys window > dump_window.txt
    
    15.抓取可以 event信息(Key events log) 
    adb shell getevent -rtl /dev/input/event0 按键事件
    

    结语

    以上Log分析是针对不同的Android系统稳定性,提供抓日志方法。有了相关日志信息我们才能进一步进行具体日志分析,分析日志需要考研开发人员的硬实力了,有什么问题欢迎留言探讨!

    拓展内容:
    BugReport分析工具:
    google开源
    ChkBugReport开源

    另一种问题定位分析方式,更精确:Android 系统全局Bug日志监听

    相关文章

      网友评论

          本文标题:Android系统稳定性Log分析

          本文链接:https://www.haomeiwen.com/subject/hwuhultx.html