Android EventLog各种标签含义
1. Eventlog获取
1. adb shell logcat -b events 可以获取如下的event log
1. 02-13 11:31:40.960 1366 2745 I am_set_resumed_activity: [0,com.android.launcher3/com.android.a1launcher.AndroidOneLauncher,resumeTopActivityInnerLocked]
2. 02-13 11:31:40.965 1366 2745 I am_resume_activity: [0,92325532,2,com.android.launcher3/com.android.a1launcher.AndroidOneLauncher]
3. 02-13 11:31:40.976 1366 1479 I dvm_lock_sample: [system_server,1,android.ui,12,ActivityManagerService.java,4986,void com.android.server.am.ActivityManagerService.dispatchUidsChanged(),-,8124,void com.android.server.am.ActivityManagerService.keyguardGoingAway(int),2]
4. 02-13 11:31:40.995 3219 3219 I am_on_restart_called: [0,com.android.a1launcher.AndroidOneLauncher,performRestartActivity]
5. 02-13 11:31:41.012 3219 3219 I am_on_start_called: [0,com.android.a1launcher.AndroidOneLauncher,handleStartActivity]
6. 02-13 11:31:41.013 3219 3219 I am_on_resume_called: [0,com.android.a1launcher.AndroidOneLauncher,RESUME_ACTIVITY]
7. 02-13 11:31:41.201 1366 1505 I am_activity_launch_time: [0,92325532,com.android.launcher3/com.android.a1launcher.AndroidOneLauncher,143599518,143605519]
2. 和system log一样,记录了手机运行过程中的做动以及状态,可以用来分析一些问题
2. 格式说明
1. 安卓P上不同类型的Eventlog都在不同的.logtags文件中进行说明,P以前在EventLog.java, EventLogTags.java等文件说明
tags格式文件system/core/logcat/event.logtags,
详细见链接:http://androidxref.com/9.0.0_r3/xref/system/core/logcat/event.logtags
2. 格式讲解
1. # The activity's onRestart has been called.
2. 30058 am_on_restart_called (User|1|5),(Component Name|3),(Reason|3)
3. 02-13 11:31:40.995 3219 3219 I am_on_restart_called: [0,com.android.a1launcher.AndroidOneLauncher,performRestartActivity]
4. 以上面的am_on_restart_called标签为例,
(User|1|5):表示:(
5. 其中数据类型和数据单位都用代号表示,具体如下
6. # The data type is a number from the following values:
7. # 1: int
8. # 2: long
9. # 3: string
10. # 4: list
11. # 5: float
12. #
13. # The data unit is a number taken from the following list:
14. # 1: Number of objects
15. # 2: Number of bytes
16. # 3: Number of milliseconds
17. # 4: Number of allocations
18. # 5: Id
19. # 6: Percent
20. # s: Number of seconds (monotonic time)
21. # Default value for data of type int/long is 2 (bytes).
22. #
23. 30058 am_on_restart_called (User|1|5),(Component Name|3),(Reason|3)
24. 02-13 11:31:40.995 3219 3219 I am_on_restart_called: [0,com.android.a1launcher.AndroidOneLauncher,performRestartActivity]
25. 如上的am_on_restart_called 即可解释为:3个括号代表里面有三个内容
User值为0,类型为int,单位为ID,
Component Name 数据类型为3:string,值为com.android.a1launcher.AndroidOneLauncher
Reason 数据类型为3:string,值为performRestartActivity
26. 有了以上的分析其他的标签可以对照上表和.logtags文件进行解析
3. 各种类型的event log说明
1. ActivityManager
1. ActivityManager tag文件:frameworks/base/services/core/java/com/android/server/am/EventLogTags.logtags
http://androidxref.com/9.0.0_r3/xref/frameworks/base/services/core/java/com/android/server/am/EventLogTags.logtags
2. 以am_开头,表示activity的生命周期或进程管理相关信息
3. 典型TAG解析
1. am_pss 表示进程的内存信息,包括Pss ,Uss ,SwapPss ,Rss ,StatType等
1. 30047 am_pss (Pid|1|5),(UID|1|5),(Process Name|3),(Pss|2|2),(Uss|2|2),(SwapPss|2|2),(Rss|2|2),(StatType|1|5),(ProcState|1|5),(TimeToCollect|2|2)
02-04 01:46:04.424 1556 1578 I am_pss : [13478,10012,android.process.media,16360448,7737344,7533568]
am_pss(pid,uid,Process Name ,Pss ,Uss ,SwapPss ,Rss ,StatType )
2. 底层信息
1. 定义位置
system/core/logcat/event.logtags(http://androidxref.com/9.0.0_r3/xref/system/core/logcat/event.logtags)
2. dvm_lock_sample 锁等待时间信息
20003 dvm_lock_sample (process|3),(main|1|5),(thread|3),(time|1|3),(file|3),(line|1|5),(ownerfile|3),(ownerline|1|5),(sample_percent|1|6)
02-04 01:47:00.964 1880 2070 I dvm_lock_sample: [com.ss.android.ugc.aweme,0,application background threads-2,512,NetInitializer.java,-1,Object.java,-2,0]
dvm_lock_sample:[进程名,main ,线程名字,锁等待时间,当前持有者的文件名,行号,上一个持有者文件名(-为相同文件),行号,锁等待相对于500ms的百分比]
上面的log表示com.ss.android.ugc.aweme进程的application background threads-2线程的NetInitializer.java文件-1行等待了512ms,锁被Object.java,-2行持有
3. 实现文件位于art/runtime/monitor_android.cc
4. 参考文章
1. https://www.jianshu.com/p/62d1af61d73f Android性能问题分析与优化,详细讲解了性能分析的几个方向还不错
2. http://gityuan.com/2016/05/15/event-log/
3. https://blog.csdn.net/ruingman/article/details/53118202