diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-10-13 00:55:35 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-10-13 00:55:35 -0400 |
commit | f8766a8266ecbfd46190fb97a393bf7d01971850 (patch) | |
tree | 5fe00ce6b69f12539d19ff4c2cbb89aa432bce6c | |
parent | 62989922ff2e9b53738acd60a2b6e202ca403e6d (diff) |
do not exit when parser fails on an event
If an event fails to parse, just warn about it, and continue.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | parse-events.c | 35 | ||||
-rw-r--r-- | parse-events.h | 15 | ||||
-rw-r--r-- | trace-cmd.c | 15 |
3 files changed, 50 insertions, 15 deletions
diff --git a/parse-events.c b/parse-events.c index 42f1e3f..5795c09 100644 --- a/parse-events.c +++ b/parse-events.c | |||
@@ -625,7 +625,7 @@ enum event_type read_token_item(char **tok) | |||
625 | int test_type(enum event_type type, enum event_type expect) | 625 | int test_type(enum event_type type, enum event_type expect) |
626 | { | 626 | { |
627 | if (type != expect) { | 627 | if (type != expect) { |
628 | die("Error: expected type %d but read %d", | 628 | warn("Error: expected type %d but read %d", |
629 | expect, type); | 629 | expect, type); |
630 | return -1; | 630 | return -1; |
631 | } | 631 | } |
@@ -636,13 +636,13 @@ int test_type_token(enum event_type type, char *token, | |||
636 | enum event_type expect, char *expect_tok) | 636 | enum event_type expect, char *expect_tok) |
637 | { | 637 | { |
638 | if (type != expect) { | 638 | if (type != expect) { |
639 | die("Error: expected type %d but read %d", | 639 | warn("Error: expected type %d but read %d", |
640 | expect, type); | 640 | expect, type); |
641 | return -1; | 641 | return -1; |
642 | } | 642 | } |
643 | 643 | ||
644 | if (strcmp(token, expect_tok) != 0) { | 644 | if (strcmp(token, expect_tok) != 0) { |
645 | die("Error: expected '%s' but read '%s'", | 645 | warn("Error: expected '%s' but read '%s'", |
646 | expect_tok, token); | 646 | expect_tok, token); |
647 | return -1; | 647 | return -1; |
648 | } | 648 | } |
@@ -685,7 +685,7 @@ int __read_expected(enum event_type expect, char *str, int newline_ok) | |||
685 | 685 | ||
686 | free_token(token); | 686 | free_token(token); |
687 | 687 | ||
688 | return 0; | 688 | return ret; |
689 | } | 689 | } |
690 | 690 | ||
691 | int read_expected(enum event_type expect, char *str) | 691 | int read_expected(enum event_type expect, char *str) |
@@ -1226,7 +1226,8 @@ process_op(struct event *event, struct print_arg *arg, char **tok) | |||
1226 | type = process_array(event, arg, tok); | 1226 | type = process_array(event, arg, tok); |
1227 | 1227 | ||
1228 | } else { | 1228 | } else { |
1229 | die("unknown op '%s'", token); | 1229 | warn("unknown op '%s'", token); |
1230 | event->flags |= EVENT_FL_FAILED; | ||
1230 | /* the arg is now the left side */ | 1231 | /* the arg is now the left side */ |
1231 | return EVENT_NONE; | 1232 | return EVENT_NONE; |
1232 | } | 1233 | } |
@@ -2749,6 +2750,12 @@ void print_event(int cpu, void *data, int size, unsigned long long nsecs) | |||
2749 | comm, pid, cpu, | 2750 | comm, pid, cpu, |
2750 | secs, usecs, event->name); | 2751 | secs, usecs, event->name); |
2751 | 2752 | ||
2753 | if (event->flags & EVENT_FL_FAILED) { | ||
2754 | printf("EVENT '%s' FAILED TO PARSE\n", | ||
2755 | event->name); | ||
2756 | return; | ||
2757 | } | ||
2758 | |||
2752 | pretty_print(data, size, event); | 2759 | pretty_print(data, size, event); |
2753 | printf("\n"); | 2760 | printf("\n"); |
2754 | } | 2761 | } |
@@ -2955,12 +2962,16 @@ int parse_event_file(char *buf, unsigned long size, char *system) | |||
2955 | die("failed to read event id"); | 2962 | die("failed to read event id"); |
2956 | 2963 | ||
2957 | ret = event_read_format(event); | 2964 | ret = event_read_format(event); |
2958 | if (ret < 0) | 2965 | if (ret < 0) { |
2959 | die("failed to read event format"); | 2966 | warn("failed to read event format for %s", event->name); |
2967 | goto event_failed; | ||
2968 | } | ||
2960 | 2969 | ||
2961 | ret = event_read_print(event); | 2970 | ret = event_read_print(event); |
2962 | if (ret < 0) | 2971 | if (ret < 0) { |
2963 | die("failed to read event print fmt"); | 2972 | warn("failed to read event print fmt for %s", event->name); |
2973 | goto event_failed; | ||
2974 | } | ||
2964 | 2975 | ||
2965 | #define PRINT_ARGS 0 | 2976 | #define PRINT_ARGS 0 |
2966 | if (PRINT_ARGS && event->print_fmt.args) | 2977 | if (PRINT_ARGS && event->print_fmt.args) |
@@ -2968,6 +2979,12 @@ int parse_event_file(char *buf, unsigned long size, char *system) | |||
2968 | 2979 | ||
2969 | add_event(event); | 2980 | add_event(event); |
2970 | return 0; | 2981 | return 0; |
2982 | |||
2983 | event_failed: | ||
2984 | event->flags |= EVENT_FL_FAILED; | ||
2985 | /* still add it even if it failed */ | ||
2986 | add_event(event); | ||
2987 | return -1; | ||
2971 | } | 2988 | } |
2972 | 2989 | ||
2973 | void parse_set_info(int nr_cpus, int long_sz) | 2990 | void parse_set_info(int nr_cpus, int long_sz) |
diff --git a/parse-events.h b/parse-events.h index 73b36dd..d517ba2 100644 --- a/parse-events.h +++ b/parse-events.h | |||
@@ -131,12 +131,14 @@ struct event { | |||
131 | }; | 131 | }; |
132 | 132 | ||
133 | enum { | 133 | enum { |
134 | EVENT_FL_ISFTRACE = 1, | 134 | EVENT_FL_ISFTRACE = 0x01, |
135 | EVENT_FL_ISPRINT = 2, | 135 | EVENT_FL_ISPRINT = 0x02, |
136 | EVENT_FL_ISBPRINT = 4, | 136 | EVENT_FL_ISBPRINT = 0x04, |
137 | EVENT_FL_ISFUNC = 8, | 137 | EVENT_FL_ISFUNC = 0x08, |
138 | EVENT_FL_ISFUNCENT = 16, | 138 | EVENT_FL_ISFUNCENT = 0x10, |
139 | EVENT_FL_ISFUNCRET = 32, | 139 | EVENT_FL_ISFUNCRET = 0x20, |
140 | |||
141 | EVENT_FL_FAILED = 0x80000000 | ||
140 | }; | 142 | }; |
141 | 143 | ||
142 | struct record { | 144 | struct record { |
@@ -156,6 +158,7 @@ void trace_report(int argc, char **argv); | |||
156 | 158 | ||
157 | void die(char *fmt, ...); | 159 | void die(char *fmt, ...); |
158 | void *malloc_or_die(unsigned int size); | 160 | void *malloc_or_die(unsigned int size); |
161 | void warn(char *fmt, ...); | ||
159 | 162 | ||
160 | void parse_cmdlines(char *file, int size); | 163 | void parse_cmdlines(char *file, int size); |
161 | void parse_proc_kallsyms(char *file, unsigned int size); | 164 | void parse_proc_kallsyms(char *file, unsigned int size); |
diff --git a/trace-cmd.c b/trace-cmd.c index c452c8f..3657dd3 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
@@ -147,6 +147,21 @@ void die(char *fmt, ...) | |||
147 | exit(ret); | 147 | exit(ret); |
148 | } | 148 | } |
149 | 149 | ||
150 | void warn(char *fmt, ...) | ||
151 | { | ||
152 | va_list ap; | ||
153 | |||
154 | if (errno) | ||
155 | perror("trace-cmd"); | ||
156 | |||
157 | va_start(ap, fmt); | ||
158 | fprintf(stderr, " "); | ||
159 | vfprintf(stderr, fmt, ap); | ||
160 | va_end(ap); | ||
161 | |||
162 | fprintf(stderr, "\n"); | ||
163 | } | ||
164 | |||
150 | void *malloc_or_die(unsigned int size) | 165 | void *malloc_or_die(unsigned int size) |
151 | { | 166 | { |
152 | void *data; | 167 | void *data; |