首页 > 系统服务 > 详细

ftrace 进程自动脚本

时间:2021-02-26 19:27:59      阅读:36      评论:0      收藏:0      [点我收藏+]
#!/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

 上述为ftrace 某一个process的基本脚本 
./trace-process.sh   ifconfig eth20  down   
就可以看到 ifconfig eth20 down 时  内核运行函数 调用 

 

ftrace 进程自动脚本

原文:https://www.cnblogs.com/codestack/p/14453293.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!