欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

ftrace:追踪进程cmd的脚本

最编程 2024-08-13 21:13:22
...
#!/bin/bash DPATH="/sys/kernel/debug/tracing" ## shell pid PID=$$ [ `id -u` -ne 0 ] && { echo "needs to be root" ; exit 1; } [ -z $1 ] && { echo "needs process name as argument" ; exit 1; } mount | grep -i debugfs &> /dev/null [ $? -ne 0 ] && { echo "debugfs not mounted, mount it first"; exit 1; } # clear existing trace data echo nop > $DPATH/current_tracer # set function_graph tracer echo function_graph > $DPATH/current_tracer # write current process id to set_ftrace_pid file next will trace echo $PID > $DPATH/set_ftrace_pid # start the tracing echo 1 > $DPATH/tracing_on # execute the process # $* all parameter list exec $* # stop the tracing echo 0 > tracing_on

推荐阅读