Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1716267ybz; Thu, 23 Apr 2020 04:30:59 -0700 (PDT) X-Google-Smtp-Source: APiQypI6BTA9cAmJPFr7RBf+V9wSLjY5tGKWJZbnVBT9wTeInlJnMg3VEr9iVbky5pj5mPvjbMtN X-Received: by 2002:a05:6402:3129:: with SMTP id dd9mr2283964edb.121.1587641459304; Thu, 23 Apr 2020 04:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587641459; cv=none; d=google.com; s=arc-20160816; b=KEjam9JC8Fs7PC7EtOwtwjW+15LvLBGB1QsZe5v4FfacUKqZCLn2CvU73aVOksTihs FkwSQBM0OdNKFeIpE5VRUpHtqMPK3d3SIhFBaeYAacP97C3EGc1V0UEocx/5z7DlAVLZ 38lk+IwpR/msnzZ5b+ySAqo36lQx3sWuEHXvaDE6Xt5o0BsR776vEa2al2gDkxRlKmmd wOt2jFbKR9X7o2fFWzBOrNhKZ23jMfoKbFS7wZ+aSVBy/8F1Z0sljuJHCRbX8Y4ikdln ZBFdhr8hizGRFf/uIciqscarCYLCqsVP2khAyVVWnFkLJ/zRsPA2krp/CXrnGE3mPgz4 WnOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=T5LP/86R6RJodTw+xNHNMGgzEhuInJZx2HqvTUy6zd8=; b=z1AUfqKo82uq5kwSNrDyrvcYyIdJI0ACAGhCZl6EeQhqstrsikmqzCVwZgEbPqd7vl DH/07vhT0t6rCrHWgg+FfUlt3LpNkkOvIjCcMGsXVgIA8fM3ufIDxqBeX1Vrz3Dn+rq4 ngIhdM606SkxFUSy3QciV9+LjfU8DlL+j91HZhqHOafznQqKN8kprUnRsWGb73DCEi5L LU8GHqOWL1t+XUepqQcsoAry23KesNPBwBkHWhmPYaA+tAKDW+O7gyiFllAT8lkEIDfv axCkmOkYKibTiGLSuuzyxpz3DBpsXsL6DnQqyyKBaZg8dVIaQvGkSKCjjtmBWGD5Nddw JgmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S1AyhSp2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jx10si1100199ejb.150.2020.04.23.04.30.35; Thu, 23 Apr 2020 04:30:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S1AyhSp2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728097AbgDWL2v (ORCPT + 99 others); Thu, 23 Apr 2020 07:28:51 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49884 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728092AbgDWL2v (ORCPT ); Thu, 23 Apr 2020 07:28:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587641330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=T5LP/86R6RJodTw+xNHNMGgzEhuInJZx2HqvTUy6zd8=; b=S1AyhSp2GYOctzz9SfqTeQ6xhv1V65paw1sRjq4no0vXT8Bdiq1UfCrYE8ObkeayUfBne1 CfVHib+hI/1GI4konxoijNdvG+yp31Zf3ni530WRTJWUHE5KtfpSVyzzR3j3Bz6+21nLAF c33/fUE8qMnub7s8oRXSGpJyp42uFJI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-303-xJgTRP31Nu-cIqxWkO_Fhw-1; Thu, 23 Apr 2020 07:28:46 -0400 X-MC-Unique: xJgTRP31Nu-cIqxWkO_Fhw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD52A80B70D; Thu, 23 Apr 2020 11:28:43 +0000 (UTC) Received: from krava (unknown [10.40.196.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F6355D706; Thu, 23 Apr 2020 11:28:39 +0000 (UTC) Date: Thu, 23 Apr 2020 13:28:37 +0200 From: Jiri Olsa To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , Kan Liang , Andi Kleen , Haiyan Song , Jin Yao , Song Liu , Ravi Bangoria , John Garry , Leo Yan , Adrian Hunter , Paul Clarke , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian Subject: Re: [PATCH v2 10/11] perf expr: print a debug message for division by zero Message-ID: <20200423112837.GE1136647@krava> References: <20200422220430.254014-1-irogers@google.com> <20200422220430.254014-11-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200422220430.254014-11-irogers@google.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 22, 2020 at 03:04:29PM -0700, Ian Rogers wrote: > If an expression yields 0 and is then divided-by/modulus-by then the > parsing aborts. Add a debug error message to better enable debugging > when this happens. > > Signed-off-by: Ian Rogers > --- > tools/perf/util/expr.y | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y > index 54260094b947..21e82a1e11a2 100644 > --- a/tools/perf/util/expr.y > +++ b/tools/perf/util/expr.y > @@ -103,8 +103,18 @@ expr: NUMBER > | expr '+' expr { $$ = $1 + $3; } > | expr '-' expr { $$ = $1 - $3; } > | expr '*' expr { $$ = $1 * $3; } > - | expr '/' expr { if ($3 == 0) YYABORT; $$ = $1 / $3; } > - | expr '%' expr { if ((long)$3 == 0) YYABORT; $$ = (long)$1 % (long)$3; } > + | expr '/' expr { if ($3 == 0) { > + pr_debug("division by zero\n"); > + YYABORT; > + } > + $$ = $1 / $3; > + } > + | expr '%' expr { if ((long)$3 == 0) { is that (long) cast necessary? it's missing for the '/' case jirka > + pr_debug("division by zero\n"); > + YYABORT; > + } > + $$ = (long)$1 % (long)$3; > + } > | '-' expr %prec NEG { $$ = -$2; } > | '(' if_expr ')' { $$ = $2; } > | MIN '(' expr ',' expr ')' { $$ = $3 < $5 ? $3 : $5; } > -- > 2.26.2.303.gf8c07b1a785-goog >