From 3e3cd6c9edc22b816f834dca63799c7c3406a7e9 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 26 Sep 2012 17:13:07 -0300 Subject: [PATCH] --- yaml --- r: 323903 b: refs/heads/master c: 82fe1c290cd26a3d092beb1e9755647d284a4134 h: refs/heads/master i: 323901: 9dac2806e02435c8431a81c528ebf974d4b49398 323899: 658bfb2afd37e0f1a62974f0088ae046e6600578 323895: ec6c3f9e407fea0c7ad524d3a6496267b1811e07 323887: 8938869e7ab4cec53abf4acc6ffcc45fcc383d36 323871: b53a797af6626fb1812fe9f369a4b3ed79dbd022 323839: 8d2378fceb475f4b8fe070487a5a149709656799 v: v3 --- [refs] | 2 +- trunk/tools/perf/util/parse-events.c | 46 ++++++++++------------------ 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/[refs] b/[refs] index 24692e0558a7..fbaaa57b6d4e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e48ffe2bd49936314d367a8c6b5eaaa17d581d13 +refs/heads/master: 82fe1c290cd26a3d092beb1e9755647d284a4134 diff --git a/trunk/tools/perf/util/parse-events.c b/trunk/tools/perf/util/parse-events.c index bf5d033ee1b4..aed38e4b9dfa 100644 --- a/trunk/tools/perf/util/parse-events.c +++ b/trunk/tools/perf/util/parse-events.c @@ -356,42 +356,28 @@ int parse_events_add_cache(struct list_head **list, int *idx, return add_event(list, idx, &attr, name); } -static int add_tracepoint(struct list_head **list, int *idx, +static int add_tracepoint(struct list_head **listp, int *idx, char *sys_name, char *evt_name) { - struct perf_event_attr attr; - char name[MAX_NAME_LEN]; - char evt_path[MAXPATHLEN]; - char id_buf[4]; - u64 id; - int fd; - - snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", tracing_events_path, - sys_name, evt_name); - - fd = open(evt_path, O_RDONLY); - if (fd < 0) - return -1; + struct perf_evsel *evsel; + struct list_head *list = *listp; - if (read(fd, id_buf, sizeof(id_buf)) < 0) { - close(fd); - return -1; + if (!list) { + list = malloc(sizeof(*list)); + if (!list) + return -ENOMEM; + INIT_LIST_HEAD(list); } - close(fd); - id = atoll(id_buf); - - memset(&attr, 0, sizeof(attr)); - attr.config = id; - attr.type = PERF_TYPE_TRACEPOINT; - attr.sample_type |= PERF_SAMPLE_RAW; - attr.sample_type |= PERF_SAMPLE_TIME; - attr.sample_type |= PERF_SAMPLE_CPU; - attr.sample_type |= PERF_SAMPLE_PERIOD; - attr.sample_period = 1; + evsel = perf_evsel__newtp(sys_name, evt_name, (*idx)++); + if (!evsel) { + free(list); + return -ENOMEM; + } - snprintf(name, MAX_NAME_LEN, "%s:%s", sys_name, evt_name); - return add_event(list, idx, &attr, name); + list_add_tail(&evsel->node, list); + *listp = list; + return 0; } static int add_tracepoint_multi(struct list_head **list, int *idx,