【问题标题】:Android Systrace Trace File FormatAndroid Systrace 跟踪文件格式
【发布时间】:2013-03-19 01:27:34
【问题描述】:

Android systrace 工具,通过 ADB 调用 atrace 工具。但是,我不太了解跟踪文件的格式。显然它与 linux ftrace 工具非常相似,但有一些区别。主要区别在于它不使用 System.Map 文件,而是将所有信息包含在跟踪文件中。此外,还有特定于 android 的新 B|E 条目。

在 Android 源代码中有一些关于这种格式的信息:http://androidxref.com/4.1.1/xref/external/chromium-trace/src/tracing/linux_perf_importer.js

但是,在该文档中,我们可以看到该格式属于 Linux Perf 工具。我不这么认为,linux perf 作为输出提供了一种非常不同的格式...(除非某些特殊配置处于活动状态...)

我的问题是:有人知道我在哪里可以找到关于使用 adb 的 atrace 工具生成的 android 跟踪文件的官方文档吗?

这种格式你熟悉吗?

# tracer: nop
#
# entries-in-buffer/entries-written: 66427/66427   #P:2
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
          atrace-1724  [000] d..3 14186.680000: sched_switch: prev_comm=atrace prev_pid=1724 prev_prio=120 prev_state=S ==> next_comm=swapper/0 next_pid=0 next_prio=120
          <idle>-0     [000] d.h7 14186.690000: sched_wakeup: comm=tfm_b6bcf800 pid=1714 prio=35 success=1 target_cpu=000
          <idle>-0     [000] d..3 14186.690000: sched_switch: prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=tfm_b6bcf800 next_pid=1714 next_prio=35
    tfm_b6bcf800-1714  [000] d..3 14186.690000: sched_switch: prev_comm=tfm_b6bcf800 prev_pid=1714 prev_prio=35 prev_state=D|W ==> next_comm=swapper/0 next_pid=0 next_prio=120
          <idle>-0     [001] d.h3 14186.690000: sched_wakeup: comm=Player Aud Mixe pid=146 prio=35 success=1 target_cpu=001
          <idle>-0     [001] d..3 14186.690000: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=Player Aud Mixe next_pid=146 next_prio=35
 Player Aud Mixe-146   [001] d..3 14186.690000: sched_switch: prev_comm=Player Aud Mixe prev_pid=146 prev_prio=35 prev_state=D ==> next_comm=swapper/1 next_pid=0 next_prio=120
          <idle>-0     [001] d.h3 14186.690000: sched_wakeup: comm=Player Aud Mixe pid=146 prio=35 success=1 target_cpu=001
          <idle>-0     [001] d..3 14186.690000: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=Player Aud Mixe next_pid=146 next_prio=35
 Player Aud Mixe-146   [001] d..3 14186.690000: sched_switch: prev_comm=Player Aud Mixe prev_pid=146 prev_prio=35 prev_state=S ==> next_comm=swapper/1 next_pid=0 next_prio=120
          <idle>-0     [001] d.h3 14186.700000: sched_wakeup: comm=Player Aud Mixe pid=146 prio=35 success=1 target_cpu=001
          <idle>-0     [001] d..3 14186.700000: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=Player Aud Mixe next_pid=146 next_prio=35
  EventThread-110   [001] d..5 14190.100000: sched_wakeup: comm=SurfaceFlinger pid=103 prio=112 success=1 target_cpu=001
     EventThread-110   [001] d..3 14190.100000: sched_switch: prev_comm=EventThread prev_pid=110 prev_prio=111 prev_state=S ==> next_comm=SurfaceFlinger next_pid=103 next_prio=112
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: B|96|onMessageReceived
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: B|96|handleTransaction
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: B|96|doTransaction
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: E
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: E
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: B|96|handleMessageInvalidate
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: E
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: E
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: B|96|onMessageReceived
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: B|96|handleMessageRefresh
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: B|96|rebuildLayerStacks
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: B|96|computeVisibleRegions
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: E
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: E
  SurfaceFlinger-103   [001] ...1 14190.100000: tracing_mark_write: B|96|doComposition
  SurfaceFlinger-103   [001] d.h4 14190.100000: sched_wakeup: comm=surfaceflinger pid=96 prio=120 success=1 target_cpu=001
  SurfaceFlinger-103   [001] d..3 14190.100000: sched_switch: prev_comm=SurfaceFlinger prev_pid=103 prev_prio=112 prev_state=R ==> next_comm=surfaceflinger next_pid=96 next_prio=120

提前致谢!

【问题讨论】:

  • 也许不是您想要的,但有帮助吗?:developer.android.com/tools/help/systrace.html
  • 您是使用哪个命令生成上述日志的?我找不到生成包含“tracing_mark_write:B|”的行的命令和“tracing_mark_write:E”
  • atrace 命令是 Android shell 控制台 (adb) 中的“隐藏”命令。它通常由 systrace python 脚本调用。我通过手动执行 atrace 获得了这个日志。

标签: android linux perf ftrace systrace


【解决方案1】:

好吧,现在可以确定:格式属于ftrace工具。 Android atraceftrace 构建的扩展,以方便配置。

ftrace的官方文档显示,这种输出格式可以直接由它通过以下方式生成:

root@adroid:# echo 1 > /sys/kernel/debug/tracing/events/sched/sched_switch/enable
root@adroid:# echo 1 > /sys/kernel/debug/tracing/tracing_on
root@adroid:# cat /sys/kernel/debug/tracing/trace > mytracefile.txt
root@adroid:# echo 0 > /sys/kernel/debug/tracing/tracing_on
root@adroid:# echo 0 > /sys/kernel/debug/tracing/events/sched/sched_switch/enable

官方文档位于: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/trace/ftrace.txt

# cat trace
# tracer: nop
#
# entries-in-buffer/entries-written: 77/77   #P:8
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
          <idle>-0     [007] d...  2440.707395: sched_switch: prev_comm=swapper/7 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=snapshot-test-2 next_pid=2243 next_prio=120
 snapshot-test-2-2229  [002] d...  2440.707438: sched_switch: prev_comm=snapshot-test-2 prev_pid=2229 prev_prio=120 prev_state=S ==> next_comm=swapper/2 next_pid=0 next_prio=120
[...]

问候,

【讨论】:

    【解决方案2】:

    很棒的帖子,但是不要忘记安装调试文件系统,

    "mount -t debugfs none /sys/kernel/debug" or 
    "mount -o rw,remount -t debugfs none /sys/kernel/debug"
    

    否则你不会得到类似的东西

    “打开/sys/kernel/debug/tracing/options/overwrite时出错:没有这个 文件或目录"

    运行atrace时

    这里有一些更有用的信息http://rahulonblog.blogspot.se/2013/06/how-to-enable-debugfs-in-kernel.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-09
      • 1970-01-01
      • 1970-01-01
      • 2013-11-15
      • 2013-05-14
      • 1970-01-01
      • 2010-11-13
      • 1970-01-01
      相关资源
      最近更新 更多