From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
Kan Liang <kan.liang@linux.intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH v2 13/13] perf parse-events: Remove ABORT_ON
Date: Thu, 29 Jun 2023 14:49:29 -0700 [thread overview]
Message-ID: <CAM9d7cjxrNTOUGxmTAycko_Gn_uY5aX8cBWTa-jrhLoc-Bur1g@mail.gmail.com> (raw)
In-Reply-To: <20230627181030.95608-14-irogers@google.com>
On Tue, Jun 27, 2023 at 11:11 AM Ian Rogers <irogers@google.com> wrote:
>
> 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>
> ---
> tools/perf/util/parse-events.y | 22 ++++++++++++++--------
> 1 file changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> index 844646752462..454577f7aff6 100644
> --- a/tools/perf/util/parse-events.y
> +++ b/tools/perf/util/parse-events.y
> @@ -22,12 +22,6 @@
>
> void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg);
>
> -#define ABORT_ON(val) \
> -do { \
> - if (val) \
> - YYABORT; \
> -} while (0)
> -
> #define PE_ABORT(val) \
> do { \
> if (val == -ENOMEM) \
> @@ -618,7 +612,9 @@ PE_RAW opt_event_config
> YYNOMEM;
> errno = 0;
> num = strtoull($1 + 1, NULL, 16);
> - ABORT_ON(errno);
> + /* Given the lexer will only give [a-fA-F0-9]+ a failure here should be impossible. */
> + if (errno)
> + YYABORT;
> free($1);
> err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, num, $2,
> /*wildcard=*/false);
> @@ -978,7 +974,17 @@ PE_VALUE PE_ARRAY_RANGE PE_VALUE
> {
> struct parse_events_array array;
>
> - ABORT_ON($3 < $1);
> + if ($3 < $1) {
> + struct parse_events_state *parse_state = _parse_state;
> + struct parse_events_error *error = parse_state->error;
> + char *err_str;
> +
> + if (asprintf(&err_str, "Expected '%ld' to be less-than '%ld'", $3, $1) < 0)
Isn't it to be "greater-than or equal" ?
Thanks,
Namhyung
> + err_str = NULL;
> +
> + parse_events_error__handle(error, @1.first_column, err_str, NULL);
> + YYABORT;
> + }
> array.nr_ranges = 1;
> array.ranges = malloc(sizeof(array.ranges[0]));
> if (!array.ranges)
> --
> 2.41.0.162.gfafddb0af9-goog
>
next prev parent reply other threads:[~2023-06-29 21:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 18:10 [PATCH v2 00/13] parse-events clean up Ian Rogers
2023-06-27 18:10 ` [PATCH v2 01/13] perf parse-events: Remove unused PE_PMU_EVENT_FAKE token Ian Rogers
[not found] ` <8dab7522-31de-2137-7474-991885932308@web.de>
2023-06-30 17:05 ` Ian Rogers
[not found] ` <59e92b31-cd78-5c0c-ef87-f0d824cd20f7@web.de>
2023-06-30 17:16 ` [v2 " Ian Rogers
[not found] ` <44d77ec3-9a19-cfd5-4bba-4a23d0cd526b@web.de>
2023-06-30 17:33 ` Ian Rogers
[not found] ` <dbf08741-0b3d-f61f-bb06-05ca3f445202@web.de>
2023-06-30 18:01 ` Ian Rogers
2023-07-03 12:46 ` [PATCH v2 " Dan Carpenter
2023-06-27 18:10 ` [PATCH v2 02/13] perf parse-events: Remove unused PE_KERNEL_PMU_EVENT token Ian Rogers
2023-06-27 18:10 ` [PATCH v2 03/13] perf parse-events: Remove two unused tokens Ian Rogers
2023-06-27 18:10 ` [PATCH v2 04/13] perf parse-events: Add more comments to parse_events_state Ian Rogers
2023-06-27 18:10 ` [PATCH v2 05/13] perf parse-events: Avoid regrouped warning for wild card events Ian Rogers
2023-06-27 18:10 ` [PATCH v2 06/13] perf parse-event: Add memory allocation test for name terms Ian Rogers
2023-06-27 18:10 ` [PATCH v2 07/13] perf parse-events: Separate YYABORT and YYNOMEM cases Ian Rogers
2023-06-27 18:10 ` [PATCH v2 08/13] perf parse-events: Move instances of YYABORT to YYNOMEM Ian Rogers
2023-06-27 18:10 ` [PATCH v2 09/13] perf parse-events: Separate ENOMEM memory handling Ian Rogers
2023-06-27 18:10 ` [PATCH v2 10/13] perf parse-events: Additional error reporting Ian Rogers
2023-06-27 18:10 ` [PATCH v2 11/13] perf parse-events: Populate error column for BPF/tracepoint events Ian Rogers
2023-06-27 18:10 ` [PATCH v2 12/13] perf parse-events: Improve location for add pmu Ian Rogers
2023-06-27 18:10 ` [PATCH v2 13/13] perf parse-events: Remove ABORT_ON Ian Rogers
2023-06-29 21:49 ` Namhyung Kim [this message]
2023-06-30 15:14 ` Ian Rogers
2023-07-01 18:43 ` Namhyung Kim
2023-07-12 5:01 ` Ian Rogers
[not found] ` <ea39aaf0-0314-1780-c1cd-7c3661fa3e7c@web.de>
2023-06-30 17:06 ` Ian Rogers
[not found] ` <a3517306-7804-f5cf-6182-ef63b6054647@web.de>
2023-06-30 18:05 ` [v2 " Ian Rogers
[not found] ` <4672c6f8-ef0d-6a36-49be-145629c2eade@web.de>
2023-07-01 9:32 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAM9d7cjxrNTOUGxmTAycko_Gn_uY5aX8cBWTa-jrhLoc-Bur1g@mail.gmail.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).