2

gs4のカーネル機能をトレースしたいときにftraceを使いたい。

というわけで、こちらの内容を了承しました。

http://www.linuxforu.com/2010/11/kernel-tracing-with-ftrace-part-1/

mount -t debugfs nodev /sys/kernel/debug

コマンドを入力すると、以下のように出てきます。

root@android:/sys/kernel/debug/tracing # mount -t debugfs nodev /nodev /sys/kernel/debug
mount: Device or resource busy

また、

root@android:/sys/kernel/debug/tracing # cat current_tracer
nop
root@android:/sys/kernel/debug/tracing # echo function > current_tracer
root@android:/sys/kernel/debug/tracing # cat current_tracer
nop

こんなに出てくるなんて。

root@android:/sys/kernel/debug/tracing # ls -al current_tracer
-rw-r--r-- root     root            0 2013-08-27 20:32 current_tracer

最終更新時刻が変更されます。currnet_tracer の内容を変更することはできません。

もちろん、次のように出てきます。

root@android:/sys/kernel/debug/tracing # cat trace
# tracer: nop
#
# entries-in-buffer/entries-written: 0/0   #P:1
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |

currnet_tracer を変更できません。trace_on は変更可能です。

root@android:/sys/kernel/debug/tracing # cat tracing_on
0
root@android:/sys/kernel/debug/tracing # echo 1 > tracing_on
root@android:/sys/kernel/debug/tracing # cat tracing_on
1
root@android:/sys/kernel/debug/tracing #

atrace を使えば、以下のように対応するオプションに応じた情報が出てくるので、カーネル関数の呼び出しをトレースしたい。

root@android:/sys/kernel/debug/tracing # atrace -s -w capturing trace < /test/trace.txt
root@android:/sys/kernel/debug/tracing # cat /test/trace.txt
capturing trace... done
TRACE:
# tracer: nop
#
# entries-in-buffer/entries-written: 532/532   #P:1
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
          atrace-22948 [000] ...2 623726.157067: sched_switch: prev_comm=atrace prev_pid=22948 prev_prio=120 prev_state=S ==> next_comm=AsyncTask #2 next_pid=21620 next_prio=130

....

current_tracer の変更方法と debugfs を使用したマウント方法を知りたいです。

助けを受け取り、感謝すること。

感謝!

4

2 に答える 2

1

そのようなことを行うには、trace-cmd を使用する方がよいでしょう。これらのトレースをコンソールに出力する方がはるかに簡単です。

http://www.omappedia.com/wiki/Installing_and_Using_Ftrace#Using_FTrace_with_Trace-cmd

于 2013-08-28T07:02:15.287 に答える