Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21366975rwd; Thu, 29 Jun 2023 15:11:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlEAAAHWk+8PzHVctSy5wmwpPxUzx6ly4NK0SemYUWAGGRkgUiE6Zs76m3/+HsiqHhmFGnPU X-Received: by 2002:a17:903:2441:b0:1b7:f443:c7f8 with SMTP id l1-20020a170903244100b001b7f443c7f8mr527707pls.15.1688076716518; Thu, 29 Jun 2023 15:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688076716; cv=none; d=google.com; s=arc-20160816; b=w5rBhv/wGtjsVwyxlBHtj7pg7vbb0iZLl8Q+bJsKVcuib9FH+0uRWgf4V4RQV6FL1U 1t1oI0ij7Kjw7Rt5LJD6v1S3WJVUP9tPivKgrf2JgTdnRoVk82SRg8Qu0HUUxcm99WRo g8jK7frTU1tD/Dl3NBoa+q1KPLjhgjc8OwZe/gVyHSyiM3FRKYIArkua74FA/LRE89Uq DplozSap/STc9u7ZqNQ0wDtyyneO3tDwgK88Nu8YWbrv4ho79gW1c1hh1peuRgudA4AR Rkp20XTD9dcWR5FMpQSCHpl/zytoQ/XKX5FMWWibJ29ztclOPmMUan8YgKXRZzDgXwAJ 3EAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=k97QvLy8Azi7lQJ0JKIYchqnAe9F436UMnmGYPLyK6k=; fh=jH/mJCXWR8bipCtjdk+yvUXuJVXXb0Twg71efdsWzWs=; b=Gdhfl3xzs51/NvYgjs8R3+ytv1zSqh0IbCmkNZ4B1zsuiLo5orsTAnzPPeLGvjwjvm U/x9h2BL9LvkAcheabxX28iEr1Hl8HPEOQdhNtk5rKXNv8/NRVjDM7vH0RSiaWWzywjT 0qsx1HPvFRM0FN3ktqfInNZ2FY6Q4LOap3PPTYqZd8FVdAP2j+xcs+rHg+ko2q0yeHum FcZEUJaZDkXppyHMjLo5rZNGOkLYZC1B51LVxL4N0jbJxeUIn/YfrSBrs9Y2sDy6jj4c mAfu11dS5TslCjLvuidZW7QAyNdIyUhLbEykXeODSuKS/Z5t1tFohD/QBNbrYNKC7WAi wvcw== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a1709026e0900b001b83767e879si3558461plk.266.2023.06.29.15.11.42; Thu, 29 Jun 2023 15:11:56 -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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231804AbjF2Vtq convert rfc822-to-8bit (ORCPT + 99 others); Thu, 29 Jun 2023 17:49:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbjF2Vtl (ORCPT ); Thu, 29 Jun 2023 17:49:41 -0400 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01A2730C4; Thu, 29 Jun 2023 14:49:40 -0700 (PDT) Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-5634d8d1db0so816840eaf.0; Thu, 29 Jun 2023 14:49:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688075380; x=1690667380; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0l23JP6S9GF/LAJfWcHkkcP43ONSxdFrMmfEO7H0kkE=; b=Gk90oRB+UAgMNfNRfbBae4fhx0Mtg0JN+CZujOejRaDwVfEoAn0yqUhYQ/HaJwJmpY QkQp0hkHPtsKbte00flgZBwneXD+hlSLrSHOMRPK4WLALkEwJBbO7fk/wXhF+yBZGRWV ZTQwp6dxQLLk6GTSJLVIf08BI96f9Wa4CT8554OG4qTV7tgDx3NBUSRWrpDbPJJVnQ/H 0mj/YGm4N3VZFJaa1QUBD4dH5TF/hpP6CqRHISeNJ29NxgGoM8FTj04gFyvuQ1jdOe3t fKeef94nKQMtu9j5K3NxlG60Fv0v+/sASlIpafqAAPpLTPk3jpwXZWfYpy15l7wFojaQ Cd9Q== X-Gm-Message-State: ABy/qLaxl1HN7r/FSUDMB3HGixrppHVVnHLqn91AU6b8DUyPdkGkPRtY 4oKbBt1GB4pMC+QSLMugCsH2+y+AJkpe40jNujCYiKiz X-Received: by 2002:a05:6358:e907:b0:134:e34e:ec49 with SMTP id gk7-20020a056358e90700b00134e34eec49mr891794rwb.2.1688075380126; Thu, 29 Jun 2023 14:49:40 -0700 (PDT) MIME-Version: 1.0 References: <20230627181030.95608-1-irogers@google.com> <20230627181030.95608-14-irogers@google.com> In-Reply-To: <20230627181030.95608-14-irogers@google.com> From: Namhyung Kim Date: Thu, 29 Jun 2023 14:49:29 -0700 Message-ID: Subject: Re: [PATCH v2 13/13] perf parse-events: Remove ABORT_ON To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , 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" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Tue, Jun 27, 2023 at 11:11 AM Ian Rogers 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 > --- > 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 >