Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf parse-events: Remove ABORT_ON

Prefer informative messages rather than none with ABORT_ON. Document
one failure mode and add an error message for another.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20230627181030.95608-14-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
4c11adff 81a4e31f

+14 -8
+14 -8
tools/perf/util/parse-events.y
··· 22 22 23 23 void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg); 24 24 25 - #define ABORT_ON(val) \ 26 - do { \ 27 - if (val) \ 28 - YYABORT; \ 29 - } while (0) 30 - 31 25 #define PE_ABORT(val) \ 32 26 do { \ 33 27 if (val == -ENOMEM) \ ··· 612 618 YYNOMEM; 613 619 errno = 0; 614 620 num = strtoull($1 + 1, NULL, 16); 615 - ABORT_ON(errno); 621 + /* Given the lexer will only give [a-fA-F0-9]+ a failure here should be impossible. */ 622 + if (errno) 623 + YYABORT; 616 624 free($1); 617 625 err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, num, $2, 618 626 /*wildcard=*/false); ··· 974 978 { 975 979 struct parse_events_array array; 976 980 977 - ABORT_ON($3 < $1); 981 + if ($3 < $1) { 982 + struct parse_events_state *parse_state = _parse_state; 983 + struct parse_events_error *error = parse_state->error; 984 + char *err_str; 985 + 986 + if (asprintf(&err_str, "Expected '%ld' to be less-than '%ld'", $3, $1) < 0) 987 + err_str = NULL; 988 + 989 + parse_events_error__handle(error, @1.first_column, err_str, NULL); 990 + YYABORT; 991 + } 978 992 array.nr_ranges = 1; 979 993 array.ranges = malloc(sizeof(array.ranges[0])); 980 994 if (!array.ranges)