Commit 245c5a18 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

tools lib traceevent: Get rid of die() from pretty_print()

There are three cases that call die() in the pretty_print.

 1. insufficient number of argument: cannot proceed anymore.
 2. too long format conversion specifier: truncate and proceed.
 3. bad size specifier in format string: skip and proceed.

For all cases, convert die to do_warning, mark the event as
EVENT_FL_FAILED and print error message at the last.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1346986187-5170-1-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9a293687
...@@ -3889,8 +3889,11 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event ...@@ -3889,8 +3889,11 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
goto cont_process; goto cont_process;
case '*': case '*':
/* The argument is the length. */ /* The argument is the length. */
if (!arg) if (!arg) {
die("no argument match"); do_warning("no argument match");
event->flags |= EVENT_FL_FAILED;
goto out_failed;
}
len_arg = eval_num_arg(data, size, event, arg); len_arg = eval_num_arg(data, size, event, arg);
len_as_arg = 1; len_as_arg = 1;
arg = arg->next; arg = arg->next;
...@@ -3923,15 +3926,21 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event ...@@ -3923,15 +3926,21 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
case 'x': case 'x':
case 'X': case 'X':
case 'u': case 'u':
if (!arg) if (!arg) {
die("no argument match"); do_warning("no argument match");
event->flags |= EVENT_FL_FAILED;
goto out_failed;
}
len = ((unsigned long)ptr + 1) - len = ((unsigned long)ptr + 1) -
(unsigned long)saveptr; (unsigned long)saveptr;
/* should never happen */ /* should never happen */
if (len > 31) if (len > 31) {
die("bad format!"); do_warning("bad format!");
event->flags |= EVENT_FL_FAILED;
len = 31;
}
memcpy(format, saveptr, len); memcpy(format, saveptr, len);
format[len] = 0; format[len] = 0;
...@@ -3995,19 +4004,26 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event ...@@ -3995,19 +4004,26 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
trace_seq_printf(s, format, (long long)val); trace_seq_printf(s, format, (long long)val);
break; break;
default: default:
die("bad count (%d)", ls); do_warning("bad count (%d)", ls);
event->flags |= EVENT_FL_FAILED;
} }
break; break;
case 's': case 's':
if (!arg) if (!arg) {
die("no matching argument"); do_warning("no matching argument");
event->flags |= EVENT_FL_FAILED;
goto out_failed;
}
len = ((unsigned long)ptr + 1) - len = ((unsigned long)ptr + 1) -
(unsigned long)saveptr; (unsigned long)saveptr;
/* should never happen */ /* should never happen */
if (len > 31) if (len > 31) {
die("bad format!"); do_warning("bad format!");
event->flags |= EVENT_FL_FAILED;
len = 31;
}
memcpy(format, saveptr, len); memcpy(format, saveptr, len);
format[len] = 0; format[len] = 0;
...@@ -4025,6 +4041,11 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event ...@@ -4025,6 +4041,11 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
trace_seq_putc(s, *ptr); trace_seq_putc(s, *ptr);
} }
if (event->flags & EVENT_FL_FAILED) {
out_failed:
trace_seq_printf(s, "[FAILED TO PARSE]");
}
if (args) { if (args) {
free_args(args); free_args(args);
free(bprint_fmt); free(bprint_fmt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment