Debugging Linux Kernel using ftrace Part4 - Tracing a specific Process

With ftrace, we can trace kernel calls only related to a specific process by echoing pid in the set_ftrace_pid file.

Steps to trace kernel calls of a particular PID:

1. Disable tracing by echoing "nop" to "current_tracer" file
$ echo "nop" > current_tracer
$ cat current_tracer 
nop

2. Echo the pid of the process which you want to trace in "set_ftrace_pid" file. 2588 is the pid of "gnome-terminal"

$ echo "2588" > set_ftrace_pid
$ cat set_ftrace_pid 
2588

3. Enable either "function" or "function_tracer" by echoing into "current_tracer" file
$ echo "function_graph" > current_tracer 

4. You can now "cat trace" to see what all kernel functions are being executed by the gnome-terminal.



You can also find out what all kernel function calls being executed by the running bash 

$ echo "$$" > set_ftrace_pid

The "$$" will convert into the PID of the bash in which all the commands we are executing.




Comments

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig