Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755902Ab3IYMwr (ORCPT ); Wed, 25 Sep 2013 08:52:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38634 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755668Ab3IYMvn (ORCPT ); Wed, 25 Sep 2013 08:51:43 -0400 From: Jiri Olsa To: linux-kernel@vger.kernel.org Cc: Jiri Olsa , Arnaldo Carvalho de Melo , Corey Ashford , Frederic Weisbecker , Ingo Molnar , Paul Mackerras , Peter Zijlstra Subject: [PATCH 17/21] perf tools: Add event_config_optional parsing rule Date: Wed, 25 Sep 2013 14:50:43 +0200 Message-Id: <1380113447-17144-18-git-send-email-jolsa@redhat.com> In-Reply-To: <1380113447-17144-1-git-send-email-jolsa@redhat.com> References: <1380113447-17144-1-git-send-email-jolsa@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2982 Lines: 113 Adding 'event_config_optional' parsing rule to omit duplication code in event_legacy_symbol for /config/no config/ processing. Signed-off-by: Jiri Olsa Cc: Arnaldo Carvalho de Melo Cc: Corey Ashford Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events.c | 3 +++ tools/perf/util/parse-events.y | 34 ++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 1957849..37b9cb7 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1328,6 +1328,9 @@ void parse_events__free_terms(struct list_head *terms) { struct parse_events_term *term, *h; + if (!terms) + return; + list_for_each_entry_safe(term, h, terms, list) free(term); } diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 4eb67ec..1497a70 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -59,6 +59,7 @@ static inc_group_count(struct list_head *list, %type PE_MODIFIER_BP %type PE_EVENT_NAME %type value_sym +%type event_config_optional %type event_config %type event_term %type event_pmu @@ -199,6 +200,17 @@ event_def: event_pmu | event_legacy_numeric sep_dc | event_legacy_raw sep_dc +event_config_optional: +'/' event_config '/' +{ + $$ = $2; +} +| +sep_slash_dc +{ + $$ = NULL; +} + event_pmu: PE_NAME '/' event_config '/' { @@ -208,6 +220,7 @@ PE_NAME '/' event_config '/' ALLOC_LIST(list); ABORT_ON(parse_events_add_pmu(list, &data->idx, $1, $3)); parse_events__free_terms($3); + free($3); $$ = list; } @@ -217,30 +230,19 @@ PE_VALUE_SYM_HW PE_VALUE_SYM_SW event_legacy_symbol: -value_sym '/' event_config '/' -{ - struct parse_events_evlist *data = _data; - struct list_head *list; - int type = $1 >> 16; - int config = $1 & 255; - - ALLOC_LIST(list); - ABORT_ON(parse_events_add_numeric(list, &data->idx, - type, config, $3)); - parse_events__free_terms($3); - $$ = list; -} -| -value_sym sep_slash_dc +value_sym event_config_optional { struct parse_events_evlist *data = _data; struct list_head *list; + struct list_head *terms = $2; int type = $1 >> 16; int config = $1 & 255; ALLOC_LIST(list); ABORT_ON(parse_events_add_numeric(list, &data->idx, - type, config, NULL)); + type, config, terms)); + parse_events__free_terms(terms); + free(terms); $$ = list; } -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/