]> git.karo-electronics.de Git - linux-beck.git/commitdiff
tracing: add __print_symbolic to trace events
authorSteven Rostedt <srostedt@redhat.com>
Wed, 20 May 2009 23:21:47 +0000 (19:21 -0400)
committerFrederic Weisbecker <fweisbec@gmail.com>
Tue, 26 May 2009 18:31:50 +0000 (20:31 +0200)
This patch adds __print_symbolic which is similar to __print_flags but
works for an enumeration type instead. That is, there is only a one to one
mapping between the values and the symbols. When a match is made, then
it is printed, otherwise the hex value is outputed.

[ Impact: add interface for showing symbol names in events ]

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
include/linux/ftrace_event.h
include/trace/ftrace.h
kernel/trace/trace_output.c

index 4b58cf1a11c2cee20ce44de69e77cda056e6d4c8..bbf40f624fc8dcaeb99ce0e1c6de052d6b03be08 100644 (file)
@@ -20,6 +20,9 @@ const char *ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
                                   unsigned long flags,
                                   const struct trace_print_flags *flag_array);
 
+const char *ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
+                                    const struct trace_print_flags *symbol_array);
+
 /*
  * The trace entry - the most basic unit of tracing. This is what
  * is printed in the end as a single line in the trace output, such as:
index 22c94719c5695cf782c5ddbdc68d5533aba4ac9c..87fc227c6fbe53154dfdd82576b32bfb430fe9ba 100644 (file)
                ftrace_print_flags_seq(p, delim, flag, flags);          \
        })
 
+#undef __print_symbolic
+#define __print_symbolic(value, symbol_array...)                       \
+       ({                                                              \
+               static const struct trace_print_flags symbols[] =       \
+                       { symbol_array, { -1, NULL }};                  \
+               ftrace_print_symbols_seq(p, value, symbols);            \
+       })
+
 #undef TRACE_EVENT
 #define TRACE_EVENT(call, proto, args, tstruct, assign, print)         \
 enum print_line_t                                                      \
index a4840c260c8919452590b643fe704368e32178a3..c12d95db2f562383759ac059d02a8b5bc80a270a 100644 (file)
@@ -251,6 +251,31 @@ ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
        return p->buffer;
 }
 
+const char *
+ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
+                        const struct trace_print_flags *symbol_array)
+{
+       int i;
+
+       trace_seq_init(p);
+
+       for (i = 0;  symbol_array[i].name; i++) {
+
+               if (val != symbol_array[i].mask)
+                       continue;
+
+               trace_seq_puts(p, symbol_array[i].name);
+               break;
+       }
+
+       if (!p->len)
+               trace_seq_printf(p, "0x%lx", val);
+               
+       trace_seq_putc(p, 0);
+
+       return p->buffer;
+}
+
 #ifdef CONFIG_KRETPROBES
 static inline const char *kretprobed(const char *name)
 {