Debugging Linux Kernel using ftrace Part7 - Script to find out what all kernel functions are executed by a particular command

I wrote a script to find out what all kernel functions are being called for a particular linux command we execute.

Script:


#!/bin/bash
# Mount the tracefs
mount -t tracefs nodev /sys/kernel/tracing
# Disable tracing
echo "0" > /sys/kernel/tracing/tracing_on
# set the current tracer to nop
echo "nop" > /sys/kernel/tracing/current_tracer
# clear the existing trace
echo > /sys/kernel/tracing/trace
# set the current tracer to function_graph
echo "function_graph" > /sys/kernel/tracing/current_tracer
# Enable tracing
echo "1" > /sys/kernel/tracing/tracing_on
# Execute the command
sh -c 'echo $$ > /sys/kernel/tracing/set_ftrace_pid;echo "1" > /sys/kernel/tracing/tracing_on;exec 'acpi -V';echo "0" > /sys/kernel/tracing/tracing_on'
# Cat the trace file into temporary file
cat /sys/kernel/tracing/trace > /tmp/mycommand_trace

Output: 


Comments

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

PR, PN and PV Variable in Yocto