diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2013-06-26 03:14:05 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-07-12 12:46:02 -0400 |
commit | e7c93f09b83be25281cf129674e0035664715033 (patch) | |
tree | 5258fd6bdda221a5224e37ef2d7bf78ab194e709 /tools/perf/util/parse-events.c | |
parent | 167aedc44e1743777e6aee71b0fe7ed94c6298cd (diff) |
perf util: Use evsel->name to get tracepoint_paths
Most tracepoint events already have their system and event name in
->name field so that searching whole event tracing directory for each
evsel to match given id is suboptimal.
Factor out this routine into tracepoint_name_to_path(). In case of en
invalid name, it'll try to find path using id again.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1372230862-15861-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r-- | tools/perf/util/parse-events.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 995fc25db8c6..ef72e98a07a6 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -217,6 +217,29 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config) | |||
217 | return NULL; | 217 | return NULL; |
218 | } | 218 | } |
219 | 219 | ||
220 | struct tracepoint_path *tracepoint_name_to_path(const char *name) | ||
221 | { | ||
222 | struct tracepoint_path *path = zalloc(sizeof(*path)); | ||
223 | char *str = strchr(name, ':'); | ||
224 | |||
225 | if (path == NULL || str == NULL) { | ||
226 | free(path); | ||
227 | return NULL; | ||
228 | } | ||
229 | |||
230 | path->system = strndup(name, str - name); | ||
231 | path->name = strdup(str+1); | ||
232 | |||
233 | if (path->system == NULL || path->name == NULL) { | ||
234 | free(path->system); | ||
235 | free(path->name); | ||
236 | free(path); | ||
237 | path = NULL; | ||
238 | } | ||
239 | |||
240 | return path; | ||
241 | } | ||
242 | |||
220 | const char *event_type(int type) | 243 | const char *event_type(int type) |
221 | { | 244 | { |
222 | switch (type) { | 245 | switch (type) { |