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", "" },
41 { CHW(STALLED_CYCLES
), "stalled-cycles", "" },
43 { CSW(CPU_CLOCK
), "cpu-clock", "" },
44 { CSW(TASK_CLOCK
), "task-clock", "" },
45 { CSW(PAGE_FAULTS
), "page-faults", "faults" },
46 { CSW(PAGE_FAULTS_MIN
), "minor-faults", "" },
47 { CSW(PAGE_FAULTS_MAJ
), "major-faults", "" },
48 { CSW(CONTEXT_SWITCHES
), "context-switches", "cs" },
49 { CSW(CPU_MIGRATIONS
), "cpu-migrations", "migrations" },
50 { CSW(ALIGNMENT_FAULTS
), "alignment-faults", "" },
51 { CSW(EMULATION_FAULTS
), "emulation-faults", "" },
54 #define __PERF_EVENT_FIELD(config, name) \
55 ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT)
57 #define PERF_EVENT_RAW(config) __PERF_EVENT_FIELD(config, RAW)
58 #define PERF_EVENT_CONFIG(config) __PERF_EVENT_FIELD(config, CONFIG)
59 #define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE)
60 #define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT)
62 static const char *hw_event_names
[] = {
72 static const char *sw_event_names
[] = {
86 static const char *hw_cache
[][MAX_ALIASES
] = {
87 { "L1-dcache", "l1-d", "l1d", "L1-data", },
88 { "L1-icache", "l1-i", "l1i", "L1-instruction", },
90 { "dTLB", "d-tlb", "Data-TLB", },
91 { "iTLB", "i-tlb", "Instruction-TLB", },
92 { "branch", "branches", "bpu", "btb", "bpc", },
95 static const char *hw_cache_op
[][MAX_ALIASES
] = {
96 { "load", "loads", "read", },
97 { "store", "stores", "write", },
98 { "prefetch", "prefetches", "speculative-read", "speculative-load", },
101 static const char *hw_cache_result
[][MAX_ALIASES
] = {
102 { "refs", "Reference", "ops", "access", },
103 { "misses", "miss", },
106 #define C(x) PERF_COUNT_HW_CACHE_##x
107 #define CACHE_READ (1 << C(OP_READ))
108 #define CACHE_WRITE (1 << C(OP_WRITE))
109 #define CACHE_PREFETCH (1 << C(OP_PREFETCH))
110 #define COP(x) (1 << x)
113 * cache operartion stat
114 * L1I : Read and prefetch only
115 * ITLB and BPU : Read-only
117 static unsigned long hw_cache_stat
[C(MAX
)] = {
118 [C(L1D
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
119 [C(L1I
)] = (CACHE_READ
| CACHE_PREFETCH
),
120 [C(LL
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
121 [C(DTLB
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
122 [C(ITLB
)] = (CACHE_READ
),
123 [C(BPU
)] = (CACHE_READ
),
126 #define for_each_subsystem(sys_dir, sys_dirent, sys_next) \
127 while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \
128 if (sys_dirent.d_type == DT_DIR && \
129 (strcmp(sys_dirent.d_name, ".")) && \
130 (strcmp(sys_dirent.d_name, "..")))
132 static int tp_event_has_id(struct dirent
*sys_dir
, struct dirent
*evt_dir
)
134 char evt_path
[MAXPATHLEN
];
137 snprintf(evt_path
, MAXPATHLEN
, "%s/%s/%s/id", debugfs_path
,
138 sys_dir
->d_name
, evt_dir
->d_name
);
139 fd
= open(evt_path
, O_RDONLY
);
147 #define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) \
148 while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \
149 if (evt_dirent.d_type == DT_DIR && \
150 (strcmp(evt_dirent.d_name, ".")) && \
151 (strcmp(evt_dirent.d_name, "..")) && \
152 (!tp_event_has_id(&sys_dirent, &evt_dirent)))
154 #define MAX_EVENT_LENGTH 512
157 struct tracepoint_path
*tracepoint_id_to_path(u64 config
)
159 struct tracepoint_path
*path
= NULL
;
160 DIR *sys_dir
, *evt_dir
;
161 struct dirent
*sys_next
, *evt_next
, sys_dirent
, evt_dirent
;
165 char evt_path
[MAXPATHLEN
];
166 char dir_path
[MAXPATHLEN
];
168 if (debugfs_valid_mountpoint(debugfs_path
))
171 sys_dir
= opendir(debugfs_path
);
175 for_each_subsystem(sys_dir
, sys_dirent
, sys_next
) {
177 snprintf(dir_path
, MAXPATHLEN
, "%s/%s", debugfs_path
,
179 evt_dir
= opendir(dir_path
);
183 for_each_event(sys_dirent
, evt_dir
, evt_dirent
, evt_next
) {
185 snprintf(evt_path
, MAXPATHLEN
, "%s/%s/id", dir_path
,
187 fd
= open(evt_path
, O_RDONLY
);
190 if (read(fd
, id_buf
, sizeof(id_buf
)) < 0) {
199 path
= zalloc(sizeof(*path
));
200 path
->system
= malloc(MAX_EVENT_LENGTH
);
205 path
->name
= malloc(MAX_EVENT_LENGTH
);
211 strncpy(path
->system
, sys_dirent
.d_name
,
213 strncpy(path
->name
, evt_dirent
.d_name
,
225 #define TP_PATH_LEN (MAX_EVENT_LENGTH * 2 + 1)
226 static const char *tracepoint_id_to_name(u64 config
)
228 static char buf
[TP_PATH_LEN
];
229 struct tracepoint_path
*path
;
231 path
= tracepoint_id_to_path(config
);
233 snprintf(buf
, TP_PATH_LEN
, "%s:%s", path
->system
, path
->name
);
238 snprintf(buf
, TP_PATH_LEN
, "%s:%s", "unknown", "unknown");
243 static int is_cache_op_valid(u8 cache_type
, u8 cache_op
)
245 if (hw_cache_stat
[cache_type
] & COP(cache_op
))
246 return 1; /* valid */
248 return 0; /* invalid */
251 static char *event_cache_name(u8 cache_type
, u8 cache_op
, u8 cache_result
)
253 static char name
[50];
256 sprintf(name
, "%s-%s-%s", hw_cache
[cache_type
][0],
257 hw_cache_op
[cache_op
][0],
258 hw_cache_result
[cache_result
][0]);
260 sprintf(name
, "%s-%s", hw_cache
[cache_type
][0],
261 hw_cache_op
[cache_op
][1]);
267 const char *event_type(int type
)
270 case PERF_TYPE_HARDWARE
:
273 case PERF_TYPE_SOFTWARE
:
276 case PERF_TYPE_TRACEPOINT
:
279 case PERF_TYPE_HW_CACHE
:
280 return "hardware-cache";
289 const char *event_name(struct perf_evsel
*evsel
)
291 u64 config
= evsel
->attr
.config
;
292 int type
= evsel
->attr
.type
;
297 return __event_name(type
, config
);
300 const char *__event_name(int type
, u64 config
)
304 if (type
== PERF_TYPE_RAW
) {
305 sprintf(buf
, "raw 0x%" PRIx64
, config
);
310 case PERF_TYPE_HARDWARE
:
311 if (config
< PERF_COUNT_HW_MAX
)
312 return hw_event_names
[config
];
313 return "unknown-hardware";
315 case PERF_TYPE_HW_CACHE
: {
316 u8 cache_type
, cache_op
, cache_result
;
318 cache_type
= (config
>> 0) & 0xff;
319 if (cache_type
> PERF_COUNT_HW_CACHE_MAX
)
320 return "unknown-ext-hardware-cache-type";
322 cache_op
= (config
>> 8) & 0xff;
323 if (cache_op
> PERF_COUNT_HW_CACHE_OP_MAX
)
324 return "unknown-ext-hardware-cache-op";
326 cache_result
= (config
>> 16) & 0xff;
327 if (cache_result
> PERF_COUNT_HW_CACHE_RESULT_MAX
)
328 return "unknown-ext-hardware-cache-result";
330 if (!is_cache_op_valid(cache_type
, cache_op
))
331 return "invalid-cache";
333 return event_cache_name(cache_type
, cache_op
, cache_result
);
336 case PERF_TYPE_SOFTWARE
:
337 if (config
< PERF_COUNT_SW_MAX
)
338 return sw_event_names
[config
];
339 return "unknown-software";
341 case PERF_TYPE_TRACEPOINT
:
342 return tracepoint_id_to_name(config
);
351 static int parse_aliases(const char **str
, const char *names
[][MAX_ALIASES
], int size
)
356 for (i
= 0; i
< size
; i
++) {
357 for (j
= 0; j
< MAX_ALIASES
&& names
[i
][j
]; j
++) {
358 n
= strlen(names
[i
][j
]);
359 if (n
> longest
&& !strncasecmp(*str
, names
[i
][j
], n
))
371 static enum event_result
372 parse_generic_hw_event(const char **str
, struct perf_event_attr
*attr
)
374 const char *s
= *str
;
375 int cache_type
= -1, cache_op
= -1, cache_result
= -1;
377 cache_type
= parse_aliases(&s
, hw_cache
, PERF_COUNT_HW_CACHE_MAX
);
379 * No fallback - if we cannot get a clear cache type
382 if (cache_type
== -1)
385 while ((cache_op
== -1 || cache_result
== -1) && *s
== '-') {
388 if (cache_op
== -1) {
389 cache_op
= parse_aliases(&s
, hw_cache_op
,
390 PERF_COUNT_HW_CACHE_OP_MAX
);
392 if (!is_cache_op_valid(cache_type
, cache_op
))
398 if (cache_result
== -1) {
399 cache_result
= parse_aliases(&s
, hw_cache_result
,
400 PERF_COUNT_HW_CACHE_RESULT_MAX
);
401 if (cache_result
>= 0)
406 * Can't parse this as a cache op or result, so back up
414 * Fall back to reads:
417 cache_op
= PERF_COUNT_HW_CACHE_OP_READ
;
420 * Fall back to accesses:
422 if (cache_result
== -1)
423 cache_result
= PERF_COUNT_HW_CACHE_RESULT_ACCESS
;
425 attr
->config
= cache_type
| (cache_op
<< 8) | (cache_result
<< 16);
426 attr
->type
= PERF_TYPE_HW_CACHE
;
432 static enum event_result
433 parse_single_tracepoint_event(char *sys_name
,
434 const char *evt_name
,
435 unsigned int evt_length
,
436 struct perf_event_attr
*attr
,
439 char evt_path
[MAXPATHLEN
];
444 snprintf(evt_path
, MAXPATHLEN
, "%s/%s/%s/id", debugfs_path
,
447 fd
= open(evt_path
, O_RDONLY
);
451 if (read(fd
, id_buf
, sizeof(id_buf
)) < 0) {
459 attr
->type
= PERF_TYPE_TRACEPOINT
;
460 *strp
+= strlen(sys_name
) + evt_length
+ 1; /* + 1 for the ':' */
462 attr
->sample_type
|= PERF_SAMPLE_RAW
;
463 attr
->sample_type
|= PERF_SAMPLE_TIME
;
464 attr
->sample_type
|= PERF_SAMPLE_CPU
;
466 attr
->sample_period
= 1;
472 /* sys + ':' + event + ':' + flags*/
473 #define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128)
474 static enum event_result
475 parse_multiple_tracepoint_event(const struct option
*opt
, char *sys_name
,
476 const char *evt_exp
, char *flags
)
478 char evt_path
[MAXPATHLEN
];
479 struct dirent
*evt_ent
;
482 snprintf(evt_path
, MAXPATHLEN
, "%s/%s", debugfs_path
, sys_name
);
483 evt_dir
= opendir(evt_path
);
486 perror("Can't open event dir");
490 while ((evt_ent
= readdir(evt_dir
))) {
491 char event_opt
[MAX_EVOPT_LEN
+ 1];
494 if (!strcmp(evt_ent
->d_name
, ".")
495 || !strcmp(evt_ent
->d_name
, "..")
496 || !strcmp(evt_ent
->d_name
, "enable")
497 || !strcmp(evt_ent
->d_name
, "filter"))
500 if (!strglobmatch(evt_ent
->d_name
, evt_exp
))
503 len
= snprintf(event_opt
, MAX_EVOPT_LEN
, "%s:%s%s%s", sys_name
,
504 evt_ent
->d_name
, flags
? ":" : "",
509 if (parse_events(opt
, event_opt
, 0))
513 return EVT_HANDLED_ALL
;
516 static enum event_result
517 parse_tracepoint_event(const struct option
*opt
, const char **strp
,
518 struct perf_event_attr
*attr
)
520 const char *evt_name
;
521 char *flags
= NULL
, *comma_loc
;
522 char sys_name
[MAX_EVENT_LENGTH
];
523 unsigned int sys_length
, evt_length
;
525 if (debugfs_valid_mountpoint(debugfs_path
))
528 evt_name
= strchr(*strp
, ':');
532 sys_length
= evt_name
- *strp
;
533 if (sys_length
>= MAX_EVENT_LENGTH
)
536 strncpy(sys_name
, *strp
, sys_length
);
537 sys_name
[sys_length
] = '\0';
538 evt_name
= evt_name
+ 1;
540 comma_loc
= strchr(evt_name
, ',');
542 /* take the event name up to the comma */
543 evt_name
= strndup(evt_name
, comma_loc
- evt_name
);
545 flags
= strchr(evt_name
, ':');
548 evt_name
= strndup(evt_name
, flags
- evt_name
);
552 evt_length
= strlen(evt_name
);
553 if (evt_length
>= MAX_EVENT_LENGTH
)
555 if (strpbrk(evt_name
, "*?")) {
556 *strp
+= strlen(sys_name
) + evt_length
+ 1; /* 1 == the ':' */
557 return parse_multiple_tracepoint_event(opt
, sys_name
, evt_name
,
560 return parse_single_tracepoint_event(sys_name
, evt_name
,
561 evt_length
, attr
, strp
);
565 static enum event_result
566 parse_breakpoint_type(const char *type
, const char **strp
,
567 struct perf_event_attr
*attr
)
571 for (i
= 0; i
< 3; i
++) {
577 attr
->bp_type
|= HW_BREAKPOINT_R
;
580 attr
->bp_type
|= HW_BREAKPOINT_W
;
583 attr
->bp_type
|= HW_BREAKPOINT_X
;
589 if (!attr
->bp_type
) /* Default */
590 attr
->bp_type
= HW_BREAKPOINT_R
| HW_BREAKPOINT_W
;
597 static enum event_result
598 parse_breakpoint_event(const char **strp
, struct perf_event_attr
*attr
)
604 enum event_result err
;
606 target
= strchr(*strp
, ':');
610 if (strncmp(*strp
, "mem", target
- *strp
) != 0)
615 addr
= strtoull(target
, &endaddr
, 0);
616 if (target
== endaddr
)
619 attr
->bp_addr
= addr
;
622 type
= strchr(target
, ':');
624 /* If no type is defined, just rw as default */
626 attr
->bp_type
= HW_BREAKPOINT_R
| HW_BREAKPOINT_W
;
628 err
= parse_breakpoint_type(++type
, strp
, attr
);
629 if (err
== EVT_FAILED
)
634 * We should find a nice way to override the access length
635 * Provide some defaults for now
637 if (attr
->bp_type
== HW_BREAKPOINT_X
)
638 attr
->bp_len
= sizeof(long);
640 attr
->bp_len
= HW_BREAKPOINT_LEN_4
;
642 attr
->type
= PERF_TYPE_BREAKPOINT
;
647 static int check_events(const char *str
, unsigned int i
)
651 n
= strlen(event_symbols
[i
].symbol
);
652 if (!strncasecmp(str
, event_symbols
[i
].symbol
, n
))
655 n
= strlen(event_symbols
[i
].alias
);
657 if (!strncasecmp(str
, event_symbols
[i
].alias
, n
))
664 static enum event_result
665 parse_symbolic_event(const char **strp
, struct perf_event_attr
*attr
)
667 const char *str
= *strp
;
671 for (i
= 0; i
< ARRAY_SIZE(event_symbols
); i
++) {
672 n
= check_events(str
, i
);
674 attr
->type
= event_symbols
[i
].type
;
675 attr
->config
= event_symbols
[i
].config
;
683 static enum event_result
684 parse_raw_event(const char **strp
, struct perf_event_attr
*attr
)
686 const char *str
= *strp
;
692 n
= hex2u64(str
+ 1, &config
);
695 attr
->type
= PERF_TYPE_RAW
;
696 attr
->config
= config
;
702 static enum event_result
703 parse_numeric_event(const char **strp
, struct perf_event_attr
*attr
)
705 const char *str
= *strp
;
710 type
= strtoul(str
, &endp
, 0);
711 if (endp
> str
&& type
< PERF_TYPE_MAX
&& *endp
== ':') {
713 config
= strtoul(str
, &endp
, 0);
716 attr
->config
= config
;
725 parse_event_modifier(const char **strp
, struct perf_event_attr
*attr
)
727 const char *str
= *strp
;
729 int eu
= 0, ek
= 0, eh
= 0, precise
= 0;
740 exclude
= eu
= ek
= eh
= 1;
742 } else if (*str
== 'k') {
744 exclude
= eu
= ek
= eh
= 1;
746 } else if (*str
== 'h') {
748 exclude
= eu
= ek
= eh
= 1;
750 } else if (*str
== 'p') {
762 attr
->exclude_user
= eu
;
763 attr
->exclude_kernel
= ek
;
764 attr
->exclude_hv
= eh
;
765 attr
->precise_ip
= precise
;
771 * Each event can have multiple symbolic names.
772 * Symbolic names are (almost) exactly matched.
774 static enum event_result
775 parse_event_symbols(const struct option
*opt
, const char **str
,
776 struct perf_event_attr
*attr
)
778 enum event_result ret
;
780 ret
= parse_tracepoint_event(opt
, str
, attr
);
781 if (ret
!= EVT_FAILED
)
784 ret
= parse_raw_event(str
, attr
);
785 if (ret
!= EVT_FAILED
)
788 ret
= parse_numeric_event(str
, attr
);
789 if (ret
!= EVT_FAILED
)
792 ret
= parse_symbolic_event(str
, attr
);
793 if (ret
!= EVT_FAILED
)
796 ret
= parse_generic_hw_event(str
, attr
);
797 if (ret
!= EVT_FAILED
)
800 ret
= parse_breakpoint_event(str
, attr
);
801 if (ret
!= EVT_FAILED
)
804 fprintf(stderr
, "invalid or unsupported event: '%s'\n", *str
);
805 fprintf(stderr
, "Run 'perf list' for a list of valid events\n");
809 if (parse_event_modifier(str
, attr
) < 0) {
810 fprintf(stderr
, "invalid event modifier: '%s'\n", *str
);
811 fprintf(stderr
, "Run 'perf list' for a list of valid events and modifiers\n");
819 int parse_events(const struct option
*opt
, const char *str
, int unset __used
)
821 struct perf_evlist
*evlist
= *(struct perf_evlist
**)opt
->value
;
822 struct perf_event_attr attr
;
823 enum event_result ret
;
828 memset(&attr
, 0, sizeof(attr
));
829 ret
= parse_event_symbols(opt
, &str
, &attr
);
830 if (ret
== EVT_FAILED
)
833 if (!(*str
== 0 || *str
== ',' || isspace(*str
)))
836 if (ret
!= EVT_HANDLED_ALL
) {
837 struct perf_evsel
*evsel
;
838 evsel
= perf_evsel__new(&attr
, evlist
->nr_entries
);
841 perf_evlist__add(evlist
, evsel
);
843 evsel
->name
= calloc(str
- ostr
+ 1, 1);
846 strncpy(evsel
->name
, ostr
, str
- ostr
);
853 while (isspace(*str
))
860 int parse_filter(const struct option
*opt
, const char *str
,
863 struct perf_evlist
*evlist
= *(struct perf_evlist
**)opt
->value
;
864 struct perf_evsel
*last
= NULL
;
866 if (evlist
->nr_entries
> 0)
867 last
= list_entry(evlist
->entries
.prev
, struct perf_evsel
, node
);
869 if (last
== NULL
|| last
->attr
.type
!= PERF_TYPE_TRACEPOINT
) {
871 "-F option should follow a -e tracepoint option\n");
875 last
->filter
= strdup(str
);
876 if (last
->filter
== NULL
) {
877 fprintf(stderr
, "not enough memory to hold filter string\n");
884 static const char * const event_type_descriptors
[] = {
888 "Hardware cache event",
889 "Raw hardware event descriptor",
890 "Hardware breakpoint",
894 * Print the events from <debugfs_mount_point>/tracing/events
897 void print_tracepoint_events(const char *subsys_glob
, const char *event_glob
)
899 DIR *sys_dir
, *evt_dir
;
900 struct dirent
*sys_next
, *evt_next
, sys_dirent
, evt_dirent
;
901 char evt_path
[MAXPATHLEN
];
902 char dir_path
[MAXPATHLEN
];
904 if (debugfs_valid_mountpoint(debugfs_path
))
907 sys_dir
= opendir(debugfs_path
);
911 for_each_subsystem(sys_dir
, sys_dirent
, sys_next
) {
912 if (subsys_glob
!= NULL
&&
913 !strglobmatch(sys_dirent
.d_name
, subsys_glob
))
916 snprintf(dir_path
, MAXPATHLEN
, "%s/%s", debugfs_path
,
918 evt_dir
= opendir(dir_path
);
922 for_each_event(sys_dirent
, evt_dir
, evt_dirent
, evt_next
) {
923 if (event_glob
!= NULL
&&
924 !strglobmatch(evt_dirent
.d_name
, event_glob
))
927 snprintf(evt_path
, MAXPATHLEN
, "%s:%s",
928 sys_dirent
.d_name
, evt_dirent
.d_name
);
929 printf(" %-42s [%s]\n", evt_path
,
930 event_type_descriptors
[PERF_TYPE_TRACEPOINT
]);
938 * Check whether event is in <debugfs_mount_point>/tracing/events
941 int is_valid_tracepoint(const char *event_string
)
943 DIR *sys_dir
, *evt_dir
;
944 struct dirent
*sys_next
, *evt_next
, sys_dirent
, evt_dirent
;
945 char evt_path
[MAXPATHLEN
];
946 char dir_path
[MAXPATHLEN
];
948 if (debugfs_valid_mountpoint(debugfs_path
))
951 sys_dir
= opendir(debugfs_path
);
955 for_each_subsystem(sys_dir
, sys_dirent
, sys_next
) {
957 snprintf(dir_path
, MAXPATHLEN
, "%s/%s", debugfs_path
,
959 evt_dir
= opendir(dir_path
);
963 for_each_event(sys_dirent
, evt_dir
, evt_dirent
, evt_next
) {
964 snprintf(evt_path
, MAXPATHLEN
, "%s:%s",
965 sys_dirent
.d_name
, evt_dirent
.d_name
);
966 if (!strcmp(evt_path
, event_string
)) {
978 void print_events_type(u8 type
)
980 struct event_symbol
*syms
= event_symbols
;
984 for (i
= 0; i
< ARRAY_SIZE(event_symbols
); i
++, syms
++) {
985 if (type
!= syms
->type
)
988 if (strlen(syms
->alias
))
989 snprintf(name
, sizeof(name
), "%s OR %s",
990 syms
->symbol
, syms
->alias
);
992 snprintf(name
, sizeof(name
), "%s", syms
->symbol
);
994 printf(" %-42s [%s]\n", name
,
995 event_type_descriptors
[type
]);
999 int print_hwcache_events(const char *event_glob
)
1001 unsigned int type
, op
, i
, printed
= 0;
1003 for (type
= 0; type
< PERF_COUNT_HW_CACHE_MAX
; type
++) {
1004 for (op
= 0; op
< PERF_COUNT_HW_CACHE_OP_MAX
; op
++) {
1005 /* skip invalid cache type */
1006 if (!is_cache_op_valid(type
, op
))
1009 for (i
= 0; i
< PERF_COUNT_HW_CACHE_RESULT_MAX
; i
++) {
1010 char *name
= event_cache_name(type
, op
, i
);
1012 if (event_glob
!= NULL
&&
1013 !strglobmatch(name
, event_glob
))
1016 printf(" %-42s [%s]\n", name
,
1017 event_type_descriptors
[PERF_TYPE_HW_CACHE
]);
1027 * Print the help text for the event symbols:
1029 void print_events(const char *event_glob
)
1031 struct event_symbol
*syms
= event_symbols
;
1032 unsigned int i
, type
, prev_type
= -1, printed
= 0, ntypes_printed
= 0;
1036 printf("List of pre-defined events (to be used in -e):\n");
1038 for (i
= 0; i
< ARRAY_SIZE(event_symbols
); i
++, syms
++) {
1041 if (type
!= prev_type
&& printed
) {
1047 if (event_glob
!= NULL
&&
1048 !(strglobmatch(syms
->symbol
, event_glob
) ||
1049 (syms
->alias
&& strglobmatch(syms
->alias
, event_glob
))))
1052 if (strlen(syms
->alias
))
1053 sprintf(name
, "%s OR %s", syms
->symbol
, syms
->alias
);
1055 strcpy(name
, syms
->symbol
);
1056 printf(" %-42s [%s]\n", name
,
1057 event_type_descriptors
[type
]);
1063 if (ntypes_printed
) {
1067 print_hwcache_events(event_glob
);
1069 if (event_glob
!= NULL
)
1073 printf(" %-42s [%s]\n",
1074 "rNNN (see 'perf list --help' on how to encode it)",
1075 event_type_descriptors
[PERF_TYPE_RAW
]);
1078 printf(" %-42s [%s]\n",
1079 "mem:<addr>[:access]",
1080 event_type_descriptors
[PERF_TYPE_BREAKPOINT
]);
1083 print_tracepoint_events(NULL
, NULL
);