1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#!/bin/sh
if [ `whoami` != root ]
then
echo you need to run this script as root
exit 1
fi
mount -t debugfs none /sys/kernel/debug 2>/dev/null
cd /sys/kernel/debug/tracing
start()
{
echo 50000 > buffer_size_kb
echo nop > current_tracer
# exemple for also tracing all function starting with hsi:
# echo function > current_tracer
# echo hsi* >> set_ftrace_filter
echo > set_event
(
while read i
do
echo $i >> set_event
done
) <<EOF
sched:sched_wakeup
sched:sched_switch
timer:timer_init
timer:timer_start
timer:timer_expire_entry
timer:timer_expire_exit
timer:hrtimer_start
timer:hrtimer_expire_entry
timer:hrtimer_expire_exit
timer:itimer_expire
workqueue:workqueue_execution
workqueue:workqueue_execution_end
workqueue:workqueue_execute
workqueue:workqueue_execute_end
power:*
irq:*
EOF
echo >trace
echo 1 >tracing_enabled
}
stop()
{
echo >set_event
echo 0 >tracing_enabled
output=~/trace`date +%y-%m-%d-%H-%M-%S`.txt.lzma
cat trace | lzma > $output
echo trace written to $output
}
COMMAND="$1"
case $COMMAND in
start|stop)
$COMMAND
;;
*)
echo "usage: $0 [start|stop]"
;;
esac
|