diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2008-08-01 12:26:41 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-14 04:35:19 -0400 |
commit | dd0e545f061f90099a3dcc13aa77e29c6295cf23 (patch) | |
tree | 91842e81cacd2ae785bf14b96f3f65af96985658 /kernel/trace/trace.h | |
parent | 2e2ca155cd2213b4f398031180fb3d399d5b7db9 (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 'kernel/trace/trace.h')
-rw-r--r-- | kernel/trace/trace.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 6ddd6a6556cf..50b6d7a6f01a 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -13,7 +13,9 @@ enum trace_type { | |||
13 | TRACE_FN, | 13 | TRACE_FN, |
14 | TRACE_CTX, | 14 | TRACE_CTX, |
15 | TRACE_WAKE, | 15 | TRACE_WAKE, |
16 | TRACE_CONT, | ||
16 | TRACE_STACK, | 17 | TRACE_STACK, |
18 | TRACE_PRINT, | ||
17 | TRACE_SPECIAL, | 19 | TRACE_SPECIAL, |
18 | TRACE_MMIO_RW, | 20 | TRACE_MMIO_RW, |
19 | TRACE_MMIO_MAP, | 21 | TRACE_MMIO_MAP, |
@@ -61,6 +63,14 @@ struct stack_entry { | |||
61 | }; | 63 | }; |
62 | 64 | ||
63 | /* | 65 | /* |
66 | * ftrace_printk entry: | ||
67 | */ | ||
68 | struct print_entry { | ||
69 | unsigned long ip; | ||
70 | char buf[]; | ||
71 | }; | ||
72 | |||
73 | /* | ||
64 | * The trace field - the most basic unit of tracing. This is what | 74 | * The trace field - the most basic unit of tracing. This is what |
65 | * is printed in the end as a single line in the trace output, such as: | 75 | * is printed in the end as a single line in the trace output, such as: |
66 | * | 76 | * |
@@ -77,6 +87,7 @@ struct trace_field { | |||
77 | struct ctx_switch_entry ctx; | 87 | struct ctx_switch_entry ctx; |
78 | struct special_entry special; | 88 | struct special_entry special; |
79 | struct stack_entry stack; | 89 | struct stack_entry stack; |
90 | struct print_entry print; | ||
80 | struct mmiotrace_rw mmiorw; | 91 | struct mmiotrace_rw mmiorw; |
81 | struct mmiotrace_map mmiomap; | 92 | struct mmiotrace_map mmiomap; |
82 | }; | 93 | }; |