Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp341078ybk; Wed, 20 May 2020 00:42:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJKlbZGBo1kevHmJ4quMnEJyKRZBlrygAGddDLen1S4wFVxJ6Sej6BA96h+eDJovmvfgHI X-Received: by 2002:a17:906:6843:: with SMTP id a3mr2506134ejs.245.1589960572923; Wed, 20 May 2020 00:42:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589960572; cv=none; d=google.com; s=arc-20160816; b=jzI/rJLyjuH7ji0ujT181gc2524CJfanGSaMmfos00Le6J+a5VLwAMLgGCe8llm2AM 3r+fcGjDmHRwpXXLliQJTa153y/n0oLcBA5btTU+dAKd4oCiovy6fg9LMeTIOwRbk2r0 1J98ZBlZT9k9fAFV293FH4mOeT5xMiAvirMtyMQ86sNJ+EJb0VsmVPSJEGo/TnqV87JY W9fKAfrYroFBtu1695pcHq5UP8JxsYPgWB9TCEg7EJ8KZWf+J1rBomhDMlq5qz8zHiqG ZYU2nZ68Uv6+LnA3U3YkfIA0hEibgu4jZ9/aAb3J3sVvc9w2A9THOm7hTHy+yYOQgYby FCpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Scg9tcxyqIdbeqjX7WtoKqhK6VXzDLKIryn8v1rT0hY=; b=u2oqYdj2HyBIo88EMMyPFbeCs2B7JKzX+ViaM8uaINsFDN5wF7QRoeaceypO5Mp9oH 4ZVj+u2RQ2hXJcLX+kwiZcgfs9X5xbue3Rr37/V/xhMjfPhAAOuc+jMbkce8fDYC/k0D XsnDGohfFNy2XgZW2mCn8wWJYHiUaaCgQAAVtMxKr88TfglhPR+Z52XcuH0jKFXVl8YU jKXf0v1YgP6+lUTLwRAJSKRhUsIKibdhgFXTUPCpTaQ5e4wnxNLAHFzD1Ir3vo79iSKl 7UQN38ysMyL4DJgiXhadP6UOTE+m8DhE9nTN1n0WiyJrwiQDNsx0DGLwI1SPt+Y7zyaw 7V6w== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id se23si1284227ejb.247.2020.05.20.00.42.28; Wed, 20 May 2020 00:42:52 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726790AbgETHlA convert rfc822-to-8bit (ORCPT + 99 others); Wed, 20 May 2020 03:41:00 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:34691 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726435AbgETHk7 (ORCPT ); Wed, 20 May 2020 03:40:59 -0400 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-153-U9-Y8UJlOdu0jcY7-C2i4Q-1; Wed, 20 May 2020 03:40:54 -0400 X-MC-Unique: U9-Y8UJlOdu0jcY7-C2i4Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37645A0BD7; Wed, 20 May 2020 07:40:53 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.194.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A79D7958F; Wed, 20 May 2020 07:40:50 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Ian Rogers , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH] perf stat: Fail on extra comma while parsing events Date: Wed, 20 May 2020 09:40:50 +0200 Message-Id: <20200520074050.156988-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ian reported that we allow to parse following: $ perf stat -e ,cycles true which is wrong and we should fail, like we do with this fix: $ perf stat -e ,cycles true event syntax error: ',cycles' \___ parser error The reason is that we don't have rule for ',' in 'event' start condition and it's matched and accepted by default rule. Adding scanner debug support (that Ian already added for expr code), which was really useful for finding this. It's enabled together with bison debug via 'make PARSER_DEBUG=1'. Reported-by: Ian Rogers Signed-off-by: Jiri Olsa --- tools/perf/util/parse-events.c | 1 + tools/perf/util/parse-events.l | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index e37a6a3e6217..d251c8a778b8 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2014,6 +2014,7 @@ static int parse_events__scanner(const char *str, void *parse_state, int start_t #ifdef PARSER_DEBUG parse_events_debug = 1; + parse_events_set_debug(1, scanner); #endif ret = parse_events_parse(parse_state, scanner); diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index c589fc42f058..394132254447 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -252,7 +252,9 @@ modifier_bp [rwx]{1,3} BEGIN(INITIAL); REWIND(0); } - +, { + return ','; + } } { -- 2.25.4