How do I get a complete graph of calls starting from a specific function using ftrace in Linux?

I want to track a specific function with ftrace, but with all further calls to that function.

I was able to run ftrace with a filter on my desired function, but now this only shows me this one specific function.

So my question is, how to print all functions called from a specific function, functions called by those functions, etc.?

+3


source to share


2 answers


I was able to resolve the issue. Here's a solution using kmalloc as an example.

cd /sys/kernel/debug/tracing
echo kmalloc > set_graph_function
echo function_graph > current_tracer
cat trace

      



Before using function_graph, be sure to reset all filters (e.g. set_ftrace_filter).

+4


source


You can also set max_graph_depth and get more graph depth of the functions.

The following steps will help in generating a functional graph of the selected linux function.

1. cd /sys/kernel/debug/tracing
2. cat /dev/null >  trace
3. echo generic_make_request > set_graph_function
4. echo 10 > max_graph_depth
5. echo function_graph > current_tracer
6. echo 1 > tracing_on
7. dd if=/dev/sddk of=~/test bs=512 count=5
8. cp trace ~/dd_trace_depth10
9. echo 0 > tracing_on
10. echo > set_graph_function
11. echo 0 > max_graph_depth
12. cat /dev/null >  trace

      

Enable tracing: In this example, I have selected the filter function as "generic_make_request" . So step 3 sets the graph function to the "generic_make_request" linux function. Then we set the chart depth to 10 in step 4. Step 5 sets the current indicator to "function_graph". After all of them are installed, we will enable tracing.



Action: Now we perform the action for which we need a line trace. In this example, we are doing I / O using the dd command. This command will hit the generic_make_request function and the file / sys / kernel / debug / tracing / trace will be filled with the function graph.

Disable tracing: Steps 9, 10, 11 will disable tracing

Refer: http://sklinuxblog.blogspot.in/2014_12_01_archive.html

+4


source







All Articles