From 9299aad4d213b24ceaee6bbbad5c64ca417ad158 Mon Sep 17 00:00:00 2001 From: Ashwin Chaugule Date: Sat, 17 Nov 2012 12:00:58 -0500 Subject: [PATCH] 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 --- tools/perf/util/parse-events.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 4c6a5a47012..f02e5c5770c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -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); }