ftrace isn’t a program exactly – you don’t just run
If you read Debugging the kernel using Ftrace it starts out by telling you to
cd /sys/kernel/debug/tracing and then do various filesystem manipulations.
For me this is way too annoying – a simple example of using ftrace this way is something like this
This filesystem interface to the tracing system (“put values in these magic files and things will happen”) seems theoretically possible to use but really not my preference.
Luckily, team ftrace also thought this interface wasn’t that user friendly and so there is an easier-to-use interface called trace-cmd!!! trace-cmd is a normal program with command line arguments. We’ll use that! I found an intro to trace-cmd on LWN at trace-cmd: A front-end for Ftrace.
sudo apt-get install trace-cmd -y
trace-cmd record --help
How to know what functions you can trace?
If you run
sudo trace-cmd list -f you’ll get a list of all the functions you can trace.
sudo trace-cmd record -p function -l __do_fault
sudo trace-cmd record -p function -P 25314 # record for PID 25314
sudo trace-cmd record -p function_graph -P 25314
sudo trace-cmd record -e sched:sched_switch
trace-cmd report -F filter