Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234450
b: refs/heads/master
c: f0c55bc
h: refs/heads/master
v: v3
  • Loading branch information
Stephane Eranian authored and Arnaldo Carvalho de Melo committed Feb 17, 2011
1 parent 55b1118 commit 89f8418
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4498062e72fd55b2a9a4ac1b44fab8cb44ad5367
refs/heads/master: f0c55bcf4aa41b4b1dbee826513b1acb01bf65e1
1 change: 1 addition & 0 deletions trunk/tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void perf_evsel__delete(struct perf_evsel *evsel)
{
perf_evsel__exit(evsel);
close_cgroup(evsel->cgrp);
free(evsel->name);
free(evsel);
}

Expand Down
7 changes: 7 additions & 0 deletions trunk/tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ struct perf_sample_id {
struct perf_evsel *evsel;
};

/** struct perf_evsel - event selector
*
* @name - Can be set to retain the original event name passed by the user,
* so that when showing results in tools such as 'perf stat', we
* show the name used, not some alias.
*/
struct perf_evsel {
struct list_head node;
struct perf_event_attr attr;
Expand All @@ -45,6 +51,7 @@ struct perf_evsel {
struct xyarray *id;
struct perf_counts *counts;
int idx;
char *name;
void *priv;
struct cgroup_sel *cgrp;
};
Expand Down
10 changes: 10 additions & 0 deletions trunk/tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ const char *event_name(struct perf_evsel *evsel)
u64 config = evsel->attr.config;
int type = evsel->attr.type;

if (evsel->name)
return evsel->name;

return __event_name(type, config);
}

Expand Down Expand Up @@ -782,8 +785,10 @@ int parse_events(const struct option *opt, const char *str, int unset __used)
struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
struct perf_event_attr attr;
enum event_result ret;
const char *ostr;

for (;;) {
ostr = str;
memset(&attr, 0, sizeof(attr));
ret = parse_event_symbols(opt, &str, &attr);
if (ret == EVT_FAILED)
Expand All @@ -798,6 +803,11 @@ int parse_events(const struct option *opt, const char *str, int unset __used)
if (evsel == NULL)
return -1;
perf_evlist__add(evlist, evsel);

evsel->name = calloc(str - ostr + 1, 1);
if (!evsel->name)
return -1;
strncpy(evsel->name, ostr, str - ostr);
}

if (*str == 0)
Expand Down

0 comments on commit 89f8418

Please sign in to comment.