diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-09-06 22:49:45 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-09-07 11:14:30 -0400 |
commit | 245c5a18433090da0e1a799bdb0faa78552b5992 (patch) | |
tree | 96dcb05214f91cb66cfde7a07ba0f8a561a598c5 /tools/lib/traceevent/event-parse.c | |
parent | 9a2936878a198553a17d21d1e843aa574ad9fa38 (diff) |
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: Namhyung Kim <namhyung@kernel.org>
Acked-by: Steven 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/traceevent/event-parse.c')
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index b5b4d806ffa2..6d5e75987a3d 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -3889,8 +3889,11 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
3889 | goto cont_process; | 3889 | goto cont_process; |
3890 | case '*': | 3890 | case '*': |
3891 | /* The argument is the length. */ | 3891 | /* The argument is the length. */ |
3892 | if (!arg) | 3892 | if (!arg) { |
3893 | die("no argument match"); | 3893 | do_warning("no argument match"); |
3894 | event->flags |= EVENT_FL_FAILED; | ||
3895 | goto out_failed; | ||
3896 | } | ||
3894 | len_arg = eval_num_arg(data, size, event, arg); | 3897 | len_arg = eval_num_arg(data, size, event, arg); |
3895 | len_as_arg = 1; | 3898 | len_as_arg = 1; |
3896 | arg = arg->next; | 3899 | arg = arg->next; |
@@ -3923,15 +3926,21 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
3923 | case 'x': | 3926 | case 'x': |
3924 | case 'X': | 3927 | case 'X': |
3925 | case 'u': | 3928 | case 'u': |
3926 | if (!arg) | 3929 | if (!arg) { |
3927 | die("no argument match"); | 3930 | do_warning("no argument match"); |
3931 | event->flags |= EVENT_FL_FAILED; | ||
3932 | goto out_failed; | ||
3933 | } | ||
3928 | 3934 | ||
3929 | len = ((unsigned long)ptr + 1) - | 3935 | len = ((unsigned long)ptr + 1) - |
3930 | (unsigned long)saveptr; | 3936 | (unsigned long)saveptr; |
3931 | 3937 | ||
3932 | /* should never happen */ | 3938 | /* should never happen */ |
3933 | if (len > 31) | 3939 | if (len > 31) { |
3934 | die("bad format!"); | 3940 | do_warning("bad format!"); |
3941 | event->flags |= EVENT_FL_FAILED; | ||
3942 | len = 31; | ||
3943 | } | ||
3935 | 3944 | ||
3936 | memcpy(format, saveptr, len); | 3945 | memcpy(format, saveptr, len); |
3937 | format[len] = 0; | 3946 | format[len] = 0; |
@@ -3995,19 +4004,26 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
3995 | trace_seq_printf(s, format, (long long)val); | 4004 | trace_seq_printf(s, format, (long long)val); |
3996 | break; | 4005 | break; |
3997 | default: | 4006 | default: |
3998 | die("bad count (%d)", ls); | 4007 | do_warning("bad count (%d)", ls); |
4008 | event->flags |= EVENT_FL_FAILED; | ||
3999 | } | 4009 | } |
4000 | break; | 4010 | break; |
4001 | case 's': | 4011 | case 's': |
4002 | if (!arg) | 4012 | if (!arg) { |
4003 | die("no matching argument"); | 4013 | do_warning("no matching argument"); |
4014 | event->flags |= EVENT_FL_FAILED; | ||
4015 | goto out_failed; | ||
4016 | } | ||
4004 | 4017 | ||
4005 | len = ((unsigned long)ptr + 1) - | 4018 | len = ((unsigned long)ptr + 1) - |
4006 | (unsigned long)saveptr; | 4019 | (unsigned long)saveptr; |
4007 | 4020 | ||
4008 | /* should never happen */ | 4021 | /* should never happen */ |
4009 | if (len > 31) | 4022 | if (len > 31) { |
4010 | die("bad format!"); | 4023 | do_warning("bad format!"); |
4024 | event->flags |= EVENT_FL_FAILED; | ||
4025 | len = 31; | ||
4026 | } | ||
4011 | 4027 | ||
4012 | memcpy(format, saveptr, len); | 4028 | memcpy(format, saveptr, len); |
4013 | format[len] = 0; | 4029 | format[len] = 0; |
@@ -4025,6 +4041,11 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
4025 | trace_seq_putc(s, *ptr); | 4041 | trace_seq_putc(s, *ptr); |
4026 | } | 4042 | } |
4027 | 4043 | ||
4044 | if (event->flags & EVENT_FL_FAILED) { | ||
4045 | out_failed: | ||
4046 | trace_seq_printf(s, "[FAILED TO PARSE]"); | ||
4047 | } | ||
4048 | |||
4028 | if (args) { | 4049 | if (args) { |
4029 | free_args(args); | 4050 | free_args(args); |
4030 | free(bprint_fmt); | 4051 | free(bprint_fmt); |