electro
electro

Reputation: 961

Using FTRACE for loadable linux driver module

I am trying to use FTRACE for tracing and getting function_graph on a loadable driver module.
But, somehow, I did not see any functions in that module being traced.

Here is what I did (I had the kernel configured to have FTRACE already in the menuconfig)

#echo function_graph > /sys/kernel/debug/tracing/current_tracer
#cat /sys/kernel/debug/tracing/current_tracer
function_graph
#echo 1 > tracing_on
#insmod my_module.ko
#echo 0 > tracing_on
#cat trace

Nothing in the trace file has any functions inside my_module.ko

Do I need to enable some compiler flags when compiling my_module.c? Any ideas what I need to do?

Thanks!

Upvotes: 2

Views: 7218

Answers (2)

Harry Pan
Harry Pan

Reputation: 1

Try this command:

echo $$ >> /sys/kernel/debug/tracing/set_ftrace_pid

Upvotes: 0

Federico
Federico

Reputation: 3892

I suspect that you don't see any function at all being traced; usually the dynamic ftrace is enable, so you have to manually choose what you want to trace.

cat available_filter_functions

It shows you all function that you can trace (grep for what you want just to be sure that is there). Of course, your module's function are visible only after module loading. So you load the module and then you add your function.

insmod mymodule.ko
echo my_function >> set_ftrace_filter

You can find all the details in the kernel documentation about ftrace

Upvotes: 1

Related Questions