ftrace 进程cmd 跟踪脚本

复制代码
#!/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 时  内核运行函数 调用 

from: https://www.codenong.com/cs106475776/

posted @   codestacklinuxer  阅读(173)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
历史上的今天:
2020-02-26 nginx&http 第四章 ngx http代理 upstream流程图
2020-02-26 nginx&http 第四章 ngx http代理 && 转载
点击右上角即可分享
微信分享提示