Perf: Add event modifiers to perf output

Enhance the output from perf to indicate if the
event had any user specified modifiers.
e.g. if the event was r8:u, show the ":u" in
the output as well.

Change-Id: Iac9d9047f2cd8c17d81104fb39f7546c6b8af4b6
Signed-off-by: Ashwin Chaugule <ashwinc@codeaurora.org>
This commit is contained in:
Ashwin Chaugule 2012-11-17 12:00:58 -05:00
parent 4822d74ddb
commit 9299aad4d2

View file

@ -297,9 +297,37 @@ const char *event_name(struct perf_evsel *evsel)
{
u64 config = evsel->attr.config;
int type = evsel->attr.type;
char *buf;
size_t buf_sz;
if (evsel->name) {
/* Make new space for the modifier bits. */
buf_sz = strlen(evsel->name) + 3;
buf = malloc(buf_sz);
if (!buf)
/*
* Always return what was already in 'name'.
*/
return evsel->name;
strlcpy(buf, evsel->name, buf_sz);
free(evsel->name);
evsel->name = buf;
/* User mode profiling. */
if (!evsel->attr.exclude_user && evsel->attr.exclude_kernel)
strlcpy(&evsel->name[strlen(evsel->name)], ":u",
buf_sz);
/* Kernel mode profiling. */
else if (!evsel->attr.exclude_kernel &&
evsel->attr.exclude_user)
strlcpy(&evsel->name[strlen(evsel->name)], ":k",
buf_sz);
if (evsel->name)
return evsel->name;
}
return __event_name(type, config, NULL);
}