aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-08-01 12:26:41 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-14 04:35:19 -0400
commitdd0e545f061f90099a3dcc13aa77e29c6295cf23 (patch)
tree91842e81cacd2ae785bf14b96f3f65af96985658 /include
parent2e2ca155cd2213b4f398031180fb3d399d5b7db9 (diff)
ftrace: printk formatting infrastructure
This patch adds a feature that can help kernel developers debug their code using ftrace. int ftrace_printk(const char *fmt, ...); This records into the ftrace buffer using printf formatting. The entry size in the buffers are still a fixed length. A new type has been added that allows for more entries to be used for a single recording. The start of the print is still the same as the other entries. It returns the number of characters written to the ftrace buffer. For example: Having a module with the following code: static int __init ftrace_print_test(void) { ftrace_printk("jiffies are %ld\n", jiffies); return 0; } Gives me: insmod-5441 3...1 7569us : ftrace_print_test: jiffies are 4296626666 for the latency_trace file and: insmod-5441 [03] 1959.370498: ftrace_print_test jiffies are 4296626666 for the trace file. Note: Only the infrastructure should go into the kernel. It is to help facilitate debugging for other kernel developers. Calls to ftrace_printk is not intended to be left in the kernel, and should be frowned upon just like scattering printks around in the code. But having this easily at your fingertips helps the debugging go faster and bugs be solved quicker. Maybe later on, we can hook this with markers and have their printf format be sucked into ftrace output. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include')
-rw-r--r--include/linux/ftrace.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 6b232a2460c0..f53b975e32fa 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -157,9 +157,18 @@ static inline void __ftrace_enabled_restore(int enabled)
157#ifdef CONFIG_TRACING 157#ifdef CONFIG_TRACING
158extern void 158extern void
159ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); 159ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
160# define ftrace_printk(x...) __ftrace_printk(_THIS_IP_, x)
161extern int
162__ftrace_printk(unsigned long ip, const char *fmt, ...)
163 __attribute__ ((format (printf, 2, 3)));
160#else 164#else
161static inline void 165static inline void
162ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } 166ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
167static inline int
168ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)))
169{
170 return 0;
171}
163#endif 172#endif
164 173
165#ifdef CONFIG_FTRACE_MCOUNT_RECORD 174#ifdef CONFIG_FTRACE_MCOUNT_RECORD
@@ -173,4 +182,5 @@ ftrace_init_module(unsigned long *start, unsigned long *end) { }
173static inline void ftrace_release(void *start, unsigned long size) { } 182static inline void ftrace_release(void *start, unsigned long size) { }
174#endif 183#endif
175 184
185
176#endif /* _LINUX_FTRACE_H */ 186#endif /* _LINUX_FTRACE_H */