Skip to content

Commit f236102

Browse files
Andi Kleenacmel
authored andcommitted
perf list: Add debug support for outputing alias string
For debugging and testing it is useful to see the converted alias string. Add support to perf stat/record and perf list to print the alias conversion. The text string is saved in the alias structure. For perf stat/record it is folded into the normal -v. For perf list -v was taken, so we use --debug. Before: % perf list ... cache: l1d.replacement [L1D data line replacements] l1d_pend_miss.fb_full [Cycles a demand request was blocked due to Fill Buffers inavailability] After % perf list --debug ... cache: l1d.replacement [L1D data line replacements] cpu/umask=0x1,period=2000003,event=0x51/ l1d_pend_miss.fb_full [Cycles a demand request was blocked due to Fill Buffers inavailability] cpu/umask=0x2,period=2000003,cmask=1,event=0x48/ Signed-off-by: Andi Kleen <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 231bb2a commit f236102

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

tools/perf/builtin-list.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "util/parse-events.h"
1515
#include "util/cache.h"
1616
#include "util/pmu.h"
17+
#include "util/debug.h"
1718
#include <subcmd/parse-options.h>
1819

1920
static bool desc_flag = true;
@@ -29,6 +30,8 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
2930
"Print extra event descriptions. --no-desc to not print."),
3031
OPT_BOOLEAN('v', "long-desc", &long_desc_flag,
3132
"Print longer event descriptions."),
33+
OPT_INCR(0, "debug", &verbose,
34+
"Enable debugging output"),
3235
OPT_END()
3336
};
3437
const char * const list_usage[] = {

tools/perf/util/parse-events.y

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/types.h>
1414
#include "util.h"
1515
#include "pmu.h"
16+
#include "debug.h"
1617
#include "parse-events.h"
1718
#include "parse-events-bison.h"
1819

@@ -254,6 +255,8 @@ PE_KERNEL_PMU_EVENT sep_dc
254255

255256
if (!parse_events_add_pmu(data, list,
256257
pmu->name, head)) {
258+
pr_debug("%s -> %s/%s/\n", $1,
259+
pmu->name, alias->str);
257260
ok++;
258261
}
259262

tools/perf/util/pmu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
275275
snprintf(alias->unit, sizeof(alias->unit), "%s", unit);
276276
}
277277
alias->per_pkg = perpkg && sscanf(perpkg, "%d", &num) == 1 && num == 1;
278+
alias->str = strdup(val);
279+
278280
list_add_tail(&alias->list, list);
279281

280282
return 0;
@@ -1087,6 +1089,8 @@ struct sevent {
10871089
char *name;
10881090
char *desc;
10891091
char *topic;
1092+
char *str;
1093+
char *pmu;
10901094
};
10911095

10921096
static int cmp_sevent(const void *a, const void *b)
@@ -1183,6 +1187,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
11831187
aliases[j].desc = long_desc ? alias->long_desc :
11841188
alias->desc;
11851189
aliases[j].topic = alias->topic;
1190+
aliases[j].str = alias->str;
1191+
aliases[j].pmu = pmu->name;
11861192
j++;
11871193
}
11881194
if (pmu->selectable &&
@@ -1217,6 +1223,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
12171223
printf("%*s", 8, "[");
12181224
wordwrap(aliases[j].desc, 8, columns, 0);
12191225
printf("]\n");
1226+
if (verbose)
1227+
printf("%*s%s/%s/\n", 8, "", aliases[j].pmu, aliases[j].str);
12201228
} else
12211229
printf(" %-50s [Kernel PMU event]\n", aliases[j].name);
12221230
printed++;

tools/perf/util/pmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct perf_pmu_alias {
4343
char *desc;
4444
char *long_desc;
4545
char *topic;
46+
char *str;
4647
struct list_head terms; /* HEAD struct parse_events_term -> list */
4748
struct list_head list; /* ELEM */
4849
char unit[UNIT_MAX_LEN+1];

0 commit comments

Comments
 (0)