diff options
-rw-r--r-- | tools/perf/util/parse-events.c | 23 | ||||
-rw-r--r-- | tools/perf/util/parse-events.h | 1 | ||||
-rw-r--r-- | tools/perf/util/trace-event-info.c | 15 |
3 files changed, 39 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) { |
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 8a4859315fd9..080f7cf25d99 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h | |||
@@ -23,6 +23,7 @@ struct tracepoint_path { | |||
23 | }; | 23 | }; |
24 | 24 | ||
25 | extern struct tracepoint_path *tracepoint_id_to_path(u64 config); | 25 | extern struct tracepoint_path *tracepoint_id_to_path(u64 config); |
26 | extern struct tracepoint_path *tracepoint_name_to_path(const char *name); | ||
26 | extern bool have_tracepoints(struct list_head *evlist); | 27 | extern bool have_tracepoints(struct list_head *evlist); |
27 | 28 | ||
28 | const char *event_type(int type); | 29 | const char *event_type(int type); |
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index 615c0628678b..a42624a6cb5c 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c | |||
@@ -414,12 +414,27 @@ get_tracepoints_path(struct list_head *pattrs) | |||
414 | if (pos->attr.type != PERF_TYPE_TRACEPOINT) | 414 | if (pos->attr.type != PERF_TYPE_TRACEPOINT) |
415 | continue; | 415 | continue; |
416 | ++nr_tracepoints; | 416 | ++nr_tracepoints; |
417 | |||
418 | if (pos->name) { | ||
419 | ppath->next = tracepoint_name_to_path(pos->name); | ||
420 | if (ppath->next) | ||
421 | goto next; | ||
422 | |||
423 | if (strchr(pos->name, ':') == NULL) | ||
424 | goto try_id; | ||
425 | |||
426 | goto error; | ||
427 | } | ||
428 | |||
429 | try_id: | ||
417 | ppath->next = tracepoint_id_to_path(pos->attr.config); | 430 | ppath->next = tracepoint_id_to_path(pos->attr.config); |
418 | if (!ppath->next) { | 431 | if (!ppath->next) { |
432 | error: | ||
419 | pr_debug("No memory to alloc tracepoints list\n"); | 433 | pr_debug("No memory to alloc tracepoints list\n"); |
420 | put_tracepoints_path(&path); | 434 | put_tracepoints_path(&path); |
421 | return NULL; | 435 | return NULL; |
422 | } | 436 | } |
437 | next: | ||
423 | ppath = ppath->next; | 438 | ppath = ppath->next; |
424 | } | 439 | } |
425 | 440 | ||