[RFC Patch 5/5] PERF-HW_HBKPT: Display kernel symbol-name alongwith perf output

From: K.Prasad
Date: Thu Oct 29 2009 - 18:22:53 EST


Enable the kernel symbol to be shown when perf statistics are reported. This
enables the user to quickly recognise the hit counter with the symbol to which
it corresponds to.

Signed-off-by: K.Prasad <prasad@xxxxxxxxxxxxxxxxxx>
---
tools/perf/builtin-report.c | 4 ++--
tools/perf/util/parse-events.c | 18 +++++++++++-------
tools/perf/util/parse-events.h | 2 +-
3 files changed, 14 insertions(+), 10 deletions(-)

Index: linux-2.6-tip.perf_hbkpt/tools/perf/util/parse-events.c
===================================================================
--- linux-2.6-tip.perf_hbkpt.orig/tools/perf/util/parse-events.c
+++ linux-2.6-tip.perf_hbkpt/tools/perf/util/parse-events.c
@@ -285,15 +285,14 @@ static char *event_cache_name(u8 cache_t

const char *event_name(int counter)
{
- u64 config = attrs[counter].config;
- int type = attrs[counter].type;
-
- return __event_name(type, config);
+ return __event_name(&attrs[counter]);
}

-const char *__event_name(int type, u64 config)
+const char *__event_name(const struct perf_event_attr *attr)
{
- static char buf[32];
+ int type = attr->type;
+ u64 config = attr->config;
+ static char buf[256];

if (type == PERF_TYPE_RAW) {
sprintf(buf, "raw 0x%llx", config);
@@ -336,7 +335,12 @@ const char *__event_name(int type, u64 c
return tracepoint_id_to_name(config);

case PERF_TYPE_BREAKPOINT:
- return hbp_event_names[config];
+ /*
+ * Separate the breakpoint event from the kernel symbol
+ * using a ":" symbol
+ */
+ sprintf(buf, "%s:%s", hbp_event_names[config], attr->ksym_name);
+ return buf;

default:
break;
Index: linux-2.6-tip.perf_hbkpt/tools/perf/util/parse-events.h
===================================================================
--- linux-2.6-tip.perf_hbkpt.orig/tools/perf/util/parse-events.h
+++ linux-2.6-tip.perf_hbkpt/tools/perf/util/parse-events.h
@@ -20,7 +20,7 @@ extern struct perf_event_attr attrs[MAX_
extern char *filters[MAX_COUNTERS];

extern const char *event_name(int ctr);
-extern const char *__event_name(int type, u64 config);
+extern const char *__event_name(const struct perf_event_attr *attr);

extern int parse_events(const struct option *opt, const char *str, int unset);
extern int parse_filter(const struct option *opt, const char *str, int unset);
Index: linux-2.6-tip.perf_hbkpt/tools/perf/builtin-report.c
===================================================================
--- linux-2.6-tip.perf_hbkpt.orig/tools/perf/builtin-report.c
+++ linux-2.6-tip.perf_hbkpt/tools/perf/builtin-report.c
@@ -849,7 +849,7 @@ process_read_event(event_t *event, unsig
attr = perf_header__find_attr(event->read.id, header);

if (show_threads) {
- const char *name = attr ? __event_name(attr->type, attr->config)
+ const char *name = attr ? __event_name(attr)
: "unknown";
perf_read_values_add_value(&show_threads_values,
event->read.pid, event->read.tid,
@@ -863,7 +863,7 @@ process_read_event(event_t *event, unsig
(void *)(long)(event->header.size),
event->read.pid,
event->read.tid,
- attr ? __event_name(attr->type, attr->config)
+ attr ? __event_name(attr)
: "FAIL",
event->read.value);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/