diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-10-14 15:43:33 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-15 10:42:35 +0200 |
commit | 91ff2bc191827f0d3f5ad0a433ff7df7d2dd9aee (patch) | |
tree | b1ce2b9f026fc579e6ebf1a9724725f925750f5a /tools/perf/util/trace-event-parse.c | |
parent | 924a79af2cdee26a034b9bdce8c9c76995b5c901 (diff) | |
download | blackbird-obmc-linux-91ff2bc191827f0d3f5ad0a433ff7df7d2dd9aee.tar.gz blackbird-obmc-linux-91ff2bc191827f0d3f5ad0a433ff7df7d2dd9aee.zip |
perf tools: Fix backslash processing on trace print formats
The handling of backslashes was broken. It would stop parsing
when encountering one. Also, '\n', '\t', '\r' and '\\' were not
converted.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <20091014194357.521974680@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/trace-event-parse.c')
-rw-r--r-- | tools/perf/util/trace-event-parse.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index a05c7144aded..2b75ec2f57e8 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -522,7 +522,10 @@ static enum event_type __read_token(char **tok) last_ch = ch; ch = __read_char(); buf[i++] = ch; - } while (ch != quote_ch && last_ch != '\\'); + /* the '\' '\' will cancel itself */ + if (ch == '\\' && last_ch == '\\') + last_ch = 0; + } while (ch != quote_ch || last_ch == '\\'); /* remove the last quote */ i--; goto out; @@ -2325,7 +2328,27 @@ static void pretty_print(void *data, int size, struct event *event) for (; *ptr; ptr++) { ls = 0; - if (*ptr == '%') { + if (*ptr == '\\') { + ptr++; + switch (*ptr) { + case 'n': + printf("\n"); + break; + case 't': + printf("\t"); + break; + case 'r': + printf("\r"); + break; + case '\\': + printf("\\"); + break; + default: + printf("%c", *ptr); + break; + } + + } else if (*ptr == '%') { saveptr = ptr; show_func = 0; cont_process: |