event__name[] is missing an entry for PERF_RECORD_FINISHED_ROUND, but we happily access the array from the dump code. Make event__name[] static and provide an accessor function, fix up all callers and add the missing string. Signed-off-by: Thomas Gleixner --- tools/perf/util/event.c | 12 +++++++++++- tools/perf/util/event.h | 2 +- tools/perf/util/hist.c | 9 ++++++--- tools/perf/util/session.c | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) Index: linux-2.6-tip/tools/perf/util/event.c =================================================================== --- linux-2.6-tip.orig/tools/perf/util/event.c +++ linux-2.6-tip/tools/perf/util/event.c @@ -7,7 +7,7 @@ #include "strlist.h" #include "thread.h" -const char *event__name[] = { +static const char *event__name[] = { [0] = "TOTAL", [PERF_RECORD_MMAP] = "MMAP", [PERF_RECORD_LOST] = "LOST", @@ -22,8 +22,18 @@ const char *event__name[] = { [PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE", [PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA", [PERF_RECORD_HEADER_BUILD_ID] = "BUILD_ID", + [PERF_RECORD_FINISHED_ROUND] = "FINISHED_ROUND", }; +const char *event__get_event_name(unsigned int id) +{ + if (id >= ARRAY_SIZE(event__name)) + return "INVALID"; + if (!event__name[id]) + return "UNKNOWN"; + return event__name[id]; +} + static struct sample_data synth_sample = { .pid = -1, .tid = -1, Index: linux-2.6-tip/tools/perf/util/event.h =================================================================== --- linux-2.6-tip.orig/tools/perf/util/event.h +++ linux-2.6-tip/tools/perf/util/event.h @@ -171,6 +171,6 @@ int event__preprocess_sample(const event int event__parse_sample(const event_t *event, struct perf_session *session, struct sample_data *sample); -extern const char *event__name[]; +const char *event__get_event_name(unsigned int id); #endif /* __PERF_RECORD_H */ Index: linux-2.6-tip/tools/perf/util/hist.c =================================================================== --- linux-2.6-tip.orig/tools/perf/util/hist.c +++ linux-2.6-tip/tools/perf/util/hist.c @@ -1168,10 +1168,13 @@ size_t hists__fprintf_nr_events(struct h size_t ret = 0; for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) { - if (!event__name[i]) + const char *name = event__get_event_name(i); + + if (!strcmp(name, "UNKNOWN")) continue; - ret += fprintf(fp, "%10s events: %10d\n", - event__name[i], self->stats.nr_events[i]); + + ret += fprintf(fp, "%16s events: %10d\n", name, + self->stats.nr_events[i]); } return ret; Index: linux-2.6-tip/tools/perf/util/session.c =================================================================== --- linux-2.6-tip.orig/tools/perf/util/session.c +++ linux-2.6-tip/tools/perf/util/session.c @@ -718,7 +718,7 @@ static int perf_session__process_event(s if (event->header.type < PERF_RECORD_HEADER_MAX) { dump_printf("%#Lx [%#x]: PERF_RECORD_%s", file_offset, event->header.size, - event__name[event->header.type]); + event__get_event_name(event->header.type)); hists__inc_nr_events(&session->hists, event->header.type); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/