根据README
中的文件/sys/kernel/debug/tracing/README
,执行操作echo 1 > tracing_on
应该是启用跟踪的快速方法。无论我(以 root 身份)执行多少次,in 中的值tracing_on
仍然保持为 0。这是为什么呢?我怎样才能进一步调试这个?中没有输出dmesg
tracing mini-HOWTO:
# echo 0 > tracing_on : quick way to disable tracing
# echo 1 > tracing_on : quick way to re-enable tracing
Important files:
trace - The static contents of the buffer
To clear the buffer write into this file: echo > trace
trace_pipe - A consuming read to see the contents of the buffer
current_tracer - function and latency tracers
答案1
为了让这个工作正常进行,我首先必须说出要追踪什么!为了跟踪函数调用,我这样做了:
sudo -s # need to be root to be able to look inside /sys/kernel/debug
cd /sys/kernel/debug/tracing
echo function > current_tracer # trace function calls
echo SyS_inotify_add_watch > set_ftrace_filter # limit what to trace
这样做,隐式地将跟踪标志设置为打开,如下所示
cat tracing_on
1
现在您也可以禁用它
echo 0 > tracing_on