1 /*
2 * Builtin evlist command: Show the list of event selectors present
3 * in a perf.data file.
4 */
5 #include "builtin.h"
6
7 #include "util/util.h"
8
9 /* ANDROID_CHANGE_BEGIN */
10 #if 0
11 #include <linux/list.h>
12 #else
13 #include "util/include/linux/list.h"
14 #endif
15 /* ANDROID_CHANGE_END */
16
17 #include "perf.h"
18 #include "util/evlist.h"
19 #include "util/evsel.h"
20 #include "util/parse-events.h"
21 #include "util/parse-options.h"
22 #include "util/session.h"
23
24 static char const *input_name = "perf.data";
25
__cmd_evlist(void)26 static int __cmd_evlist(void)
27 {
28 struct perf_session *session;
29 struct perf_evsel *pos;
30
31 session = perf_session__new(input_name, O_RDONLY, 0, false, NULL);
32 if (session == NULL)
33 return -ENOMEM;
34
35 list_for_each_entry(pos, &session->evlist->entries, node)
36 printf("%s\n", event_name(pos));
37
38 perf_session__delete(session);
39 return 0;
40 }
41
42 static const char * const evlist_usage[] = {
43 "perf evlist [<options>]",
44 NULL
45 };
46
47 static const struct option options[] = {
48 OPT_STRING('i', "input", &input_name, "file",
49 "input file name"),
50 OPT_END()
51 };
52
cmd_evlist(int argc,const char ** argv,const char * prefix __used)53 int cmd_evlist(int argc, const char **argv, const char *prefix __used)
54 {
55 argc = parse_options(argc, argv, options, evlist_usage, 0);
56 if (argc)
57 usage_with_options(evlist_usage, options);
58
59 return __cmd_evlist();
60 }
61