ftrace:仅输出trace_printk()

时间:2022-11-24 16:52:27

Is it possible to dump only trace_printk() outputs in trace file? I mean filter out all functions in function tracer (or any other tracer).

是否可能仅在跟踪文件中转储trace_printk()输出?我的意思是过滤掉函数跟踪程序(或任何其他跟踪程序)中的所有函数。

1 个解决方案

#1


2  

In general, you can switch options off inside of the options directory, /sys/kernel/debug/tracing/options. Use ls to display all toggle-able options.

通常,您可以在options目录/sys/内核/调试/跟踪/选项中关闭选项。使用ls显示所有可切换选项。

# ls
annotate     context-info     funcgraph-abstime   funcgraph-overhead  func_stack_trace  hex             overwrite        record-cmd  sym-offset       trace_printk
bin          disable_on_free  funcgraph-cpu       funcgraph-overrun   function-fork     irq-info        printk-msg-only  sleep-time  sym-userobj      userstacktrace
blk_classic  display-graph    funcgraph-duration  funcgraph-proc      function-trace    latency-format  print-parent     stacktrace  test_nop_accept  verbose
block        event-fork       funcgraph-irqs

Toggle options via echo, i.e.,

切换选项通过echo,即,

echo -n "1" > /sys/kernel/debug/tracing/options/trace_printk

echo -n "1" > /sys/内核/调试/跟踪/选项/trace_printk

If you are trying to filter out any output that was not produced by trace_printk(), you would likely need to ensure that trace_printk() is the only option set.

如果您试图过滤掉trace_printk()不生成的任何输出,您可能需要确保trace_printk()是惟一的选项集。

It's always good to check out the kernel documentation when in doubt. There's also a great lwn article that helped me out when I was first learning ftrace called Secrets of the Ftrace function tracer, which includes some sections about filtering in general.

当有疑问时,检查内核文档总是好的。在我第一次学习ftrace的时候,有一篇很棒的文章帮助我解决了ftrace,叫做ftrace函数跟踪器的秘密。

#1


2  

In general, you can switch options off inside of the options directory, /sys/kernel/debug/tracing/options. Use ls to display all toggle-able options.

通常,您可以在options目录/sys/内核/调试/跟踪/选项中关闭选项。使用ls显示所有可切换选项。

# ls
annotate     context-info     funcgraph-abstime   funcgraph-overhead  func_stack_trace  hex             overwrite        record-cmd  sym-offset       trace_printk
bin          disable_on_free  funcgraph-cpu       funcgraph-overrun   function-fork     irq-info        printk-msg-only  sleep-time  sym-userobj      userstacktrace
blk_classic  display-graph    funcgraph-duration  funcgraph-proc      function-trace    latency-format  print-parent     stacktrace  test_nop_accept  verbose
block        event-fork       funcgraph-irqs

Toggle options via echo, i.e.,

切换选项通过echo,即,

echo -n "1" > /sys/kernel/debug/tracing/options/trace_printk

echo -n "1" > /sys/内核/调试/跟踪/选项/trace_printk

If you are trying to filter out any output that was not produced by trace_printk(), you would likely need to ensure that trace_printk() is the only option set.

如果您试图过滤掉trace_printk()不生成的任何输出,您可能需要确保trace_printk()是惟一的选项集。

It's always good to check out the kernel documentation when in doubt. There's also a great lwn article that helped me out when I was first learning ftrace called Secrets of the Ftrace function tracer, which includes some sections about filtering in general.

当有疑问时,检查内核文档总是好的。在我第一次学习ftrace的时候,有一篇很棒的文章帮助我解决了ftrace,叫做ftrace函数跟踪器的秘密。