简体   繁体   English

使用ftrace的android内核函数跟踪?

[英]android kernel function trace using ftrace?

Want to use the ftrace when we want to trace the kernel function of gs4. 当我们要跟踪gs4的内核功能时要使用ftrace。

So, I accepted the contents of here. 因此,我接受了这里的内容。

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

mount -t debugfs nodev /sys/kernel/debug

When you enter the command, to come out as follows. 输入命令时,显示如下。

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

Also, 也,

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

To come out like this. 这样出来。

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

Last update time will change, it is not possible to change the contents of the currnet_tracer. 上次更新时间将更改,无法更改currnet_tracer的内容。

Of course, come out as follows. 当然,如下所示。

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
#              | |       |   ||||       |         |

I can not change the currnet_tracer. 我无法更改currnet_tracer。 tracing_on is capable of change. tracing_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 #

I can use the atrace, I come out information according to the corresponding options as follows, want to trace the call to the kernel function. 我可以使用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

....

I want to know how to change the current_tracer and how to mount by using the debugfs. 我想知道如何更改current_tracer以及如何使用debugfs进行安装。

To receive and grateful to help. 能够得到感谢和帮助。

Thank! 谢谢!

You miss the point of available_tracers option under /sys/kernel/debug/tracing, which shows what are the tracing features available from kernel. 您会错过/ sys / kernel / debug / tracing下的available_tracers选项的要点,该选项显示了内核中可用的跟踪功能。 To see the list of available tracer do - 要查看可用的跟踪器列表,请执行以下操作-

      cat /sys/kernel/debug/tracing/available_tracers

This will show you all the tracers available. 这将向您显示所有可用的跟踪器。 Now, if you found "function" then you'll be able to trace kernel functions otherwise not. 现在,如果找到了“函数”,那么您将能够跟踪内核函数,否则将无法跟踪。

If you have function tracer option available to activate it do the following - 如果您具有可用的功能跟踪器选项,请执行以下操作-

    echo function > /sys/kernel/debug/tracing/current_tracer
    echo 1 > /sys/kernel/debug/tracing/tracing_on

Now, you'll find the tracing output via /sys/kernel/debug/tracing/trace . 现在,您将通过/ sys / kernel / debug / tracing / trace找到跟踪输出。 To disable the tracing do 禁用跟踪

   echo 0 > /sys/kernel/debug/tracing/tracing_on
   echo nop > /sys/kernel/debug/tracing/current_tracer

So, the main requirement of changing the current tracer is, that feature must have to be available, which can be found via current_tracer. 因此,更改当前跟踪器的主要要求是,该功能必须必须可用,可以通过current_tracer找到。

You maybe better use trace-cmd to do such things, it's much easier then print those trace in console. 您也许最好使用trace-cmd来执行这些操作,然后在控制台中打印这些跟踪会容易得多。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM