Blame view
tools/perf/builtin-list.c
4.03 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
86847b62f perf_counter tool... |
2 3 4 5 6 7 8 |
/* * builtin-list.c * * Builtin list command: list all event types * * Copyright (C) 2009, Thomas Gleixner <tglx@linutronix.de> * Copyright (C) 2008-2009, Red Hat Inc, Ingo Molnar <mingo@redhat.com> |
668b8788f perf list: Allow ... |
9 |
* Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> |
86847b62f perf_counter tool... |
10 11 |
*/ #include "builtin.h" |
86847b62f perf_counter tool... |
12 |
#include "util/parse-events.h" |
dc098b35b perf list: List k... |
13 |
#include "util/pmu.h" |
f23610245 perf list: Add de... |
14 |
#include "util/debug.h" |
71b0acce7 perf list: Add me... |
15 |
#include "util/metricgroup.h" |
fa0d98462 perf tools: Remov... |
16 |
#include <subcmd/pager.h> |
4b6ab94ea perf subcmd: Crea... |
17 |
#include <subcmd/parse-options.h> |
8520a98db perf debug: Remov... |
18 |
#include <stdio.h> |
86847b62f perf_counter tool... |
19 |
|
1c5f01fe8 perf list: Add a ... |
20 |
static bool desc_flag = true; |
bf874fcf9 perf list: Move e... |
21 |
static bool details_flag; |
1c5f01fe8 perf list: Add a ... |
22 |
|
b0ad8ea66 perf tools: Remov... |
23 |
int cmd_list(int argc, const char **argv) |
86847b62f perf_counter tool... |
24 |
{ |
8e00ddc9d perf list: Remove... |
25 |
int i; |
b35052088 perf list: Fix --... |
26 |
bool raw_dump = false; |
c8d6828a6 perf list: Suppor... |
27 |
bool long_desc_flag = false; |
a7f6c8c81 perf list: Hide d... |
28 |
bool deprecated = false; |
b35052088 perf list: Fix --... |
29 30 |
struct option list_options[] = { OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"), |
1c5f01fe8 perf list: Add a ... |
31 32 |
OPT_BOOLEAN('d', "desc", &desc_flag, "Print extra event descriptions. --no-desc to not print."), |
c8d6828a6 perf list: Suppor... |
33 34 |
OPT_BOOLEAN('v', "long-desc", &long_desc_flag, "Print longer event descriptions."), |
bf874fcf9 perf list: Move e... |
35 36 |
OPT_BOOLEAN(0, "details", &details_flag, "Print information on the perf event names and expressions used internally by events."), |
a7f6c8c81 perf list: Hide d... |
37 38 |
OPT_BOOLEAN(0, "deprecated", &deprecated, "Print deprecated events."), |
f23610245 perf list: Add de... |
39 40 |
OPT_INCR(0, "debug", &verbose, "Enable debugging output"), |
44d742e01 perf list: Add usage |
41 42 43 |
OPT_END() }; const char * const list_usage[] = { |
a90a1c54a perf list: Add me... |
44 |
"perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|metric|metricgroup|event_glob]", |
44d742e01 perf list: Add usage |
45 46 |
NULL }; |
b35052088 perf list: Fix --... |
47 |
set_option_flag(list_options, 0, "raw-dump", PARSE_OPT_HIDDEN); |
44d742e01 perf list: Add usage |
48 49 |
argc = parse_options(argc, argv, list_options, list_usage, PARSE_OPT_STOP_AT_NON_OPTION); |
8e00ddc9d perf list: Remove... |
50 |
|
8f7a0dc51 perf list: Fix la... |
51 |
setup_pager(); |
668b8788f perf list: Allow ... |
52 |
|
dfc431cbd perf list: Remove... |
53 |
if (!raw_dump && pager_in_use()) |
619a303c1 perf list: Place ... |
54 55 56 57 |
printf(" List of pre-defined events (to be used in -e): "); |
44d742e01 perf list: Add usage |
58 |
if (argc == 0) { |
bf874fcf9 perf list: Move e... |
59 |
print_events(NULL, raw_dump, !desc_flag, long_desc_flag, |
a7f6c8c81 perf list: Hide d... |
60 |
details_flag, deprecated); |
8e00ddc9d perf list: Remove... |
61 62 |
return 0; } |
668b8788f perf list: Allow ... |
63 |
|
44d742e01 perf list: Add usage |
64 |
for (i = 0; i < argc; ++i) { |
dbc67409f perf list: Do eve... |
65 |
char *sep, *s; |
161149513 perf list: Allow ... |
66 |
if (strcmp(argv[i], "tracepoint") == 0) |
5ef803ee0 perf list: Extend... |
67 |
print_tracepoint_events(NULL, NULL, raw_dump); |
8e00ddc9d perf list: Remove... |
68 69 |
else if (strcmp(argv[i], "hw") == 0 || strcmp(argv[i], "hardware") == 0) |
705750f2d perf list: Clean ... |
70 |
print_symbol_events(NULL, PERF_TYPE_HARDWARE, |
5ef803ee0 perf list: Extend... |
71 |
event_symbols_hw, PERF_COUNT_HW_MAX, raw_dump); |
8e00ddc9d perf list: Remove... |
72 |
else if (strcmp(argv[i], "sw") == 0 || |
5e0861baa perf list: Output... |
73 |
strcmp(argv[i], "software") == 0) { |
705750f2d perf list: Clean ... |
74 |
print_symbol_events(NULL, PERF_TYPE_SOFTWARE, |
5ef803ee0 perf list: Extend... |
75 |
event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump); |
5e0861baa perf list: Output... |
76 77 |
print_tool_events(NULL, raw_dump); } else if (strcmp(argv[i], "cache") == 0 || |
8e00ddc9d perf list: Remove... |
78 |
strcmp(argv[i], "hwcache") == 0) |
5ef803ee0 perf list: Extend... |
79 |
print_hwcache_events(NULL, raw_dump); |
8e00ddc9d perf list: Remove... |
80 |
else if (strcmp(argv[i], "pmu") == 0) |
c8d6828a6 perf list: Suppor... |
81 |
print_pmu_events(NULL, raw_dump, !desc_flag, |
a7f6c8c81 perf list: Hide d... |
82 83 |
long_desc_flag, details_flag, deprecated); |
40218daea perf list: Show S... |
84 85 |
else if (strcmp(argv[i], "sdt") == 0) print_sdt_events(NULL, NULL, raw_dump); |
8788d3695 perf list: Allow ... |
86 |
else if (strcmp(argv[i], "metric") == 0 || strcmp(argv[i], "metrics") == 0) |
33bbc571e perf list: Displa... |
87 |
metricgroup__print(true, false, NULL, raw_dump, details_flag); |
8788d3695 perf list: Allow ... |
88 |
else if (strcmp(argv[i], "metricgroup") == 0 || strcmp(argv[i], "metricgroups") == 0) |
33bbc571e perf list: Displa... |
89 |
metricgroup__print(false, true, NULL, raw_dump, details_flag); |
dbc67409f perf list: Do eve... |
90 |
else if ((sep = strchr(argv[i], ':')) != NULL) { |
8e00ddc9d perf list: Remove... |
91 |
int sep_idx; |
668b8788f perf list: Allow ... |
92 |
|
8e00ddc9d perf list: Remove... |
93 94 95 96 97 98 |
sep_idx = sep - argv[i]; s = strdup(argv[i]); if (s == NULL) return -1; s[sep_idx] = '\0'; |
5ef803ee0 perf list: Extend... |
99 |
print_tracepoint_events(s, s + sep_idx + 1, raw_dump); |
40218daea perf list: Show S... |
100 |
print_sdt_events(s, s + sep_idx + 1, raw_dump); |
33bbc571e perf list: Displa... |
101 |
metricgroup__print(true, true, s, raw_dump, details_flag); |
8e00ddc9d perf list: Remove... |
102 |
free(s); |
dbc67409f perf list: Do eve... |
103 104 105 106 107 108 109 110 111 112 |
} else { if (asprintf(&s, "*%s*", argv[i]) < 0) { printf("Critical: Not enough memory! Trying to continue... "); continue; } print_symbol_events(s, PERF_TYPE_HARDWARE, event_symbols_hw, PERF_COUNT_HW_MAX, raw_dump); print_symbol_events(s, PERF_TYPE_SOFTWARE, event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump); |
5e0861baa perf list: Output... |
113 |
print_tool_events(s, raw_dump); |
dbc67409f perf list: Do eve... |
114 |
print_hwcache_events(s, raw_dump); |
c8d6828a6 perf list: Suppor... |
115 |
print_pmu_events(s, raw_dump, !desc_flag, |
bf874fcf9 perf list: Move e... |
116 |
long_desc_flag, |
a7f6c8c81 perf list: Hide d... |
117 118 |
details_flag, deprecated); |
dbc67409f perf list: Do eve... |
119 |
print_tracepoint_events(NULL, s, raw_dump); |
40218daea perf list: Show S... |
120 |
print_sdt_events(NULL, s, raw_dump); |
6f40b2a5d perf list: Filter... |
121 |
metricgroup__print(true, true, s, raw_dump, details_flag); |
dbc67409f perf list: Do eve... |
122 |
free(s); |
668b8788f perf list: Allow ... |
123 124 |
} } |
86847b62f perf_counter tool... |
125 126 |
return 0; } |