Skip to content

Commit

Permalink
tools lib traceevent: Fix use of multiple options in processing field
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steven Rostedt authored and Arnaldo Carvalho de Melo committed Nov 19, 2013
1 parent 50a2740 commit eff2c92
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,24 @@ process_arg(struct event_format *event, struct print_arg *arg, char **tok)
static enum event_type
process_op(struct event_format *event, struct print_arg *arg, char **tok);

/*
* For __print_symbolic() and __print_flags, we need to completely
* evaluate the first argument, which defines what to print next.
*/
static enum event_type
process_field_arg(struct event_format *event, struct print_arg *arg, char **tok)
{
enum event_type type;

type = process_arg(event, arg, tok);

while (type == EVENT_OP) {
type = process_op(event, arg, tok);
}

return type;
}

static enum event_type
process_cond(struct event_format *event, struct print_arg *top, char **tok)
{
Expand Down Expand Up @@ -2371,7 +2389,7 @@ process_flags(struct event_format *event, struct print_arg *arg, char **tok)
goto out_free;
}

type = process_arg(event, field, &token);
type = process_field_arg(event, field, &token);

/* Handle operations in the first argument */
while (type == EVENT_OP)
Expand Down Expand Up @@ -2424,7 +2442,8 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok)
goto out_free;
}

type = process_arg(event, field, &token);
type = process_field_arg(event, field, &token);

if (test_type_token(type, token, EVENT_DELIM, ","))
goto out_free_field;

Expand Down

0 comments on commit eff2c92

Please sign in to comment.