~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/builtin-list.c

Version: ~ [ linux-6.4-rc3 ] ~ [ linux-6.3.4 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.30 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.113 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.180 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.243 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.283 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.315 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * builtin-list.c
  4  *
  5  * Builtin list command: list all event types
  6  *
  7  * Copyright (C) 2009, Thomas Gleixner <tglx@linutronix.de>
  8  * Copyright (C) 2008-2009, Red Hat Inc, Ingo Molnar <mingo@redhat.com>
  9  * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
 10  */
 11 #include "builtin.h"
 12 
 13 #include "util/parse-events.h"
 14 #include "util/pmu.h"
 15 #include "util/pmu-hybrid.h"
 16 #include "util/debug.h"
 17 #include "util/metricgroup.h"
 18 #include <subcmd/pager.h>
 19 #include <subcmd/parse-options.h>
 20 #include <stdio.h>
 21 
 22 static bool desc_flag = true;
 23 static bool details_flag;
 24 static const char *hybrid_type;
 25 
 26 int cmd_list(int argc, const char **argv)
 27 {
 28         int i, ret = 0;
 29         bool raw_dump = false;
 30         bool long_desc_flag = false;
 31         bool deprecated = false;
 32         char *pmu_name = NULL;
 33         struct option list_options[] = {
 34                 OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"),
 35                 OPT_BOOLEAN('d', "desc", &desc_flag,
 36                             "Print extra event descriptions. --no-desc to not print."),
 37                 OPT_BOOLEAN('v', "long-desc", &long_desc_flag,
 38                             "Print longer event descriptions."),
 39                 OPT_BOOLEAN(0, "details", &details_flag,
 40                             "Print information on the perf event names and expressions used internally by events."),
 41                 OPT_BOOLEAN(0, "deprecated", &deprecated,
 42                             "Print deprecated events."),
 43                 OPT_STRING(0, "cputype", &hybrid_type, "hybrid cpu type",
 44                            "Print events applying cpu with this type for hybrid platform "
 45                            "(e.g. core or atom)"),
 46                 OPT_INCR(0, "debug", &verbose,
 47                              "Enable debugging output"),
 48                 OPT_END()
 49         };
 50         const char * const list_usage[] = {
 51                 "perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|metric|metricgroup|event_glob]",
 52                 NULL
 53         };
 54 
 55         set_option_flag(list_options, 0, "raw-dump", PARSE_OPT_HIDDEN);
 56 
 57         argc = parse_options(argc, argv, list_options, list_usage,
 58                              PARSE_OPT_STOP_AT_NON_OPTION);
 59 
 60         setup_pager();
 61 
 62         if (!raw_dump && pager_in_use())
 63                 printf("\nList of pre-defined events (to be used in -e):\n\n");
 64 
 65         if (hybrid_type) {
 66                 pmu_name = perf_pmu__hybrid_type_to_pmu(hybrid_type);
 67                 if (!pmu_name)
 68                         pr_warning("WARNING: hybrid cputype is not supported!\n");
 69         }
 70 
 71         if (argc == 0) {
 72                 print_events(NULL, raw_dump, !desc_flag, long_desc_flag,
 73                                 details_flag, deprecated, pmu_name);
 74                 goto out;
 75         }
 76 
 77         for (i = 0; i < argc; ++i) {
 78                 char *sep, *s;
 79 
 80                 if (strcmp(argv[i], "tracepoint") == 0)
 81                         print_tracepoint_events(NULL, NULL, raw_dump);
 82                 else if (strcmp(argv[i], "hw") == 0 ||
 83                          strcmp(argv[i], "hardware") == 0)
 84                         print_symbol_events(NULL, PERF_TYPE_HARDWARE,
 85                                         event_symbols_hw, PERF_COUNT_HW_MAX, raw_dump);
 86                 else if (strcmp(argv[i], "sw") == 0 ||
 87                          strcmp(argv[i], "software") == 0) {
 88                         print_symbol_events(NULL, PERF_TYPE_SOFTWARE,
 89                                         event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
 90                         print_tool_events(NULL, raw_dump);
 91                 } else if (strcmp(argv[i], "cache") == 0 ||
 92                          strcmp(argv[i], "hwcache") == 0)
 93                         print_hwcache_events(NULL, raw_dump);
 94                 else if (strcmp(argv[i], "pmu") == 0)
 95                         print_pmu_events(NULL, raw_dump, !desc_flag,
 96                                                 long_desc_flag, details_flag,
 97                                                 deprecated, pmu_name);
 98                 else if (strcmp(argv[i], "sdt") == 0)
 99                         print_sdt_events(NULL, NULL, raw_dump);
100                 else if (strcmp(argv[i], "metric") == 0 || strcmp(argv[i], "metrics") == 0)
101                         metricgroup__print(true, false, NULL, raw_dump, details_flag, pmu_name);
102                 else if (strcmp(argv[i], "metricgroup") == 0 || strcmp(argv[i], "metricgroups") == 0)
103                         metricgroup__print(false, true, NULL, raw_dump, details_flag, pmu_name);
104                 else if ((sep = strchr(argv[i], ':')) != NULL) {
105                         int sep_idx;
106 
107                         sep_idx = sep - argv[i];
108                         s = strdup(argv[i]);
109                         if (s == NULL) {
110                                 ret = -1;
111                                 goto out;
112                         }
113 
114                         s[sep_idx] = '\0';
115                         print_tracepoint_events(s, s + sep_idx + 1, raw_dump);
116                         print_sdt_events(s, s + sep_idx + 1, raw_dump);
117                         metricgroup__print(true, true, s, raw_dump, details_flag, pmu_name);
118                         free(s);
119                 } else {
120                         if (asprintf(&s, "*%s*", argv[i]) < 0) {
121                                 printf("Critical: Not enough memory! Trying to continue...\n");
122                                 continue;
123                         }
124                         print_symbol_events(s, PERF_TYPE_HARDWARE,
125                                             event_symbols_hw, PERF_COUNT_HW_MAX, raw_dump);
126                         print_symbol_events(s, PERF_TYPE_SOFTWARE,
127                                             event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
128                         print_tool_events(s, raw_dump);
129                         print_hwcache_events(s, raw_dump);
130                         print_pmu_events(s, raw_dump, !desc_flag,
131                                                 long_desc_flag,
132                                                 details_flag,
133                                                 deprecated,
134                                                 pmu_name);
135                         print_tracepoint_events(NULL, s, raw_dump);
136                         print_sdt_events(NULL, s, raw_dump);
137                         metricgroup__print(true, true, s, raw_dump, details_flag, pmu_name);
138                         free(s);
139                 }
140         }
141 
142 out:
143         free(pmu_name);
144         return ret;
145 }
146 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp