perf evsel: Handle all event types in perf_evsel__name
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 12 Jun 2012 13:29:12 +0000 (10:29 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 19 Jun 2012 16:06:20 +0000 (13:06 -0300)
Now to convert all event_name users to perf_evsel__name.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-buuz0j0gynseglxa76r01rdn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evsel.c
tools/perf/util/parse-events.c

index 2da04733117350a2fad52e2dab501c811c8819d6..2ddc812718555cead782ed584f2c0025f411bd42 100644 (file)
@@ -252,6 +252,11 @@ static int perf_evsel__hw_cache_name(struct perf_evsel *evsel, char *bf, size_t
        return ret + perf_evsel__add_modifiers(evsel, bf + ret, size - ret);
 }
 
+static int perf_evsel__tracepoint_name(struct perf_evsel *evsel, char *bf, size_t size)
+{
+       return scnprintf(bf, size, "%s", evsel->name ?: "unknown tracepoint");
+}
+
 int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size)
 {
        int ret;
@@ -273,20 +278,13 @@ int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size)
                ret = perf_evsel__sw_name(evsel, bf, size);
                break;
 
+       case PERF_TYPE_TRACEPOINT:
+               ret = perf_evsel__tracepoint_name(evsel, bf, size);
+               break;
+
        default:
-               /*
-                * FIXME
-                *
-                * This is the minimal perf_evsel__name so that we can
-                * reconstruct event names taking into account event modifiers.
-                *
-                * The old event_name uses it now for raw anr hw events, so that
-                * we don't drag all the parsing stuff into the python binding.
-                *
-                * On the next devel cycle the rest of the event naming will be
-                * brought here.
-                */
-               return 0;
+               ret = scnprintf(bf, size, "%s", "unknown attr type");
+               break;
        }
 
        return ret;
index 641c4ac8a8385fdf48187ba048bc2dcfd8e64e93..d73690b11242605e7439b8bfe260908cff26239b 100644 (file)
@@ -203,24 +203,9 @@ const char *event_type(int type)
 
 const char *event_name(struct perf_evsel *evsel)
 {
-       u64 config = evsel->attr.config;
-       int type = evsel->attr.type;
-
-       if (type == PERF_TYPE_RAW || type == PERF_TYPE_HARDWARE ||
-           type == PERF_TYPE_SOFTWARE || type == PERF_TYPE_HW_CACHE) {
-               /*
-                * XXX minimal fix, see comment on perf_evsen__name, this static buffer
-                * will go away together with event_name in the next devel cycle.
-                */
-               static char bf[128];
-               perf_evsel__name(evsel, bf, sizeof(bf));
-               return bf;
-       }
-
-       if (evsel->name)
-               return evsel->name;
-
-       return __event_name(type, config);
+       static char bf[128];
+       perf_evsel__name(evsel, bf, sizeof(bf));
+       return bf;
 }
 
 const char *__event_name(int type, u64 config)