Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools lib traceevent: Fix use of multiple options in processing field

Jiri Olsa reported that the scsi_dispatch_cmd_done event failed to parse
with:

Error: expected type 5 but read 4
Error: expected type 5 but read 4

The problem is with this part of the print_fmt:

__print_symbolic(((REC->result) >> 24) & 0xff, ...

The __print_symbolic() helper function's first parameter is the field to
use to determine what symbol to print based on the value of the result.
The parser can handle one operation, but it can not handle multiple
operations ('>>' and '&').

Add code to process all operations for the field argument for
__print_symbolic() as well as __print_flags().

Reported-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20131118142314.27ca334b@gandalf.local.home
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Steven Rostedt and committed by
Arnaldo Carvalho de Melo
eff2c92f 50a2740b

+21 -2
+21 -2
tools/lib/traceevent/event-parse.c
··· 1606 1606 static enum event_type 1607 1607 process_op(struct event_format *event, struct print_arg *arg, char **tok); 1608 1608 1609 + /* 1610 + * For __print_symbolic() and __print_flags, we need to completely 1611 + * evaluate the first argument, which defines what to print next. 1612 + */ 1613 + static enum event_type 1614 + process_field_arg(struct event_format *event, struct print_arg *arg, char **tok) 1615 + { 1616 + enum event_type type; 1617 + 1618 + type = process_arg(event, arg, tok); 1619 + 1620 + while (type == EVENT_OP) { 1621 + type = process_op(event, arg, tok); 1622 + } 1623 + 1624 + return type; 1625 + } 1626 + 1609 1627 static enum event_type 1610 1628 process_cond(struct event_format *event, struct print_arg *top, char **tok) 1611 1629 { ··· 2389 2371 goto out_free; 2390 2372 } 2391 2373 2392 - type = process_arg(event, field, &token); 2374 + type = process_field_arg(event, field, &token); 2393 2375 2394 2376 /* Handle operations in the first argument */ 2395 2377 while (type == EVENT_OP) ··· 2442 2424 goto out_free; 2443 2425 } 2444 2426 2445 - type = process_arg(event, field, &token); 2427 + type = process_field_arg(event, field, &token); 2428 + 2446 2429 if (test_type_token(type, token, EVENT_DELIM, ",")) 2447 2430 goto out_free_field; 2448 2431