diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index f1fa7b8d1f69..88aeac9aa1da 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -43,7 +43,7 @@ static int parse_record_events(const struct option *opt, fprintf(stderr, "%-13s%-*s%s\n", e->tag, verbose ? 25 : 0, - verbose ? e->name : "", + verbose ? perf_mem_events__name(j) : "", e->supported ? ": available" : ""); } exit(0); @@ -95,12 +95,12 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem) if (!perf_mem_events[j].supported) { pr_err("failed: event '%s' not supported\n", - perf_mem_events[j].name); + perf_mem_events__name(j)); return -1; } rec_argv[i++] = "-e"; - rec_argv[i++] = perf_mem_events[j].name; + rec_argv[i++] = perf_mem_events__name(j); }; for (j = 0; j < argc; j++, i++) diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index e21853fe1312..2330db510976 100644 --- a/tools/perf/util/mem-events.c +++ b/tools/perf/util/mem-events.c @@ -19,6 +19,11 @@ struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = { #undef E +char *perf_mem_events__name(int i) +{ + return (char *)perf_mem_events[i].name; +} + int perf_mem_events__parse(const char *str) { char *tok, *saveptr = NULL; diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h index 75c1660bda62..2a91b959de62 100644 --- a/tools/perf/util/mem-events.h +++ b/tools/perf/util/mem-events.h @@ -22,4 +22,5 @@ extern struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX]; int perf_mem_events__parse(const char *str); int perf_mem_events__init(void); +char *perf_mem_events__name(int i); #endif /* __PERF_MEM_EVENTS_H */