Ftrace
http://www.uini.net/2010/06/linux-kernel-debug-using-the-ftrace-part-3.html
http://www.uini.net/2010/06/linux-kernel-debug-using-the-ftrace-part-2.html
高级点的使用技巧:
Secrets of the Ftrace function tracer
http://lwn.net/Articles/370423/
Debugging the kernel using Ftrace
http://lwn.net/Articles/365835/
http://lwn.net/Articles/366796/
一次打多个补丁:
$ for p in ARM_ftrace_enable_dynamic_ftrace/*; do patch -p1 < $p ; done
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 13e13d4..e10519f 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -124,7 +124,7 @@
if FTRACE
config FUNCTION_TRACER
bool "Kernel Function Tracer"
depends on HAVE_FUNCTION_TRACER
- select FRAME_POINTER
+ select FRAME_POINTER if (!ARM_UNWIND)
select KALLSYMS
select GENERIC_TRACER
select CONTEXT_SWITCH_TRACER
revert 上面的补丁即可解决下面的错误:
#error Ftrace requires CONFIG_FRAME_POINTER=y with GCC older than 4.4.0 .
# echo soc_pcm_open > set_ftrace_filter
# cat set_ftrace_filter
soc_pcm_open
# echo * > set_ftrace_filter
# cat set_ftrace_filter
#### all functions enabled ####
# cat set_ftrace_filter
#### all functions enabled ####
soc_pcm_open:traceon:unlimited
# echo '!soc_pcm_open:traceon' > set_ftrace_filter
# cat set_ftrace_filter
#### all functions enabled ####
function:command[:count]
This will execute the command at the start of the function . The command is either traceon or traceoff , and an optional count can be added to have the command only execute a given number of times. If the count is left off (including the leading colon) then the command will be executed every time the function is called.
# echo 1 > tracing_on (traceon )
# echo 0 > tracing_on (traceoff )
There are two functions that work well inside the kernel:
tracing_on() and tracing_off() . These two act just like
echoing "1" or "0" respectively into the tracing_on file .