tracing/ftrace: add the printk-msg-only option
authorFrederic Weisbecker <fweisbec@gmail.com>
Sat, 13 Dec 2008 19:18:13 +0000 (20:18 +0100)
committerIngo Molnar <mingo@elte.hu>
Tue, 16 Dec 2008 23:26:36 +0000 (00:26 +0100)
Impact: display ftrace_printk messages "as is"

By default, ftrace_printk() messages find their output with some other
informations like pid, caller, ...
Sometimes a developer just want to have the ftrace_printk left "as is", without
other information.

This is done by providing a default-off option called printk-msg-only.
To enable it, just do `echo printk-msg-only > /debugfs/tracing/trace_options`

Before the patch:

           <...>-2739  [000]   145.692153: __might_sleep: I'm an ftrace_printk msg in __might_sleep
           <...>-2739  [000]   145.692155: __might_sleep: I'm another ftrace_printk msg in __might_sleep

After the patch and the printk-msg-only option enabled:

I'm an ftrace_printk msg in __might_sleep
I'm another ftrace_printk msg in __might_sleep

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/trace.c
kernel/trace/trace.h

index 639344a4d3a2ddc1f4246fefbad9383e38e5f87f..1a3d6b329782de4587d2bacd544e07fa7cb7f2c8 100644 (file)
@@ -287,6 +287,7 @@ static const char *trace_options[] = {
        "annotate",
        "userstacktrace",
        "sym-userobj",
+       "printk-msg-only",
        NULL
 };
 
@@ -2265,6 +2266,25 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
        return TRACE_TYPE_HANDLED;
 }
 
+static enum print_line_t print_printk_msg_only(struct trace_iterator *iter)
+{
+       struct trace_seq *s = &iter->seq;
+       struct trace_entry *entry = iter->ent;
+       struct print_entry *field;
+       int ret;
+
+       trace_assign_type(field, entry);
+
+       ret = trace_seq_printf(s, field->buf);
+       if (!ret)
+               return TRACE_TYPE_PARTIAL_LINE;
+
+       if (entry->flags & TRACE_FLAG_CONT)
+               trace_seq_print_cont(s, iter);
+
+       return TRACE_TYPE_HANDLED;
+}
+
 static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
 {
        struct trace_seq *s = &iter->seq;
@@ -2345,6 +2365,11 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
                        return ret;
        }
 
+       if (iter->ent->type == TRACE_PRINT &&
+                       trace_flags & TRACE_ITER_PRINTK &&
+                       trace_flags & TRACE_ITER_PRINTK_MSGONLY)
+               return print_printk_msg_only(iter);
+
        if (trace_flags & TRACE_ITER_BIN)
                return print_bin_fmt(iter);
 
index f07c246dd73dab7b283048df72bce71b36b34f4d..fc75dce7a6645edfafdb612be7ff313d6ea8cf6e 100644 (file)
@@ -578,7 +578,8 @@ enum trace_iterator_flags {
        TRACE_ITER_BRANCH               = 0x1000,
        TRACE_ITER_ANNOTATE             = 0x2000,
        TRACE_ITER_USERSTACKTRACE       = 0x4000,
-       TRACE_ITER_SYM_USEROBJ          = 0x8000
+       TRACE_ITER_SYM_USEROBJ          = 0x8000,
+       TRACE_ITER_PRINTK_MSGONLY       = 0x10000
 };
 
 /*