Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18075681rwd; Tue, 27 Jun 2023 11:13:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7HL/7oPsqqbel+2lw7Qn7PSt4XZjhQjqPaiy2qshNgJVznrfy/8FdiJ+EUPNCHCe+q19o+ X-Received: by 2002:a17:902:dac3:b0:1b6:8b70:328f with SMTP id q3-20020a170902dac300b001b68b70328fmr12442423plx.6.1687889612195; Tue, 27 Jun 2023 11:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687889612; cv=none; d=google.com; s=arc-20160816; b=VYKWyGtrk+fgEivvgKcNwPv5jmxCT8VXVWeT0iRaKIEyLSCPql25X7880JuFLdke8y WqY96VT5Uw9bXwVe3/yPkNy82iPgMdO9OsCFsXYq5GktBbj9e55Vdu0ejNt9fUf/QFvq KNM6PyvG8DunDNeiQIQNNL6xRDs9SHuU8aQTWtU5mGik9zBpo8Alx+JEQpTFpzyrZV/3 YqG4AAdO1Qug1H/IsjxbBa92w+OpwHEX/VpSQUoUeCCB7xpiPno+bcJak2/xdRKdxjI7 ehjSJ7l3aVB+G0eePB8bsLpIMnNpl8TbCdHrWQpeYtCDxxVHwV8vbtDOPdEMNLUfAcOB 9D6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=/xtK5HWFrotXOQTFAtNsXMiJLnjczB0bKaJqMYYAdAw=; fh=YqCpiVzWMvO28maLP3cwkHz56jIPX7pCDRM4yIDiKGU=; b=g8X/gjHdmyOzCr5jz7RW0cUBv6kJmxjb+GMuH10I7eHib5mTCo83dmTIWUtC+qcv6E 94cIswKltGvUYSNGZn0M16+Oz69Z+IfR2rbnu0RlPsV0kMhG3LvRDLQqm+OAM26S+5HT 9xP9gQB1MpZHQQKFSXpA/yad3QZ3PNF7os1TZBN0TiB1YDqQhJ1Z9FgLA3aiegDIOA36 VyjEfcz/ZMSARpBD/5Wu+VB/WxueEwufJxxWPbc1nuviqtG+/QyloH3SYREwJnlUk+L5 JOb5lZ28U4AlZ/sozsGjVPqa0wvKyf+WNPGAXWowcs33Rb5vjfD+p+/MxsCFUoZhjzIO 0+wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=oW5Nw8Ca; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020a170902848300b001b22c8d0dc5si7055627plo.437.2023.06.27.11.13.20; Tue, 27 Jun 2023 11:13:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=oW5Nw8Ca; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231564AbjF0SLs (ORCPT + 99 others); Tue, 27 Jun 2023 14:11:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231254AbjF0SLQ (ORCPT ); Tue, 27 Jun 2023 14:11:16 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 443002D4C for ; Tue, 27 Jun 2023 11:11:13 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bf0ba82473dso6701151276.0 for ; Tue, 27 Jun 2023 11:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687889472; x=1690481472; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=/xtK5HWFrotXOQTFAtNsXMiJLnjczB0bKaJqMYYAdAw=; b=oW5Nw8CaZlguvVXnWXrJCyRqJYAVwXXD99hYzQcoeE0ITiJM35Lhadh3q6zb4/iv8L LoLj3jARhvxaEXR1qszm5BP0ezvL+QzCCPMkgm+gR4yzm8M5lJBpsBruMpzcd0QxMDGC 9nXx9hQDzbvTPEnkSVw5s1VEb+umG92l809VG8DurQ+Xy7t7oMFKn1YpVU6FybqjB2Bw 5VUxTLUK7TetoD1OEK5cWJsqz7xJDR/G9ibr3Vt9AnKV1tRlGAnt2g6ryGS5+TyOK6xU Qrbcwl/ESPNFj7fYUM1Dpw/RsKAA5q37hivFSgqyIRIjX4cOXaSIPy+eMqildaC4hcPs Xz3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687889472; x=1690481472; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/xtK5HWFrotXOQTFAtNsXMiJLnjczB0bKaJqMYYAdAw=; b=fBQAcR0YHjF5gA52558/BCLIhp3D7Oxvg33umA0c73gH8+GD430Y6jsWYNwPkYl83o +Y/1uUvjjF1X83Jua1ri/GzIW4SjFeDRLOIRsLEI7hJh2kMkF82yKW3t9n/gOxU0W2ch Gt39jx+XGgsV0XDRD/U3SBICCowuGjcQpJJw/mM5GYk7a9oqcC/DuGK41iq+xsiRBdFR OmFNntj1wNEm+Og51e24s4Ekkygui/9dDDQ7kzOmaZK1/oM6uuCgbEyYExtbSCqrSCfP +etZJCOMAZf3QC5mFXZZuA3GAEtg7AsPywaF8MHb1rhLuDuVfid8VLGZsSIeAZ+HYp4k xryQ== X-Gm-Message-State: AC+VfDxwaMQpDmZOTKidVYgdwleU1gRAmj3QyvfiuP0aObYla6YJe6SE WUmRgxMFNzE5ApbpM70JRdUoU3k3Q0LY X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:a518:9a69:cf62:b4d9]) (user=irogers job=sendgmr) by 2002:a25:c943:0:b0:c15:42bf:22f with SMTP id z64-20020a25c943000000b00c1542bf022fmr3603446ybf.9.1687889472210; Tue, 27 Jun 2023 11:11:12 -0700 (PDT) Date: Tue, 27 Jun 2023 11:10:30 -0700 In-Reply-To: <20230627181030.95608-1-irogers@google.com> Message-Id: <20230627181030.95608-14-irogers@google.com> Mime-Version: 1.0 References: <20230627181030.95608-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Subject: [PATCH v2 13/13] perf parse-events: Remove ABORT_ON From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Athira Rajeev , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) + 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