perf tools: Fix legacy events symbol separator parsing
authorJiri Olsa <jolsa@kernel.org>
Wed, 13 Feb 2019 12:32:40 +0000 (13:32 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 14 Feb 2019 18:18:08 +0000 (15:18 -0300)
Fixing legacy symbol events parsing. We can't support single slash
separator, like 'cycles/u', because it conflicts with non empty terms,
like 'cycles/period/u'.

Keeping only '//' and ':' separator for these events:
  cycles//u
  cycles:k

And removing '/' separator support, which is not working
anymore. Also adding automated tests for above events.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190213123246.4015-5-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/parse-events.c
tools/perf/util/parse-events.y

index 3b97ac018d5aac5d6505924e508a5451888c6cd7..4a69c07f41011ee7c7dde5bf932f0c17a07f72d7 100644 (file)
@@ -1330,6 +1330,26 @@ static int test__checkevent_complex_name(struct perf_evlist *evlist)
        return 0;
 }
 
+static int test__sym_event_slash(struct perf_evlist *evlist)
+{
+       struct perf_evsel *evsel = perf_evlist__first(evlist);
+
+       TEST_ASSERT_VAL("wrong type", evsel->attr.type == PERF_TYPE_HARDWARE);
+       TEST_ASSERT_VAL("wrong config", evsel->attr.config == PERF_COUNT_HW_CPU_CYCLES);
+       TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
+       return 0;
+}
+
+static int test__sym_event_dc(struct perf_evlist *evlist)
+{
+       struct perf_evsel *evsel = perf_evlist__first(evlist);
+
+       TEST_ASSERT_VAL("wrong type", evsel->attr.type == PERF_TYPE_HARDWARE);
+       TEST_ASSERT_VAL("wrong config", evsel->attr.config == PERF_COUNT_HW_CPU_CYCLES);
+       TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
+       return 0;
+}
+
 static int count_tracepoints(void)
 {
        struct dirent *events_ent;
@@ -1670,6 +1690,16 @@ static struct evlist_test test__events[] = {
                .name  = "cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk",
                .check = test__checkevent_complex_name,
                .id    = 53
+       },
+       {
+               .name  = "cycles//u",
+               .check = test__sym_event_slash,
+               .id    = 54,
+       },
+       {
+               .name  = "cycles:k",
+               .check = test__sym_event_dc,
+               .id    = 55,
        }
 };
 
index da8fe57691b8cd0d4c1c22d0cf0fa62595385ac5..44819bdb037dabbd820f3ba13988ffd7dbf1343e 100644 (file)
@@ -311,7 +311,7 @@ value_sym '/' event_config '/'
        $$ = list;
 }
 |
-value_sym sep_slash_dc
+value_sym sep_slash_slash_dc
 {
        struct list_head *list;
        int type = $1 >> 16;
@@ -702,7 +702,7 @@ PE_VALUE PE_ARRAY_RANGE PE_VALUE
 
 sep_dc: ':' |
 
-sep_slash_dc: '/' | ':' |
+sep_slash_slash_dc: '/' '/' | ':' |
 
 %%