[PATCH 17/21] perf tools: Add event_config_optional parsing rule
From: Jiri Olsa
Date: Wed Sep 25 2013 - 08:52:51 EST
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@xxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Corey Ashford <cjashfor@xxxxxxxxxxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/