Skip to content

Commit

Permalink
perf tools: Fix backslash processing on trace print formats
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steven Rostedt authored and Ingo Molnar committed Oct 15, 2009
1 parent 924a79a commit 91ff2bc
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions tools/perf/util/trace-event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 91ff2bc

Please sign in to comment.