aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index bf5d033ee1b4..aed38e4b9dfa 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -356,42 +356,28 @@ int parse_events_add_cache(struct list_head **list, int *idx,
356 return add_event(list, idx, &attr, name); 356 return add_event(list, idx, &attr, name);
357} 357}
358 358
359static int add_tracepoint(struct list_head **list, int *idx, 359static int add_tracepoint(struct list_head **listp, int *idx,
360 char *sys_name, char *evt_name) 360 char *sys_name, char *evt_name)
361{ 361{
362 struct perf_event_attr attr; 362 struct perf_evsel *evsel;
363 char name[MAX_NAME_LEN]; 363 struct list_head *list = *listp;
364 char evt_path[MAXPATHLEN];
365 char id_buf[4];
366 u64 id;
367 int fd;
368
369 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", tracing_events_path,
370 sys_name, evt_name);
371
372 fd = open(evt_path, O_RDONLY);
373 if (fd < 0)
374 return -1;
375 364
376 if (read(fd, id_buf, sizeof(id_buf)) < 0) { 365 if (!list) {
377 close(fd); 366 list = malloc(sizeof(*list));
378 return -1; 367 if (!list)
368 return -ENOMEM;
369 INIT_LIST_HEAD(list);
379 } 370 }
380 371
381 close(fd); 372 evsel = perf_evsel__newtp(sys_name, evt_name, (*idx)++);
382 id = atoll(id_buf); 373 if (!evsel) {
383 374 free(list);
384 memset(&attr, 0, sizeof(attr)); 375 return -ENOMEM;
385 attr.config = id; 376 }
386 attr.type = PERF_TYPE_TRACEPOINT;
387 attr.sample_type |= PERF_SAMPLE_RAW;
388 attr.sample_type |= PERF_SAMPLE_TIME;
389 attr.sample_type |= PERF_SAMPLE_CPU;
390 attr.sample_type |= PERF_SAMPLE_PERIOD;
391 attr.sample_period = 1;
392 377
393 snprintf(name, MAX_NAME_LEN, "%s:%s", sys_name, evt_name); 378 list_add_tail(&evsel->node, list);
394 return add_event(list, idx, &attr, name); 379 *listp = list;
380 return 0;
395} 381}
396 382
397static int add_tracepoint_multi(struct list_head **list, int *idx, 383static int add_tracepoint_multi(struct list_head **list, int *idx,