Blame view
tools/perf/builtin-evlist.c
2.17 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
43adec955 perf evlist: New ... |
2 3 4 5 6 |
/* * Builtin evlist command: Show the list of event selectors present * in a perf.data file. */ #include "builtin.h" |
43adec955 perf evlist: New ... |
7 8 9 10 11 |
#include <linux/list.h> #include "perf.h" #include "util/evlist.h" #include "util/evsel.h" |
ca1252779 perf evsel: Intro... |
12 |
#include "util/evsel_fprintf.h" |
43adec955 perf evlist: New ... |
13 |
#include "util/parse-events.h" |
4b6ab94ea perf subcmd: Crea... |
14 |
#include <subcmd/parse-options.h> |
43adec955 perf evlist: New ... |
15 |
#include "util/session.h" |
f5fc14124 perf tools: Add d... |
16 |
#include "util/data.h" |
84f5d36f4 perf tools: Move ... |
17 |
#include "util/debug.h" |
6ef81c55a perf session: Ret... |
18 |
#include <linux/err.h> |
43adec955 perf evlist: New ... |
19 |
|
70cb4e963 perf tools: Add a... |
20 |
static int __cmd_evlist(const char *file_name, struct perf_attr_details *details) |
43adec955 perf evlist: New ... |
21 22 |
{ struct perf_session *session; |
32dcd021d perf evsel: Renam... |
23 |
struct evsel *pos; |
8ceb41d7e perf tools: Renam... |
24 |
struct perf_data data = { |
2d4f27999 perf data: Add gl... |
25 |
.path = file_name, |
eae8ad804 perf tools: Add s... |
26 27 |
.mode = PERF_DATA_MODE_READ, .force = details->force, |
f5fc14124 perf tools: Add d... |
28 |
}; |
775d8a1b0 perf evlist: Add ... |
29 |
bool has_tracepoint = false; |
43adec955 perf evlist: New ... |
30 |
|
8ceb41d7e perf tools: Renam... |
31 |
session = perf_session__new(&data, 0, NULL); |
6ef81c55a perf session: Ret... |
32 33 |
if (IS_ERR(session)) return PTR_ERR(session); |
43adec955 perf evlist: New ... |
34 |
|
e5cadb93d perf evlist: Rena... |
35 |
evlist__for_each_entry(session->evlist, pos) { |
2dbfc9451 perf evsel: Renam... |
36 |
evsel__fprintf(pos, details, stdout); |
43adec955 perf evlist: New ... |
37 |
|
1fc632cef libperf: Move per... |
38 |
if (pos->core.attr.type == PERF_TYPE_TRACEPOINT) |
775d8a1b0 perf evlist: Add ... |
39 40 41 42 43 44 |
has_tracepoint = true; } if (has_tracepoint && !details->trace_fields) printf("# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events "); |
43adec955 perf evlist: New ... |
45 46 47 |
perf_session__delete(session); return 0; } |
b0ad8ea66 perf tools: Remov... |
48 |
int cmd_evlist(int argc, const char **argv) |
43adec955 perf evlist: New ... |
49 |
{ |
26252ea67 perf evlist: Show... |
50 |
struct perf_attr_details details = { .verbose = false, }; |
26252ea67 perf evlist: Show... |
51 |
const struct option options[] = { |
94d668d07 perf evlist: Don'... |
52 53 54 55 |
OPT_STRING('i', "input", &input_name, "file", "Input file name"), OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"), OPT_BOOLEAN('v', "verbose", &details.verbose, "Show all event attr details"), |
e35ef355a perf evlist: Pass... |
56 |
OPT_BOOLEAN('g', "group", &details.event_group, |
e6ab07d02 perf evlist: Add ... |
57 |
"Show event group information"), |
9e3b6ec17 perf evlist: Supp... |
58 |
OPT_BOOLEAN('f', "force", &details.force, "don't complain, do it"), |
775d8a1b0 perf evlist: Add ... |
59 |
OPT_BOOLEAN(0, "trace-fields", &details.trace_fields, "Show tracepoint fields"), |
94d668d07 perf evlist: Don'... |
60 61 62 63 64 |
OPT_END() }; const char * const evlist_usage[] = { "perf evlist [<options>]", NULL |
26252ea67 perf evlist: Show... |
65 |
}; |
43adec955 perf evlist: New ... |
66 67 68 |
argc = parse_options(argc, argv, options, evlist_usage, 0); if (argc) usage_with_options(evlist_usage, options); |
e35ef355a perf evlist: Pass... |
69 |
if (details.event_group && (details.verbose || details.freq)) { |
c71183697 perf tools: Intro... |
70 71 72 |
usage_with_options_msg(evlist_usage, options, "--group option is not compatible with other options "); |
e6ab07d02 perf evlist: Add ... |
73 |
} |
26252ea67 perf evlist: Show... |
74 |
return __cmd_evlist(input_name, &details); |
43adec955 perf evlist: New ... |
75 |
} |