aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-list.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-list.c')
-rw-r--r--tools/perf/builtin-list.c84
1 files changed, 48 insertions, 36 deletions
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index e79f423cc302..011195e38f21 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -14,51 +14,63 @@
14#include "util/parse-events.h" 14#include "util/parse-events.h"
15#include "util/cache.h" 15#include "util/cache.h"
16#include "util/pmu.h" 16#include "util/pmu.h"
17#include "util/parse-options.h"
17 18
18int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) 19int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
19{ 20{
21 int i;
22 const struct option list_options[] = {
23 OPT_END()
24 };
25 const char * const list_usage[] = {
26 "perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
27 NULL
28 };
29
30 argc = parse_options(argc, argv, list_options, list_usage,
31 PARSE_OPT_STOP_AT_NON_OPTION);
32
20 setup_pager(); 33 setup_pager();
21 34
22 if (argc == 1) 35 if (argc == 0) {
23 print_events(NULL, false); 36 print_events(NULL, false);
24 else { 37 return 0;
25 int i; 38 }
26
27 for (i = 1; i < argc; ++i) {
28 if (i > 2)
29 putchar('\n');
30 if (strncmp(argv[i], "tracepoint", 10) == 0)
31 print_tracepoint_events(NULL, NULL, false);
32 else if (strcmp(argv[i], "hw") == 0 ||
33 strcmp(argv[i], "hardware") == 0)
34 print_events_type(PERF_TYPE_HARDWARE);
35 else if (strcmp(argv[i], "sw") == 0 ||
36 strcmp(argv[i], "software") == 0)
37 print_events_type(PERF_TYPE_SOFTWARE);
38 else if (strcmp(argv[i], "cache") == 0 ||
39 strcmp(argv[i], "hwcache") == 0)
40 print_hwcache_events(NULL, false);
41 else if (strcmp(argv[i], "pmu") == 0)
42 print_pmu_events(NULL, false);
43 else if (strcmp(argv[i], "--raw-dump") == 0)
44 print_events(NULL, true);
45 else {
46 char *sep = strchr(argv[i], ':'), *s;
47 int sep_idx;
48 39
49 if (sep == NULL) { 40 for (i = 0; i < argc; ++i) {
50 print_events(argv[i], false); 41 if (i)
51 continue; 42 putchar('\n');
52 } 43 if (strncmp(argv[i], "tracepoint", 10) == 0)
53 sep_idx = sep - argv[i]; 44 print_tracepoint_events(NULL, NULL, false);
54 s = strdup(argv[i]); 45 else if (strcmp(argv[i], "hw") == 0 ||
55 if (s == NULL) 46 strcmp(argv[i], "hardware") == 0)
56 return -1; 47 print_events_type(PERF_TYPE_HARDWARE);
48 else if (strcmp(argv[i], "sw") == 0 ||
49 strcmp(argv[i], "software") == 0)
50 print_events_type(PERF_TYPE_SOFTWARE);
51 else if (strcmp(argv[i], "cache") == 0 ||
52 strcmp(argv[i], "hwcache") == 0)
53 print_hwcache_events(NULL, false);
54 else if (strcmp(argv[i], "pmu") == 0)
55 print_pmu_events(NULL, false);
56 else if (strcmp(argv[i], "--raw-dump") == 0)
57 print_events(NULL, true);
58 else {
59 char *sep = strchr(argv[i], ':'), *s;
60 int sep_idx;
57 61
58 s[sep_idx] = '\0'; 62 if (sep == NULL) {
59 print_tracepoint_events(s, s + sep_idx + 1, false); 63 print_events(argv[i], false);
60 free(s); 64 continue;
61 } 65 }
66 sep_idx = sep - argv[i];
67 s = strdup(argv[i]);
68 if (s == NULL)
69 return -1;
70
71 s[sep_idx] = '\0';
72 print_tracepoint_events(s, s + sep_idx + 1, false);
73 free(s);
62 } 74 }
63 } 75 }
64 return 0; 76 return 0;