]> git.ipfire.org Git - thirdparty/linux.git/blame - tools/perf/builtin-evlist.c
tcp: add tcp_min_snd_mss sysctl
[thirdparty/linux.git] / tools / perf / builtin-evlist.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
43adec95
ACM
2/*
3 * Builtin evlist command: Show the list of event selectors present
4 * in a perf.data file.
5 */
6#include "builtin.h"
7
8#include "util/util.h"
9
10#include <linux/list.h>
11
12#include "perf.h"
13#include "util/evlist.h"
14#include "util/evsel.h"
15#include "util/parse-events.h"
4b6ab94e 16#include <subcmd/parse-options.h>
43adec95 17#include "util/session.h"
f5fc1412 18#include "util/data.h"
84f5d36f 19#include "util/debug.h"
43adec95 20
70cb4e96 21static int __cmd_evlist(const char *file_name, struct perf_attr_details *details)
43adec95
ACM
22{
23 struct perf_session *session;
24 struct perf_evsel *pos;
8ceb41d7 25 struct perf_data data = {
2d4f2799 26 .path = file_name,
eae8ad80
JO
27 .mode = PERF_DATA_MODE_READ,
28 .force = details->force,
f5fc1412 29 };
775d8a1b 30 bool has_tracepoint = false;
43adec95 31
8ceb41d7 32 session = perf_session__new(&data, 0, NULL);
43adec95 33 if (session == NULL)
52e02834 34 return -1;
43adec95 35
e5cadb93 36 evlist__for_each_entry(session->evlist, pos) {
0698aedd 37 perf_evsel__fprintf(pos, details, stdout);
43adec95 38
775d8a1b
NK
39 if (pos->attr.type == PERF_TYPE_TRACEPOINT)
40 has_tracepoint = true;
41 }
42
43 if (has_tracepoint && !details->trace_fields)
44 printf("# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events\n");
45
43adec95
ACM
46 perf_session__delete(session);
47 return 0;
48}
49
b0ad8ea6 50int cmd_evlist(int argc, const char **argv)
43adec95 51{
26252ea6 52 struct perf_attr_details details = { .verbose = false, };
26252ea6 53 const struct option options[] = {
94d668d0
ACM
54 OPT_STRING('i', "input", &input_name, "file", "Input file name"),
55 OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"),
56 OPT_BOOLEAN('v', "verbose", &details.verbose,
57 "Show all event attr details"),
e35ef355 58 OPT_BOOLEAN('g', "group", &details.event_group,
e6ab07d0 59 "Show event group information"),
9e3b6ec1 60 OPT_BOOLEAN('f', "force", &details.force, "don't complain, do it"),
775d8a1b 61 OPT_BOOLEAN(0, "trace-fields", &details.trace_fields, "Show tracepoint fields"),
94d668d0
ACM
62 OPT_END()
63 };
64 const char * const evlist_usage[] = {
65 "perf evlist [<options>]",
66 NULL
26252ea6
ACM
67 };
68
43adec95
ACM
69 argc = parse_options(argc, argv, options, evlist_usage, 0);
70 if (argc)
71 usage_with_options(evlist_usage, options);
72
e35ef355 73 if (details.event_group && (details.verbose || details.freq)) {
c7118369
NK
74 usage_with_options_msg(evlist_usage, options,
75 "--group option is not compatible with other options\n");
e6ab07d0
NK
76 }
77
26252ea6 78 return __cmd_evlist(input_name, &details);
43adec95 79}