aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/trace-event-parse.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-10-14 15:43:33 -0400
committerIngo Molnar <mingo@elte.hu>2009-10-15 04:42:35 -0400
commit91ff2bc191827f0d3f5ad0a433ff7df7d2dd9aee (patch)
treeb1ce2b9f026fc579e6ebf1a9724725f925750f5a /tools/perf/util/trace-event-parse.c
parent924a79af2cdee26a034b9bdce8c9c76995b5c901 (diff)
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.c27
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)
522 last_ch = ch; 522 last_ch = ch;
523 ch = __read_char(); 523 ch = __read_char();
524 buf[i++] = ch; 524 buf[i++] = ch;
525 } while (ch != quote_ch && last_ch != '\\'); 525 /* the '\' '\' will cancel itself */
526 if (ch == '\\' && last_ch == '\\')
527 last_ch = 0;
528 } while (ch != quote_ch || last_ch == '\\');
526 /* remove the last quote */ 529 /* remove the last quote */
527 i--; 530 i--;
528 goto out; 531 goto out;
@@ -2325,7 +2328,27 @@ static void pretty_print(void *data, int size, struct event *event)
2325 2328
2326 for (; *ptr; ptr++) { 2329 for (; *ptr; ptr++) {
2327 ls = 0; 2330 ls = 0;
2328 if (*ptr == '%') { 2331 if (*ptr == '\\') {
2332 ptr++;
2333 switch (*ptr) {
2334 case 'n':
2335 printf("\n");
2336 break;
2337 case 't':
2338 printf("\t");
2339 break;
2340 case 'r':
2341 printf("\r");
2342 break;
2343 case '\\':
2344 printf("\\");
2345 break;
2346 default:
2347 printf("%c", *ptr);
2348 break;
2349 }
2350
2351 } else if (*ptr == '%') {
2329 saveptr = ptr; 2352 saveptr = ptr;
2330 show_func = 0; 2353 show_func = 0;
2331 cont_process: 2354 cont_process: