perf evlist: Add tracepoint lookup by name
authorDavid Ahern <dsahern@gmail.com>
Thu, 29 Aug 2013 04:29:51 +0000 (22:29 -0600)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 29 Aug 2013 20:41:02 +0000 (17:41 -0300)
Will be used by upcoming perf-trace replay option.

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1377750593-48046-2-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c
tools/perf/util/evlist.h

index 6a629af5137610823ba99b5f99913b23ed0ecc6e..5df4ca91bed346050727e6de6394bc582b84cbcb 100644 (file)
@@ -208,6 +208,21 @@ perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id)
        return NULL;
 }
 
+struct perf_evsel *
+perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,
+                                    const char *name)
+{
+       struct perf_evsel *evsel;
+
+       list_for_each_entry(evsel, &evlist->entries, node) {
+               if ((evsel->attr.type == PERF_TYPE_TRACEPOINT) &&
+                   (strcmp(evsel->name, name) == 0))
+                       return evsel;
+       }
+
+       return NULL;
+}
+
 int perf_evlist__add_newtp(struct perf_evlist *evlist,
                           const char *sys, const char *name, void *handler)
 {
index ab95d7273638d859c0724dcca16061773b9442f9..841a39405f6a021bdf405a6974c5da46767313ef 100644 (file)
@@ -74,6 +74,10 @@ int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter);
 struct perf_evsel *
 perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id);
 
+struct perf_evsel *
+perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,
+                                    const char *name);
+
 void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
                         int cpu, int thread, u64 id);