概述
Ftrace查看函数向上的调用栈
1 方法一:使用function tracer
cat ./available_filter_functions | grep vfs_open
cat ./available_filter_functions | grep bio_add_page
#! /bin/bash
CURRENT_DIR=$(pwd)
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
TRACE_DIR='/sys/kernel/debug/tracing/'
cd ${TRACE_DIR}
echo 0 > ./tracing_on && echo > ./trace
echo bio_add_page > ./set_ftrace_filter
echo vfs_open >> ./set_ftrace_filter
echo 1 > ./options/func_stack_trace
echo function > ./current_tracer # turn on
echo 1 > ./tracing_on
${SCRIPT_DIR}/run_test.sh && cp ./trace ${SCRIPT_DIR}/trace_test.log
echo 0 > ./tracing_on
echo nop > ./current_tracer # turn off
echo 0 > ./options/func_stack_trace
echo !bio_add_page >> ./set_ftrace_filter
echo !vfs_open >> ./set_ftrace_filter
cat ${SCRIPT_DIR}/trace_test.log
cd ${CURRENT_DIR}
exec "$@"
2 方法二:使用kprobe event
cat ./available_filter_functions | grep vfs_open
# echo 'p vfs_open' > ./kprobe_events
## cat ./kprobe_events
### p:kprobes/p_vfs_open_0 vfs_open
#! /bin/bash
CURRENT_DIR=$(pwd)
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
TRACE_DIR='/sys/kernel/debug/tracing/'
cd ${TRACE_DIR}
echo nop > current_tracer
echo 0 > ./tracing_on && echo > ./trace
echo 'p vfs_open' > ./kprobe_events
echo 1 > ./options/stacktrace
# or
# echo 'stacktrace' > ./events/kprobes/p_vfs_open_0/trigger
echo 1 > ./events/kprobes/p_vfs_open_0/enable # turn on
echo 1 > ./tracing_on
${SCRIPT_DIR}/run_test.sh && cp ./trace ${SCRIPT_DIR}/trace_test.log
echo 0 > ./tracing_on
echo 0 > ./events/kprobes/p_vfs_open_0/enable # turn off
# echo '!stacktrace' > ./events/kprobes/p_vfs_open_0/trigger
echo 0 > ./options/stacktrace
echo '-:p_vfs_open_0' >> kprobe_events
cat ${SCRIPT_DIR}/trace_test.log
cd ${CURRENT_DIR}
exec "$@"
3 方式三:一招制胜
#! /bin/bash
CURRENT_DIR=$(pwd)
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
TRACE_DIR='/sys/kernel/debug/tracing/'
cd ${TRACE_DIR}
echo nop > current_tracer
echo 0 > ./tracing_on && echo > ./trace
echo 'blk_update_request:stacktrace' > ./set_ftrace_filter
echo 1 > ./tracing_on
${SCRIPT_DIR}/run_test.sh && cp ./trace ${SCRIPT_DIR}/trace_test.log
echo 0 > ./tracing_on
echo "!blk_update_request:stacktrace" > ./set_ftrace_filter
cat ${SCRIPT_DIR}/trace_test.log
cd ${CURRENT_DIR}
exec "$@"
4 参考资料
- 谢欢, ftrace公开课
最后
以上就是尊敬自行车为你收集整理的Ftrace查看函数向上的调用栈Ftrace查看函数向上的调用栈的全部内容,希望文章能够帮你解决Ftrace查看函数向上的调用栈Ftrace查看函数向上的调用栈所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复