美文网首页
bug report

bug report

作者: richy_ | 来源:发表于2019-03-21 10:36 被阅读0次

    ref:https://github.com/sonyxperiadev/ChkBugReport
    https://github.com/google/battery-historian

    https://source.android.google.cn/source/read-bug-reports

    http://www.voidcn.com/article/p-ngdhydls-bez.html

    https://www.jianshu.com/p/d872ea28c2fc

    How to take a bug report

    To take a bug report from your Android device, you will need to enable USB debugging under Settings > System > Developer Options. On Android 4.2 and higher, the Developer options screen is hidden by default. You can enable this by following the instructions here.

    To obtain a bug report from your development device running Android 7.0 and higher:

    $ adb bugreport bugreport.zip
    

    For devices 6.0 and lower:

    $ adb bugreport > bugreport.txt
    

    use chkbugreport

    unzip bugreport.zip -d bug
    cd bug
    java -jar ../chkbugreport-0.5-215.jar bugreport-NMF26F-1970-02-05-06-31-55.txt
    

    得到如下的内容

    image
    rentianxin@rentianxin-Desk ~/s/b/bug> ls                                     
    bugreport-NMF26F-1970-02-05-06-31-55_out  FS              systrace.txt
    bugreport-NMF26F-1970-02-05-06-31-55.txt  main_entry.txt  version.txt
    rentianxin@rentianxin-Desk ~/s/b/bug> cd bugreport-NMF26F-1970-02-05-06-31-55_out
    rentianxin@rentianxin-Desk ~/s/b/b/bugreport-NMF26F-1970-02-05-06-31-55_out> ls
    data  index.html  raw
    rentianxin@rentianxin-Desk ~/s/b/b/bugreport-NMF26F-1970-02-05-06-31-55_out> google-chrome index.html 
    
    

    可以在chrome中打开 ,得到如下内容

    image

    chkbugreport的常见参数如下:

    参数 说明
    -ds:file 分析dumsys输出(类似-pb)
    -el:file 分析event日志
    -ft:file 分析ftrace dump
    -ml:file 分析main日志
    -mo:file 分析monkey输出并提取堆栈信息
    -pb:file 加载bugreport部分数据(例如dumpsys输出的数据)
    -pk:file 加载packages.xml
    -ps:file 分析 “processes”部分
    -pt:file 分析”processes and threads”部分
    -sa:file 分析”vm traces at last anr”部分
    -sl:file 分析system日志
    -sn:file 分析”vm traces just now”部分
    -sd:dir 从指定目录加载部分bugreports
    -uh:file 加载usage-history.xml

    其他参数(较少使用):

    不常用参数 说明
    –browser 分析完后启动浏览器查看结果报告
    –gui 不指定文件名则启动图形界面(开发中)
    –silent 不输出非严重错误信息
    –limit 限制要分析文件大小
    –no-limit 不限制分析文件大小

    示例

    1、分析Bugreport文件

    java -jar $HOME/Downloads/chkbugreport.jar $HOME/tmp/bugreport.txt
    

    你也可以把chkbugreport.jar加到path下,然后这样使用,这将根据你的bugreport数据输出一个分析结果目录bugreport_out。

    chkbugreport thebugreport.txt
    

    你可以使用如下命令取得bugreport:

    adb bugreport > bugreport.txt
    

    2、分析BugReport的部分数据

    当然你可以使用ChkBugReport分析bugreport的部分数据比如/data/anr/traces.txt

    chkbugreport -sl:the_system_log.txt -sa:traces.txt dummy
    

    这将输出分析结果到dummy_out。

    3、分析profile文件

    你甚至可以使用ChkBugReport分析traceview生成的数据

    chkbugreport -t something.prof
    

    附prof数据生成方法:

    1. 可以使用eclipse插件traceview生成
    2. 也可以按如下步骤
      • 用adb shell ps列出所有进程并找出你想要trace的进程的PID
      • 执行adb shell am profile PID start /data/profile.dat,开始分析
      • 操作你的app
      • 执行adb shell am profile PID stop ,停止分析
      • 导出数据并清除临时文件:adb pull /data/profile.dat adb shell rm /data/profile.dat
      • 使用ChkBugReport进行分析 chkbugreport -t profile.dat

    4、分析monkey文件

    chkbugreport -t something.prof
    java -jar chkbugreport-0.4-164.jar output_file_name -mo:monkey.log
    

    分析

    目前ChkBugReport可以从bugreport数据中抽取出如下信息:

    1. Stacktraces ChkBugReport可以从bugreport中解析出输出bugreport的最后时刻、导致ANR时刻甚至更多时刻的堆栈信息。在 官方示例 中你可以看到进程的优先级和策略都已标示出来,堆栈中耗时的部分颜色是黑红,一些违反Strict Mode的部分(比如主线程中使用数据库)颜色标记为亮红。如果这个线程死锁,在报告的Errors将会出现。
    2. Logs 这部分是对system、main和kernel日志的分析,在这里你可以看到每个进程内存使用图、那个程序产生的log最多、Activity的启动耗时、数据库操作耗时统计、对象被锁定时间、AIDL调用时间、Activity和Service的生命周期及其在内存中使用频率等等,
    3. Packages ChkBugReport解析bugreport中存储的packages.xml并展示一系列的packages、user ids和 permissions。
    4. Processes 操作app过程中产生的系统事件日志、内存使用信息等等,
    5. Battery statistics 电池使用统计信息,
    6. CPU Frequency statistics CPU频率统计信息,
    7. Raw data 被分割成小段的原始数据

    相关文章

      网友评论

          本文标题:bug report

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