lkml.org 
[lkml]   [2013]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 17/21] perf tools: Add event_config_optional parsing rule
Date
Adding 'event_config_optional' parsing rule to omit
duplication code in event_legacy_symbol for /config/no config/
processing.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
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 <str> PE_MODIFIER_BP
%type <str> PE_EVENT_NAME
%type <num> value_sym
+%type <head> event_config_optional
%type <head> event_config
%type <term> event_term
%type <head> 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


\
 
 \ /
  Last update: 2013-09-25 15:21    [W:0.676 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site