1 #include "../../../include/linux/hw_breakpoint.h"
6 #include "parse-options.h"
7 #include "parse-events.h"
28 #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
29 #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
31 static struct event_symbol event_symbols[] = {
32 { CHW(CPU_CYCLES), "cpu-cycles", "cycles" },
33 { CHW(STALLED_CYCLES_FRONTEND), "stalled-cycles-frontend", "idle-cycles-frontend" },
34 { CHW(STALLED_CYCLES_BACKEND), "stalled-cycles-backend", "idle-cycles-backend" },
35 { CHW(INSTRUCTIONS), "instructions", "" },
36 { CHW(CACHE_REFERENCES), "cache-references", "" },
37 { CHW(CACHE_MISSES), "cache-misses", "" },
38 { CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" },
39 { CHW(BRANCH_MISSES), "branch-misses", "" },
40 { CHW(BUS_CYCLES), "bus-cycles", "" },
42 { CSW(CPU_CLOCK), "cpu-clock", "" },
43 { CSW(TASK_CLOCK), "task-clock", "" },
44 { CSW(PAGE_FAULTS), "page-faults", "faults" },
45 { CSW(PAGE_FAULTS_MIN), "minor-faults", "" },
46 { CSW(PAGE_FAULTS_MAJ), "major-faults", "" },
47 { CSW(CONTEXT_SWITCHES), "context-switches", "cs" },
48 { CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" },
49 { CSW(ALIGNMENT_FAULTS), "alignment-faults", "" },
50 { CSW(EMULATION_FAULTS), "emulation-faults", "" },
53 #define __PERF_EVENT_FIELD(config, name) \
54 ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT)
56 #define PERF_EVENT_RAW(config) __PERF_EVENT_FIELD(config, RAW)
57 #define PERF_EVENT_CONFIG(config) __PERF_EVENT_FIELD(config, CONFIG)
58 #define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE)
59 #define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT)
61 static const char *hw_event_names[PERF_COUNT_HW_MAX] = {
69 "stalled-cycles-frontend",
70 "stalled-cycles-backend",
73 static const char *sw_event_names[PERF_COUNT_SW_MAX] = {
87 static const char *hw_cache[PERF_COUNT_HW_CACHE_MAX][MAX_ALIASES] = {
88 { "L1-dcache", "l1-d", "l1d", "L1-data", },
89 { "L1-icache", "l1-i", "l1i", "L1-instruction", },
91 { "dTLB", "d-tlb", "Data-TLB", },
92 { "iTLB", "i-tlb", "Instruction-TLB", },
93 { "branch", "branches", "bpu", "btb", "bpc", },
97 static const char *hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][MAX_ALIASES] = {
98 { "load", "loads", "read", },
99 { "store", "stores", "write", },
100 { "prefetch", "prefetches", "speculative-read", "speculative-load", },
103 static const char *hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX]
105 { "refs", "Reference", "ops", "access", },
106 { "misses", "miss", },
109 #define C(x) PERF_COUNT_HW_CACHE_##x
110 #define CACHE_READ (1 << C(OP_READ))
111 #define CACHE_WRITE (1 << C(OP_WRITE))
112 #define CACHE_PREFETCH (1 << C(OP_PREFETCH))
113 #define COP(x) (1 << x)
116 * cache operartion stat
117 * L1I : Read and prefetch only
118 * ITLB and BPU : Read-only
120 static unsigned long hw_cache_stat[C(MAX)] = {
121 [C(L1D)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
122 [C(L1I)] = (CACHE_READ | CACHE_PREFETCH),
123 [C(LL)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
124 [C(DTLB)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
125 [C(ITLB)] = (CACHE_READ),
126 [C(BPU)] = (CACHE_READ),
127 [C(NODE)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
130 #define for_each_subsystem(sys_dir, sys_dirent, sys_next) \
131 while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \
132 if (sys_dirent.d_type == DT_DIR && \
133 (strcmp(sys_dirent.d_name, ".")) && \
134 (strcmp(sys_dirent.d_name, "..")))
136 static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir)
138 char evt_path[MAXPATHLEN];
141 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", tracing_events_path,
142 sys_dir->d_name, evt_dir->d_name);
143 fd = open(evt_path, O_RDONLY);
151 #define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) \
152 while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \
153 if (evt_dirent.d_type == DT_DIR && \
154 (strcmp(evt_dirent.d_name, ".")) && \
155 (strcmp(evt_dirent.d_name, "..")) && \
156 (!tp_event_has_id(&sys_dirent, &evt_dirent)))
158 #define MAX_EVENT_LENGTH 512
161 struct tracepoint_path *tracepoint_id_to_path(u64 config)
163 struct tracepoint_path *path = NULL;
164 DIR *sys_dir, *evt_dir;
165 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
169 char evt_path[MAXPATHLEN];
170 char dir_path[MAXPATHLEN];
172 if (debugfs_valid_mountpoint(tracing_events_path))
175 sys_dir = opendir(tracing_events_path);
179 for_each_subsystem(sys_dir, sys_dirent, sys_next) {
181 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,
183 evt_dir = opendir(dir_path);
187 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) {
189 snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,
191 fd = open(evt_path, O_RDONLY);
194 if (read(fd, id_buf, sizeof(id_buf)) < 0) {
203 path = zalloc(sizeof(*path));
204 path->system = malloc(MAX_EVENT_LENGTH);
209 path->name = malloc(MAX_EVENT_LENGTH);
215 strncpy(path->system, sys_dirent.d_name,
217 strncpy(path->name, evt_dirent.d_name,
229 #define TP_PATH_LEN (MAX_EVENT_LENGTH * 2 + 1)
230 static const char *tracepoint_id_to_name(u64 config)
232 static char buf[TP_PATH_LEN];
233 struct tracepoint_path *path;
235 path = tracepoint_id_to_path(config);
237 snprintf(buf, TP_PATH_LEN, "%s:%s", path->system, path->name);
242 snprintf(buf, TP_PATH_LEN, "%s:%s", "unknown", "unknown");
247 static int is_cache_op_valid(u8 cache_type, u8 cache_op)
249 if (hw_cache_stat[cache_type] & COP(cache_op))
250 return 1; /* valid */
252 return 0; /* invalid */
255 static char *event_cache_name(u8 cache_type, u8 cache_op, u8 cache_result)
257 static char name[50];
260 sprintf(name, "%s-%s-%s", hw_cache[cache_type][0],
261 hw_cache_op[cache_op][0],
262 hw_cache_result[cache_result][0]);
264 sprintf(name, "%s-%s", hw_cache[cache_type][0],
265 hw_cache_op[cache_op][1]);
271 const char *event_type(int type)
274 case PERF_TYPE_HARDWARE:
277 case PERF_TYPE_SOFTWARE:
280 case PERF_TYPE_TRACEPOINT:
283 case PERF_TYPE_HW_CACHE:
284 return "hardware-cache";
293 const char *event_name(struct perf_evsel *evsel)
295 u64 config = evsel->attr.config;
296 int type = evsel->attr.type;
301 return __event_name(type, config);
304 const char *__event_name(int type, u64 config)
308 if (type == PERF_TYPE_RAW) {
309 sprintf(buf, "raw 0x%" PRIx64, config);
314 case PERF_TYPE_HARDWARE:
315 if (config < PERF_COUNT_HW_MAX && hw_event_names[config])
316 return hw_event_names[config];
317 return "unknown-hardware";
319 case PERF_TYPE_HW_CACHE: {
320 u8 cache_type, cache_op, cache_result;
322 cache_type = (config >> 0) & 0xff;
323 if (cache_type > PERF_COUNT_HW_CACHE_MAX)
324 return "unknown-ext-hardware-cache-type";
326 cache_op = (config >> 8) & 0xff;
327 if (cache_op > PERF_COUNT_HW_CACHE_OP_MAX)
328 return "unknown-ext-hardware-cache-op";
330 cache_result = (config >> 16) & 0xff;
331 if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX)
332 return "unknown-ext-hardware-cache-result";
334 if (!is_cache_op_valid(cache_type, cache_op))
335 return "invalid-cache";
337 return event_cache_name(cache_type, cache_op, cache_result);
340 case PERF_TYPE_SOFTWARE:
341 if (config < PERF_COUNT_SW_MAX && sw_event_names[config])
342 return sw_event_names[config];
343 return "unknown-software";
345 case PERF_TYPE_TRACEPOINT:
346 return tracepoint_id_to_name(config);
355 static int parse_aliases(const char **str, const char *names[][MAX_ALIASES], int size)
360 for (i = 0; i < size; i++) {
361 for (j = 0; j < MAX_ALIASES && names[i][j]; j++) {
362 n = strlen(names[i][j]);
363 if (n > longest && !strncasecmp(*str, names[i][j], n))
375 static enum event_result
376 parse_generic_hw_event(const char **str, struct perf_event_attr *attr)
378 const char *s = *str;
379 int cache_type = -1, cache_op = -1, cache_result = -1;
381 cache_type = parse_aliases(&s, hw_cache, PERF_COUNT_HW_CACHE_MAX);
383 * No fallback - if we cannot get a clear cache type
386 if (cache_type == -1)
389 while ((cache_op == -1 || cache_result == -1) && *s == '-') {
392 if (cache_op == -1) {
393 cache_op = parse_aliases(&s, hw_cache_op,
394 PERF_COUNT_HW_CACHE_OP_MAX);
396 if (!is_cache_op_valid(cache_type, cache_op))
402 if (cache_result == -1) {
403 cache_result = parse_aliases(&s, hw_cache_result,
404 PERF_COUNT_HW_CACHE_RESULT_MAX);
405 if (cache_result >= 0)
410 * Can't parse this as a cache op or result, so back up
418 * Fall back to reads:
421 cache_op = PERF_COUNT_HW_CACHE_OP_READ;
424 * Fall back to accesses:
426 if (cache_result == -1)
427 cache_result = PERF_COUNT_HW_CACHE_RESULT_ACCESS;
429 attr->config = cache_type | (cache_op << 8) | (cache_result << 16);
430 attr->type = PERF_TYPE_HW_CACHE;
436 static enum event_result
437 parse_single_tracepoint_event(char *sys_name,
438 const char *evt_name,
439 unsigned int evt_length,
440 struct perf_event_attr *attr,
443 char evt_path[MAXPATHLEN];
448 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", tracing_events_path,
451 fd = open(evt_path, O_RDONLY);
455 if (read(fd, id_buf, sizeof(id_buf)) < 0) {
463 attr->type = PERF_TYPE_TRACEPOINT;
464 *strp += strlen(sys_name) + evt_length + 1; /* + 1 for the ':' */
466 attr->sample_type |= PERF_SAMPLE_RAW;
467 attr->sample_type |= PERF_SAMPLE_TIME;
468 attr->sample_type |= PERF_SAMPLE_CPU;
470 attr->sample_period = 1;
476 /* sys + ':' + event + ':' + flags*/
477 #define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128)
478 static enum event_result
479 parse_multiple_tracepoint_event(struct perf_evlist *evlist, char *sys_name,
480 const char *evt_exp, char *flags)
482 char evt_path[MAXPATHLEN];
483 struct dirent *evt_ent;
486 snprintf(evt_path, MAXPATHLEN, "%s/%s", tracing_events_path, sys_name);
487 evt_dir = opendir(evt_path);
490 perror("Can't open event dir");
494 while ((evt_ent = readdir(evt_dir))) {
495 char event_opt[MAX_EVOPT_LEN + 1];
498 if (!strcmp(evt_ent->d_name, ".")
499 || !strcmp(evt_ent->d_name, "..")
500 || !strcmp(evt_ent->d_name, "enable")
501 || !strcmp(evt_ent->d_name, "filter"))
504 if (!strglobmatch(evt_ent->d_name, evt_exp))
507 len = snprintf(event_opt, MAX_EVOPT_LEN, "%s:%s%s%s", sys_name,
508 evt_ent->d_name, flags ? ":" : "",
513 if (parse_events(evlist, event_opt, 0))
517 return EVT_HANDLED_ALL;
520 static enum event_result
521 parse_tracepoint_event(struct perf_evlist *evlist, const char **strp,
522 struct perf_event_attr *attr)
524 const char *evt_name;
525 char *flags = NULL, *comma_loc;
526 char sys_name[MAX_EVENT_LENGTH];
527 unsigned int sys_length, evt_length;
529 if (debugfs_valid_mountpoint(tracing_events_path))
532 evt_name = strchr(*strp, ':');
536 sys_length = evt_name - *strp;
537 if (sys_length >= MAX_EVENT_LENGTH)
540 strncpy(sys_name, *strp, sys_length);
541 sys_name[sys_length] = '\0';
542 evt_name = evt_name + 1;
544 comma_loc = strchr(evt_name, ',');
546 /* take the event name up to the comma */
547 evt_name = strndup(evt_name, comma_loc - evt_name);
549 flags = strchr(evt_name, ':');
552 evt_name = strndup(evt_name, flags - evt_name);
556 evt_length = strlen(evt_name);
557 if (evt_length >= MAX_EVENT_LENGTH)
559 if (strpbrk(evt_name, "*?")) {
560 *strp += strlen(sys_name) + evt_length + 1; /* 1 == the ':' */
561 return parse_multiple_tracepoint_event(evlist, sys_name,
564 return parse_single_tracepoint_event(sys_name, evt_name,
565 evt_length, attr, strp);
569 static enum event_result
570 parse_breakpoint_type(const char *type, const char **strp,
571 struct perf_event_attr *attr)
575 for (i = 0; i < 3; i++) {
581 attr->bp_type |= HW_BREAKPOINT_R;
584 attr->bp_type |= HW_BREAKPOINT_W;
587 attr->bp_type |= HW_BREAKPOINT_X;
593 if (!attr->bp_type) /* Default */
594 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
601 static enum event_result
602 parse_breakpoint_event(const char **strp, struct perf_event_attr *attr)
608 enum event_result err;
610 target = strchr(*strp, ':');
614 if (strncmp(*strp, "mem", target - *strp) != 0)
619 addr = strtoull(target, &endaddr, 0);
620 if (target == endaddr)
623 attr->bp_addr = addr;
626 type = strchr(target, ':');
628 /* If no type is defined, just rw as default */
630 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
632 err = parse_breakpoint_type(++type, strp, attr);
633 if (err == EVT_FAILED)
638 * We should find a nice way to override the access length
639 * Provide some defaults for now
641 if (attr->bp_type == HW_BREAKPOINT_X)
642 attr->bp_len = sizeof(long);
644 attr->bp_len = HW_BREAKPOINT_LEN_4;
646 attr->type = PERF_TYPE_BREAKPOINT;
651 static int check_events(const char *str, unsigned int i)
655 n = strlen(event_symbols[i].symbol);
656 if (!strncasecmp(str, event_symbols[i].symbol, n))
659 n = strlen(event_symbols[i].alias);
661 if (!strncasecmp(str, event_symbols[i].alias, n))
668 static enum event_result
669 parse_symbolic_event(const char **strp, struct perf_event_attr *attr)
671 const char *str = *strp;
675 for (i = 0; i < ARRAY_SIZE(event_symbols); i++) {
676 n = check_events(str, i);
678 attr->type = event_symbols[i].type;
679 attr->config = event_symbols[i].config;
687 static enum event_result
688 parse_raw_event(const char **strp, struct perf_event_attr *attr)
690 const char *str = *strp;
696 n = hex2u64(str + 1, &config);
698 const char *end = str + n + 1;
699 if (*end != '\0' && *end != ',' && *end != ':')
703 attr->type = PERF_TYPE_RAW;
704 attr->config = config;
710 static enum event_result
711 parse_numeric_event(const char **strp, struct perf_event_attr *attr)
713 const char *str = *strp;
718 type = strtoul(str, &endp, 0);
719 if (endp > str && type < PERF_TYPE_MAX && *endp == ':') {
721 config = strtoul(str, &endp, 0);
724 attr->config = config;
733 parse_event_modifier(const char **strp, struct perf_event_attr *attr)
735 const char *str = *strp;
737 int eu = 0, ek = 0, eh = 0, precise = 0;
751 exclude = eu = ek = eh = 1;
753 } else if (*str == 'k') {
755 exclude = eu = ek = eh = 1;
757 } else if (*str == 'h') {
759 exclude = eu = ek = eh = 1;
761 } else if (*str == 'p') {
773 attr->exclude_user = eu;
774 attr->exclude_kernel = ek;
775 attr->exclude_hv = eh;
776 attr->precise_ip = precise;
782 * Each event can have multiple symbolic names.
783 * Symbolic names are (almost) exactly matched.
785 static enum event_result
786 parse_event_symbols(struct perf_evlist *evlist, const char **str,
787 struct perf_event_attr *attr)
789 enum event_result ret;
791 ret = parse_tracepoint_event(evlist, str, attr);
792 if (ret != EVT_FAILED)
795 ret = parse_raw_event(str, attr);
796 if (ret != EVT_FAILED)
799 ret = parse_numeric_event(str, attr);
800 if (ret != EVT_FAILED)
803 ret = parse_symbolic_event(str, attr);
804 if (ret != EVT_FAILED)
807 ret = parse_generic_hw_event(str, attr);
808 if (ret != EVT_FAILED)
811 ret = parse_breakpoint_event(str, attr);
812 if (ret != EVT_FAILED)
815 fprintf(stderr, "invalid or unsupported event: '%s'\n", *str);
816 fprintf(stderr, "Run 'perf list' for a list of valid events\n");
820 if (parse_event_modifier(str, attr) < 0) {
821 fprintf(stderr, "invalid event modifier: '%s'\n", *str);
822 fprintf(stderr, "Run 'perf list' for a list of valid events and modifiers\n");
830 int parse_events(struct perf_evlist *evlist , const char *str, int unset __used)
832 struct perf_event_attr attr;
833 enum event_result ret;
838 memset(&attr, 0, sizeof(attr));
839 ret = parse_event_symbols(evlist, &str, &attr);
840 if (ret == EVT_FAILED)
843 if (!(*str == 0 || *str == ',' || isspace(*str)))
846 if (ret != EVT_HANDLED_ALL) {
847 struct perf_evsel *evsel;
848 evsel = perf_evsel__new(&attr, evlist->nr_entries);
851 perf_evlist__add(evlist, evsel);
853 evsel->name = calloc(str - ostr + 1, 1);
856 strncpy(evsel->name, ostr, str - ostr);
863 while (isspace(*str))
870 int parse_events_option(const struct option *opt, const char *str,
873 struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
874 return parse_events(evlist, str, unset);
877 int parse_filter(const struct option *opt, const char *str,
880 struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
881 struct perf_evsel *last = NULL;
883 if (evlist->nr_entries > 0)
884 last = list_entry(evlist->entries.prev, struct perf_evsel, node);
886 if (last == NULL || last->attr.type != PERF_TYPE_TRACEPOINT) {
888 "-F option should follow a -e tracepoint option\n");
892 last->filter = strdup(str);
893 if (last->filter == NULL) {
894 fprintf(stderr, "not enough memory to hold filter string\n");
901 static const char * const event_type_descriptors[] = {
905 "Hardware cache event",
906 "Raw hardware event descriptor",
907 "Hardware breakpoint",
911 * Print the events from <debugfs_mount_point>/tracing/events
914 void print_tracepoint_events(const char *subsys_glob, const char *event_glob)
916 DIR *sys_dir, *evt_dir;
917 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
918 char evt_path[MAXPATHLEN];
919 char dir_path[MAXPATHLEN];
921 if (debugfs_valid_mountpoint(tracing_events_path))
924 sys_dir = opendir(tracing_events_path);
928 for_each_subsystem(sys_dir, sys_dirent, sys_next) {
929 if (subsys_glob != NULL &&
930 !strglobmatch(sys_dirent.d_name, subsys_glob))
933 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,
935 evt_dir = opendir(dir_path);
939 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) {
940 if (event_glob != NULL &&
941 !strglobmatch(evt_dirent.d_name, event_glob))
944 snprintf(evt_path, MAXPATHLEN, "%s:%s",
945 sys_dirent.d_name, evt_dirent.d_name);
946 printf(" %-50s [%s]\n", evt_path,
947 event_type_descriptors[PERF_TYPE_TRACEPOINT]);
955 * Check whether event is in <debugfs_mount_point>/tracing/events
958 int is_valid_tracepoint(const char *event_string)
960 DIR *sys_dir, *evt_dir;
961 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
962 char evt_path[MAXPATHLEN];
963 char dir_path[MAXPATHLEN];
965 if (debugfs_valid_mountpoint(tracing_events_path))
968 sys_dir = opendir(tracing_events_path);
972 for_each_subsystem(sys_dir, sys_dirent, sys_next) {
974 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,
976 evt_dir = opendir(dir_path);
980 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) {
981 snprintf(evt_path, MAXPATHLEN, "%s:%s",
982 sys_dirent.d_name, evt_dirent.d_name);
983 if (!strcmp(evt_path, event_string)) {
995 void print_events_type(u8 type)
997 struct event_symbol *syms = event_symbols;
1001 for (i = 0; i < ARRAY_SIZE(event_symbols); i++, syms++) {
1002 if (type != syms->type)
1005 if (strlen(syms->alias))
1006 snprintf(name, sizeof(name), "%s OR %s",
1007 syms->symbol, syms->alias);
1009 snprintf(name, sizeof(name), "%s", syms->symbol);
1011 printf(" %-50s [%s]\n", name,
1012 event_type_descriptors[type]);
1016 int print_hwcache_events(const char *event_glob)
1018 unsigned int type, op, i, printed = 0;
1020 for (type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) {
1021 for (op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) {
1022 /* skip invalid cache type */
1023 if (!is_cache_op_valid(type, op))
1026 for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
1027 char *name = event_cache_name(type, op, i);
1029 if (event_glob != NULL && !strglobmatch(name, event_glob))
1032 printf(" %-50s [%s]\n", name,
1033 event_type_descriptors[PERF_TYPE_HW_CACHE]);
1042 #define MAX_NAME_LEN 100
1045 * Print the help text for the event symbols:
1047 void print_events(const char *event_glob)
1049 unsigned int i, type, prev_type = -1, printed = 0, ntypes_printed = 0;
1050 struct event_symbol *syms = event_symbols;
1051 char name[MAX_NAME_LEN];
1054 printf("List of pre-defined events (to be used in -e):\n");
1056 for (i = 0; i < ARRAY_SIZE(event_symbols); i++, syms++) {
1059 if (type != prev_type && printed) {
1065 if (event_glob != NULL &&
1066 !(strglobmatch(syms->symbol, event_glob) ||
1067 (syms->alias && strglobmatch(syms->alias, event_glob))))
1070 if (strlen(syms->alias))
1071 snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias);
1073 strncpy(name, syms->symbol, MAX_NAME_LEN);
1074 printf(" %-50s [%s]\n", name,
1075 event_type_descriptors[type]);
1081 if (ntypes_printed) {
1085 print_hwcache_events(event_glob);
1087 if (event_glob != NULL)
1091 printf(" %-50s [%s]\n",
1092 "rNNN (see 'perf list --help' on how to encode it)",
1093 event_type_descriptors[PERF_TYPE_RAW]);
1096 printf(" %-50s [%s]\n",
1097 "mem:<addr>[:access]",
1098 event_type_descriptors[PERF_TYPE_BREAKPOINT]);
1101 print_tracepoint_events(NULL, NULL);