1 #include "../../../include/linux/hw_breakpoint.h"
6 #include "parse-options.h"
7 #include "parse-events.h"
28 char debugfs_path
[MAXPATHLEN
];
30 #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
31 #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
33 static struct event_symbol event_symbols
[] = {
34 { CHW(CPU_CYCLES
), "cpu-cycles", "cycles" },
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
[] = {
71 static const char *sw_event_names
[] = {
85 static const char *hw_cache
[][MAX_ALIASES
] = {
86 { "L1-dcache", "l1-d", "l1d", "L1-data", },
87 { "L1-icache", "l1-i", "l1i", "L1-instruction", },
89 { "dTLB", "d-tlb", "Data-TLB", },
90 { "iTLB", "i-tlb", "Instruction-TLB", },
91 { "branch", "branches", "bpu", "btb", "bpc", },
94 static const char *hw_cache_op
[][MAX_ALIASES
] = {
95 { "load", "loads", "read", },
96 { "store", "stores", "write", },
97 { "prefetch", "prefetches", "speculative-read", "speculative-load", },
100 static const char *hw_cache_result
[][MAX_ALIASES
] = {
101 { "refs", "Reference", "ops", "access", },
102 { "misses", "miss", },
105 #define C(x) PERF_COUNT_HW_CACHE_##x
106 #define CACHE_READ (1 << C(OP_READ))
107 #define CACHE_WRITE (1 << C(OP_WRITE))
108 #define CACHE_PREFETCH (1 << C(OP_PREFETCH))
109 #define COP(x) (1 << x)
112 * cache operartion stat
113 * L1I : Read and prefetch only
114 * ITLB and BPU : Read-only
116 static unsigned long hw_cache_stat
[C(MAX
)] = {
117 [C(L1D
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
118 [C(L1I
)] = (CACHE_READ
| CACHE_PREFETCH
),
119 [C(LL
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
120 [C(DTLB
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
121 [C(ITLB
)] = (CACHE_READ
),
122 [C(BPU
)] = (CACHE_READ
),
125 #define for_each_subsystem(sys_dir, sys_dirent, sys_next) \
126 while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \
127 if (sys_dirent.d_type == DT_DIR && \
128 (strcmp(sys_dirent.d_name, ".")) && \
129 (strcmp(sys_dirent.d_name, "..")))
131 static int tp_event_has_id(struct dirent
*sys_dir
, struct dirent
*evt_dir
)
133 char evt_path
[MAXPATHLEN
];
136 snprintf(evt_path
, MAXPATHLEN
, "%s/%s/%s/id", debugfs_path
,
137 sys_dir
->d_name
, evt_dir
->d_name
);
138 fd
= open(evt_path
, O_RDONLY
);
146 #define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) \
147 while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \
148 if (evt_dirent.d_type == DT_DIR && \
149 (strcmp(evt_dirent.d_name, ".")) && \
150 (strcmp(evt_dirent.d_name, "..")) && \
151 (!tp_event_has_id(&sys_dirent, &evt_dirent)))
153 #define MAX_EVENT_LENGTH 512
156 struct tracepoint_path
*tracepoint_id_to_path(u64 config
)
158 struct tracepoint_path
*path
= NULL
;
159 DIR *sys_dir
, *evt_dir
;
160 struct dirent
*sys_next
, *evt_next
, sys_dirent
, evt_dirent
;
164 char evt_path
[MAXPATHLEN
];
165 char dir_path
[MAXPATHLEN
];
167 if (debugfs_valid_mountpoint(debugfs_path
))
170 sys_dir
= opendir(debugfs_path
);
174 for_each_subsystem(sys_dir
, sys_dirent
, sys_next
) {
176 snprintf(dir_path
, MAXPATHLEN
, "%s/%s", debugfs_path
,
178 evt_dir
= opendir(dir_path
);
182 for_each_event(sys_dirent
, evt_dir
, evt_dirent
, evt_next
) {
184 snprintf(evt_path
, MAXPATHLEN
, "%s/%s/id", dir_path
,
186 fd
= open(evt_path
, O_RDONLY
);
189 if (read(fd
, id_buf
, sizeof(id_buf
)) < 0) {
198 path
= zalloc(sizeof(*path
));
199 path
->system
= malloc(MAX_EVENT_LENGTH
);
204 path
->name
= malloc(MAX_EVENT_LENGTH
);
210 strncpy(path
->system
, sys_dirent
.d_name
,
212 strncpy(path
->name
, evt_dirent
.d_name
,
224 #define TP_PATH_LEN (MAX_EVENT_LENGTH * 2 + 1)
225 static const char *tracepoint_id_to_name(u64 config
)
227 static char buf
[TP_PATH_LEN
];
228 struct tracepoint_path
*path
;
230 path
= tracepoint_id_to_path(config
);
232 snprintf(buf
, TP_PATH_LEN
, "%s:%s", path
->system
, path
->name
);
237 snprintf(buf
, TP_PATH_LEN
, "%s:%s", "unknown", "unknown");
242 static int is_cache_op_valid(u8 cache_type
, u8 cache_op
)
244 if (hw_cache_stat
[cache_type
] & COP(cache_op
))
245 return 1; /* valid */
247 return 0; /* invalid */
250 static char *event_cache_name(u8 cache_type
, u8 cache_op
, u8 cache_result
)
252 static char name
[50];
255 sprintf(name
, "%s-%s-%s", hw_cache
[cache_type
][0],
256 hw_cache_op
[cache_op
][0],
257 hw_cache_result
[cache_result
][0]);
259 sprintf(name
, "%s-%s", hw_cache
[cache_type
][0],
260 hw_cache_op
[cache_op
][1]);
266 const char *event_type(int type
)
269 case PERF_TYPE_HARDWARE
:
272 case PERF_TYPE_SOFTWARE
:
275 case PERF_TYPE_TRACEPOINT
:
278 case PERF_TYPE_HW_CACHE
:
279 return "hardware-cache";
288 const char *event_name(struct perf_evsel
*evsel
)
290 u64 config
= evsel
->attr
.config
;
291 int type
= evsel
->attr
.type
;
296 return __event_name(type
, config
);
299 const char *__event_name(int type
, u64 config
)
303 if (type
== PERF_TYPE_RAW
) {
304 sprintf(buf
, "raw 0x%" PRIx64
, config
);
309 case PERF_TYPE_HARDWARE
:
310 if (config
< PERF_COUNT_HW_MAX
)
311 return hw_event_names
[config
];
312 return "unknown-hardware";
314 case PERF_TYPE_HW_CACHE
: {
315 u8 cache_type
, cache_op
, cache_result
;
317 cache_type
= (config
>> 0) & 0xff;
318 if (cache_type
> PERF_COUNT_HW_CACHE_MAX
)
319 return "unknown-ext-hardware-cache-type";
321 cache_op
= (config
>> 8) & 0xff;
322 if (cache_op
> PERF_COUNT_HW_CACHE_OP_MAX
)
323 return "unknown-ext-hardware-cache-op";
325 cache_result
= (config
>> 16) & 0xff;
326 if (cache_result
> PERF_COUNT_HW_CACHE_RESULT_MAX
)
327 return "unknown-ext-hardware-cache-result";
329 if (!is_cache_op_valid(cache_type
, cache_op
))
330 return "invalid-cache";
332 return event_cache_name(cache_type
, cache_op
, cache_result
);
335 case PERF_TYPE_SOFTWARE
:
336 if (config
< PERF_COUNT_SW_MAX
)
337 return sw_event_names
[config
];
338 return "unknown-software";
340 case PERF_TYPE_TRACEPOINT
:
341 return tracepoint_id_to_name(config
);
350 static int parse_aliases(const char **str
, const char *names
[][MAX_ALIASES
], int size
)
355 for (i
= 0; i
< size
; i
++) {
356 for (j
= 0; j
< MAX_ALIASES
&& names
[i
][j
]; j
++) {
357 n
= strlen(names
[i
][j
]);
358 if (n
> longest
&& !strncasecmp(*str
, names
[i
][j
], n
))
370 static enum event_result
371 parse_generic_hw_event(const char **str
, struct perf_event_attr
*attr
)
373 const char *s
= *str
;
374 int cache_type
= -1, cache_op
= -1, cache_result
= -1;
376 cache_type
= parse_aliases(&s
, hw_cache
, PERF_COUNT_HW_CACHE_MAX
);
378 * No fallback - if we cannot get a clear cache type
381 if (cache_type
== -1)
384 while ((cache_op
== -1 || cache_result
== -1) && *s
== '-') {
387 if (cache_op
== -1) {
388 cache_op
= parse_aliases(&s
, hw_cache_op
,
389 PERF_COUNT_HW_CACHE_OP_MAX
);
391 if (!is_cache_op_valid(cache_type
, cache_op
))
397 if (cache_result
== -1) {
398 cache_result
= parse_aliases(&s
, hw_cache_result
,
399 PERF_COUNT_HW_CACHE_RESULT_MAX
);
400 if (cache_result
>= 0)
405 * Can't parse this as a cache op or result, so back up
413 * Fall back to reads:
416 cache_op
= PERF_COUNT_HW_CACHE_OP_READ
;
419 * Fall back to accesses:
421 if (cache_result
== -1)
422 cache_result
= PERF_COUNT_HW_CACHE_RESULT_ACCESS
;
424 attr
->config
= cache_type
| (cache_op
<< 8) | (cache_result
<< 16);
425 attr
->type
= PERF_TYPE_HW_CACHE
;
431 static enum event_result
432 parse_single_tracepoint_event(char *sys_name
,
433 const char *evt_name
,
434 unsigned int evt_length
,
435 struct perf_event_attr
*attr
,
438 char evt_path
[MAXPATHLEN
];
443 snprintf(evt_path
, MAXPATHLEN
, "%s/%s/%s/id", debugfs_path
,
446 fd
= open(evt_path
, O_RDONLY
);
450 if (read(fd
, id_buf
, sizeof(id_buf
)) < 0) {
458 attr
->type
= PERF_TYPE_TRACEPOINT
;
459 *strp
+= strlen(sys_name
) + evt_length
+ 1; /* + 1 for the ':' */
461 attr
->sample_type
|= PERF_SAMPLE_RAW
;
462 attr
->sample_type
|= PERF_SAMPLE_TIME
;
463 attr
->sample_type
|= PERF_SAMPLE_CPU
;
465 attr
->sample_period
= 1;
471 /* sys + ':' + event + ':' + flags*/
472 #define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128)
473 static enum event_result
474 parse_multiple_tracepoint_event(const struct option
*opt
, char *sys_name
,
475 const char *evt_exp
, char *flags
)
477 char evt_path
[MAXPATHLEN
];
478 struct dirent
*evt_ent
;
481 snprintf(evt_path
, MAXPATHLEN
, "%s/%s", debugfs_path
, sys_name
);
482 evt_dir
= opendir(evt_path
);
485 perror("Can't open event dir");
489 while ((evt_ent
= readdir(evt_dir
))) {
490 char event_opt
[MAX_EVOPT_LEN
+ 1];
493 if (!strcmp(evt_ent
->d_name
, ".")
494 || !strcmp(evt_ent
->d_name
, "..")
495 || !strcmp(evt_ent
->d_name
, "enable")
496 || !strcmp(evt_ent
->d_name
, "filter"))
499 if (!strglobmatch(evt_ent
->d_name
, evt_exp
))
502 len
= snprintf(event_opt
, MAX_EVOPT_LEN
, "%s:%s%s%s", sys_name
,
503 evt_ent
->d_name
, flags
? ":" : "",
508 if (parse_events(opt
, event_opt
, 0))
512 return EVT_HANDLED_ALL
;
515 static enum event_result
516 parse_tracepoint_event(const struct option
*opt
, const char **strp
,
517 struct perf_event_attr
*attr
)
519 const char *evt_name
;
520 char *flags
= NULL
, *comma_loc
;
521 char sys_name
[MAX_EVENT_LENGTH
];
522 unsigned int sys_length
, evt_length
;
524 if (debugfs_valid_mountpoint(debugfs_path
))
527 evt_name
= strchr(*strp
, ':');
531 sys_length
= evt_name
- *strp
;
532 if (sys_length
>= MAX_EVENT_LENGTH
)
535 strncpy(sys_name
, *strp
, sys_length
);
536 sys_name
[sys_length
] = '\0';
537 evt_name
= evt_name
+ 1;
539 comma_loc
= strchr(evt_name
, ',');
541 /* take the event name up to the comma */
542 evt_name
= strndup(evt_name
, comma_loc
- evt_name
);
544 flags
= strchr(evt_name
, ':');
547 evt_name
= strndup(evt_name
, flags
- evt_name
);
551 evt_length
= strlen(evt_name
);
552 if (evt_length
>= MAX_EVENT_LENGTH
)
554 if (strpbrk(evt_name
, "*?")) {
555 *strp
+= strlen(sys_name
) + evt_length
+ 1; /* 1 == the ':' */
556 return parse_multiple_tracepoint_event(opt
, sys_name
, evt_name
,
559 return parse_single_tracepoint_event(sys_name
, evt_name
,
560 evt_length
, attr
, strp
);
564 static enum event_result
565 parse_breakpoint_type(const char *type
, const char **strp
,
566 struct perf_event_attr
*attr
)
570 for (i
= 0; i
< 3; i
++) {
576 attr
->bp_type
|= HW_BREAKPOINT_R
;
579 attr
->bp_type
|= HW_BREAKPOINT_W
;
582 attr
->bp_type
|= HW_BREAKPOINT_X
;
588 if (!attr
->bp_type
) /* Default */
589 attr
->bp_type
= HW_BREAKPOINT_R
| HW_BREAKPOINT_W
;
596 static enum event_result
597 parse_breakpoint_event(const char **strp
, struct perf_event_attr
*attr
)
603 enum event_result err
;
605 target
= strchr(*strp
, ':');
609 if (strncmp(*strp
, "mem", target
- *strp
) != 0)
614 addr
= strtoull(target
, &endaddr
, 0);
615 if (target
== endaddr
)
618 attr
->bp_addr
= addr
;
621 type
= strchr(target
, ':');
623 /* If no type is defined, just rw as default */
625 attr
->bp_type
= HW_BREAKPOINT_R
| HW_BREAKPOINT_W
;
627 err
= parse_breakpoint_type(++type
, strp
, attr
);
628 if (err
== EVT_FAILED
)
633 * We should find a nice way to override the access length
634 * Provide some defaults for now
636 if (attr
->bp_type
== HW_BREAKPOINT_X
)
637 attr
->bp_len
= sizeof(long);
639 attr
->bp_len
= HW_BREAKPOINT_LEN_4
;
641 attr
->type
= PERF_TYPE_BREAKPOINT
;
646 static int check_events(const char *str
, unsigned int i
)
650 n
= strlen(event_symbols
[i
].symbol
);
651 if (!strncmp(str
, event_symbols
[i
].symbol
, n
))
654 n
= strlen(event_symbols
[i
].alias
);
656 if (!strncmp(str
, event_symbols
[i
].alias
, n
))
661 static enum event_result
662 parse_symbolic_event(const char **strp
, struct perf_event_attr
*attr
)
664 const char *str
= *strp
;
668 for (i
= 0; i
< ARRAY_SIZE(event_symbols
); i
++) {
669 n
= check_events(str
, i
);
671 attr
->type
= event_symbols
[i
].type
;
672 attr
->config
= event_symbols
[i
].config
;
680 static enum event_result
681 parse_raw_event(const char **strp
, struct perf_event_attr
*attr
)
683 const char *str
= *strp
;
689 n
= hex2u64(str
+ 1, &config
);
692 attr
->type
= PERF_TYPE_RAW
;
693 attr
->config
= config
;
699 static enum event_result
700 parse_numeric_event(const char **strp
, struct perf_event_attr
*attr
)
702 const char *str
= *strp
;
707 type
= strtoul(str
, &endp
, 0);
708 if (endp
> str
&& type
< PERF_TYPE_MAX
&& *endp
== ':') {
710 config
= strtoul(str
, &endp
, 0);
713 attr
->config
= config
;
721 static enum event_result
722 parse_event_modifier(const char **strp
, struct perf_event_attr
*attr
)
724 const char *str
= *strp
;
726 int eu
= 0, ek
= 0, eh
= 0, precise
= 0;
733 exclude
= eu
= ek
= eh
= 1;
735 } else if (*str
== 'k') {
737 exclude
= eu
= ek
= eh
= 1;
739 } else if (*str
== 'h') {
741 exclude
= eu
= ek
= eh
= 1;
743 } else if (*str
== 'p') {
750 if (str
>= *strp
+ 2) {
752 attr
->exclude_user
= eu
;
753 attr
->exclude_kernel
= ek
;
754 attr
->exclude_hv
= eh
;
755 attr
->precise_ip
= precise
;
762 * Each event can have multiple symbolic names.
763 * Symbolic names are (almost) exactly matched.
765 static enum event_result
766 parse_event_symbols(const struct option
*opt
, const char **str
,
767 struct perf_event_attr
*attr
)
769 enum event_result ret
;
771 ret
= parse_tracepoint_event(opt
, str
, attr
);
772 if (ret
!= EVT_FAILED
)
775 ret
= parse_raw_event(str
, attr
);
776 if (ret
!= EVT_FAILED
)
779 ret
= parse_numeric_event(str
, attr
);
780 if (ret
!= EVT_FAILED
)
783 ret
= parse_symbolic_event(str
, attr
);
784 if (ret
!= EVT_FAILED
)
787 ret
= parse_generic_hw_event(str
, attr
);
788 if (ret
!= EVT_FAILED
)
791 ret
= parse_breakpoint_event(str
, attr
);
792 if (ret
!= EVT_FAILED
)
795 fprintf(stderr
, "invalid or unsupported event: '%s'\n", *str
);
796 fprintf(stderr
, "Run 'perf list' for a list of valid events\n");
800 parse_event_modifier(str
, attr
);
805 int parse_events(const struct option
*opt
, const char *str
, int unset __used
)
807 struct perf_evlist
*evlist
= *(struct perf_evlist
**)opt
->value
;
808 struct perf_event_attr attr
;
809 enum event_result ret
;
814 memset(&attr
, 0, sizeof(attr
));
815 ret
= parse_event_symbols(opt
, &str
, &attr
);
816 if (ret
== EVT_FAILED
)
819 if (!(*str
== 0 || *str
== ',' || isspace(*str
)))
822 if (ret
!= EVT_HANDLED_ALL
) {
823 struct perf_evsel
*evsel
;
824 evsel
= perf_evsel__new(&attr
, evlist
->nr_entries
);
827 perf_evlist__add(evlist
, evsel
);
829 evsel
->name
= calloc(str
- ostr
+ 1, 1);
832 strncpy(evsel
->name
, ostr
, str
- ostr
);
839 while (isspace(*str
))
846 int parse_filter(const struct option
*opt
, const char *str
,
849 struct perf_evlist
*evlist
= *(struct perf_evlist
**)opt
->value
;
850 struct perf_evsel
*last
= NULL
;
852 if (evlist
->nr_entries
> 0)
853 last
= list_entry(evlist
->entries
.prev
, struct perf_evsel
, node
);
855 if (last
== NULL
|| last
->attr
.type
!= PERF_TYPE_TRACEPOINT
) {
857 "-F option should follow a -e tracepoint option\n");
861 last
->filter
= strdup(str
);
862 if (last
->filter
== NULL
) {
863 fprintf(stderr
, "not enough memory to hold filter string\n");
870 static const char * const event_type_descriptors
[] = {
874 "Hardware cache event",
875 "Raw hardware event descriptor",
876 "Hardware breakpoint",
880 * Print the events from <debugfs_mount_point>/tracing/events
883 void print_tracepoint_events(const char *subsys_glob
, const char *event_glob
)
885 DIR *sys_dir
, *evt_dir
;
886 struct dirent
*sys_next
, *evt_next
, sys_dirent
, evt_dirent
;
887 char evt_path
[MAXPATHLEN
];
888 char dir_path
[MAXPATHLEN
];
890 if (debugfs_valid_mountpoint(debugfs_path
))
893 sys_dir
= opendir(debugfs_path
);
897 for_each_subsystem(sys_dir
, sys_dirent
, sys_next
) {
898 if (subsys_glob
!= NULL
&&
899 !strglobmatch(sys_dirent
.d_name
, subsys_glob
))
902 snprintf(dir_path
, MAXPATHLEN
, "%s/%s", debugfs_path
,
904 evt_dir
= opendir(dir_path
);
908 for_each_event(sys_dirent
, evt_dir
, evt_dirent
, evt_next
) {
909 if (event_glob
!= NULL
&&
910 !strglobmatch(evt_dirent
.d_name
, event_glob
))
913 snprintf(evt_path
, MAXPATHLEN
, "%s:%s",
914 sys_dirent
.d_name
, evt_dirent
.d_name
);
915 printf(" %-42s [%s]\n", evt_path
,
916 event_type_descriptors
[PERF_TYPE_TRACEPOINT
]);
924 * Check whether event is in <debugfs_mount_point>/tracing/events
927 int is_valid_tracepoint(const char *event_string
)
929 DIR *sys_dir
, *evt_dir
;
930 struct dirent
*sys_next
, *evt_next
, sys_dirent
, evt_dirent
;
931 char evt_path
[MAXPATHLEN
];
932 char dir_path
[MAXPATHLEN
];
934 if (debugfs_valid_mountpoint(debugfs_path
))
937 sys_dir
= opendir(debugfs_path
);
941 for_each_subsystem(sys_dir
, sys_dirent
, sys_next
) {
943 snprintf(dir_path
, MAXPATHLEN
, "%s/%s", debugfs_path
,
945 evt_dir
= opendir(dir_path
);
949 for_each_event(sys_dirent
, evt_dir
, evt_dirent
, evt_next
) {
950 snprintf(evt_path
, MAXPATHLEN
, "%s:%s",
951 sys_dirent
.d_name
, evt_dirent
.d_name
);
952 if (!strcmp(evt_path
, event_string
)) {
964 void print_events_type(u8 type
)
966 struct event_symbol
*syms
= event_symbols
;
970 for (i
= 0; i
< ARRAY_SIZE(event_symbols
); i
++, syms
++) {
971 if (type
!= syms
->type
)
974 if (strlen(syms
->alias
))
975 snprintf(name
, sizeof(name
), "%s OR %s",
976 syms
->symbol
, syms
->alias
);
978 snprintf(name
, sizeof(name
), "%s", syms
->symbol
);
980 printf(" %-42s [%s]\n", name
,
981 event_type_descriptors
[type
]);
985 int print_hwcache_events(const char *event_glob
)
987 unsigned int type
, op
, i
, printed
= 0;
989 for (type
= 0; type
< PERF_COUNT_HW_CACHE_MAX
; type
++) {
990 for (op
= 0; op
< PERF_COUNT_HW_CACHE_OP_MAX
; op
++) {
991 /* skip invalid cache type */
992 if (!is_cache_op_valid(type
, op
))
995 for (i
= 0; i
< PERF_COUNT_HW_CACHE_RESULT_MAX
; i
++) {
996 char *name
= event_cache_name(type
, op
, i
);
998 if (event_glob
!= NULL
&&
999 !strglobmatch(name
, event_glob
))
1002 printf(" %-42s [%s]\n", name
,
1003 event_type_descriptors
[PERF_TYPE_HW_CACHE
]);
1013 * Print the help text for the event symbols:
1015 void print_events(const char *event_glob
)
1017 struct event_symbol
*syms
= event_symbols
;
1018 unsigned int i
, type
, prev_type
= -1, printed
= 0, ntypes_printed
= 0;
1022 printf("List of pre-defined events (to be used in -e):\n");
1024 for (i
= 0; i
< ARRAY_SIZE(event_symbols
); i
++, syms
++) {
1027 if (type
!= prev_type
&& printed
) {
1033 if (event_glob
!= NULL
&&
1034 !(strglobmatch(syms
->symbol
, event_glob
) ||
1035 (syms
->alias
&& strglobmatch(syms
->alias
, event_glob
))))
1038 if (strlen(syms
->alias
))
1039 sprintf(name
, "%s OR %s", syms
->symbol
, syms
->alias
);
1041 strcpy(name
, syms
->symbol
);
1042 printf(" %-42s [%s]\n", name
,
1043 event_type_descriptors
[type
]);
1049 if (ntypes_printed
) {
1053 print_hwcache_events(event_glob
);
1055 if (event_glob
!= NULL
)
1059 printf(" %-42s [%s]\n",
1060 "rNNN (see 'perf list --help' on how to encode it)",
1061 event_type_descriptors
[PERF_TYPE_RAW
]);
1064 printf(" %-42s [%s]\n",
1065 "mem:<addr>[:access]",
1066 event_type_descriptors
[PERF_TYPE_BREAKPOINT
]);
1069 print_tracepoint_events(NULL
, NULL
);