]> Pileus Git - ~andy/linux/commitdiff
parse-events: Handle opcode parsing error
authorVaibhav Nagarnaik <vnagarnaik@google.com>
Thu, 5 Apr 2012 22:48:01 +0000 (00:48 +0200)
committerFrederic Weisbecker <fweisbec@gmail.com>
Wed, 25 Apr 2012 11:35:32 +0000 (13:35 +0200)
If an invalid opcode is encountered in parsing event print format, the
trace-cmd calls exit() without parsing any other events.

This patch adds handling for such an error where the get_op_prio() is
called. If the return value is -1, then the event print format parsing
is skipped and parsing continues.

Cc: Michael Rubin <mrubin@google.com>
Cc: David Sharp <dhsharp@google.com>
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Link: http://lkml.kernel.org/r/1311619257-4970-1-git-send-email-vnagarnaik@google.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arun Sharma <asharma@fb.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
tools/lib/traceevent/event-parse.c

index ef2c65f91677e96d9bfb8c5ca5fdef23fc630ac8..cdb32c78d150cfa5ebbbf1e748e3a152932c9f0d 100644 (file)
@@ -1592,7 +1592,7 @@ static int get_op_prio(char *op)
                case '?':
                        return 16;
                default:
-                       die("unknown op '%c'", op[0]);
+                       do_warning("unknown op '%c'", op[0]);
                        return -1;
                }
        } else {
@@ -1613,22 +1613,22 @@ static int get_op_prio(char *op)
                } else if (strcmp(op, "||") == 0) {
                        return 15;
                } else {
-                       die("unknown op '%s'", op);
+                       do_warning("unknown op '%s'", op);
                        return -1;
                }
        }
 }
 
-static void set_op_prio(struct print_arg *arg)
+static int set_op_prio(struct print_arg *arg)
 {
 
        /* single ops are the greatest */
-       if (!arg->op.left || arg->op.left->type == PRINT_NULL) {
+       if (!arg->op.left || arg->op.left->type == PRINT_NULL)
                arg->op.prio = 0;
-               return;
-       }
+       else
+               arg->op.prio = get_op_prio(arg->op.op);
 
-       arg->op.prio = get_op_prio(arg->op.op);
+       return arg->op.prio;
 }
 
 /* Note, *tok does not get freed, but will most likely be saved */
@@ -1710,7 +1710,10 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)
                arg->op.op = token;
                arg->op.left = left;
 
-               set_op_prio(arg);
+               if (set_op_prio(arg) == -1) {
+                       event->flags |= EVENT_FL_FAILED;
+                       goto out_free;
+               }
 
                type = read_token_item(&token);
                *tok = token;