I have limited experience with ftrace
, although I have used it for for function stack traces and latency issues. (People with more experience can possibly suggest) Its pretty much the same experience using trace-cmd
and kernelshark
.
However, if you want to trace syscalls, function params, kernel APIs and return values etc. within the kernel space a better choice would be to go with systemtap
. It has an extensive list of Samples & Doc which is good for function call tracing, argument values passed etc. You may want to look at some samples and taylor them to your requirement. See general/para-callgraph-verbose.stp
and process/sleeptime.stp
"
general/para-callgraph-verbose.stp - Callgraph Tracing with Verbose Arguments
keywords: TRACE CALLGRAPH
Print a timed per-thread microsecond-timed callgraph, complete with pretty-printed function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger.
stap para-callgraph-verbose.stp 'kernel.function("*@fs/proc*.c")' \
'kernel.function("vfs_read")' -c "cat /proc/sys/vm/* || true"
process/strace.stp - Trace system calls
keywords: _BEST PROCESS SYSCALL
The script loosely emulates strace, when applied to individual processes or hierarchies (via -c/-x), or the entire system (without -c/-x). A few output configuration parameters may be set with -G.
stap strace.stp -c "sleep 1"
"
Note you will need to install the correct version of the debug kernel
and kernel-devel
rpms/deb for stap
to work correctly. For this just use stap-prep
and install the dependencies shown depending on the flavour you are on.
strace
. – Cardiovascular