1 #include "../../../include/linux/hw_breakpoint.h"
6 #include "parse-options.h"
7 #include "parse-events.h"
14 #include "parse-events-flex.h"
17 #define MAX_NAME_LEN 100
26 int parse_events_parse(struct list_head *list, struct list_head *list_tmp,
29 #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
30 #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
32 static struct event_symbol event_symbols[] = {
33 { CHW(CPU_CYCLES), "cpu-cycles", "cycles" },
34 { CHW(STALLED_CYCLES_FRONTEND), "stalled-cycles-frontend", "idle-cycles-frontend" },
35 { CHW(STALLED_CYCLES_BACKEND), "stalled-cycles-backend", "idle-cycles-backend" },
36 { CHW(INSTRUCTIONS), "instructions", "" },
37 { CHW(CACHE_REFERENCES), "cache-references", "" },
38 { CHW(CACHE_MISSES), "cache-misses", "" },
39 { CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" },
40 { CHW(BRANCH_MISSES), "branch-misses", "" },
41 { CHW(BUS_CYCLES), "bus-cycles", "" },
42 { CHW(REF_CPU_CYCLES), "ref-cycles", "" },
44 { CSW(CPU_CLOCK), "cpu-clock", "" },
45 { CSW(TASK_CLOCK), "task-clock", "" },
46 { CSW(PAGE_FAULTS), "page-faults", "faults" },
47 { CSW(PAGE_FAULTS_MIN), "minor-faults", "" },
48 { CSW(PAGE_FAULTS_MAJ), "major-faults", "" },
49 { CSW(CONTEXT_SWITCHES), "context-switches", "cs" },
50 { CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" },
51 { CSW(ALIGNMENT_FAULTS), "alignment-faults", "" },
52 { CSW(EMULATION_FAULTS), "emulation-faults", "" },
55 #define __PERF_EVENT_FIELD(config, name) \
56 ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT)
58 #define PERF_EVENT_RAW(config) __PERF_EVENT_FIELD(config, RAW)
59 #define PERF_EVENT_CONFIG(config) __PERF_EVENT_FIELD(config, CONFIG)
60 #define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE)
61 #define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT)
63 static const char *hw_event_names[PERF_COUNT_HW_MAX] = {
71 "stalled-cycles-frontend",
72 "stalled-cycles-backend",
76 static const char *sw_event_names[PERF_COUNT_SW_MAX] = {
90 static const char *hw_cache[PERF_COUNT_HW_CACHE_MAX][MAX_ALIASES] = {
91 { "L1-dcache", "l1-d", "l1d", "L1-data", },
92 { "L1-icache", "l1-i", "l1i", "L1-instruction", },
94 { "dTLB", "d-tlb", "Data-TLB", },
95 { "iTLB", "i-tlb", "Instruction-TLB", },
96 { "branch", "branches", "bpu", "btb", "bpc", },
100 static const char *hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][MAX_ALIASES] = {
101 { "load", "loads", "read", },
102 { "store", "stores", "write", },
103 { "prefetch", "prefetches", "speculative-read", "speculative-load", },
106 static const char *hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX]
108 { "refs", "Reference", "ops", "access", },
109 { "misses", "miss", },
112 #define C(x) PERF_COUNT_HW_CACHE_##x
113 #define CACHE_READ (1 << C(OP_READ))
114 #define CACHE_WRITE (1 << C(OP_WRITE))
115 #define CACHE_PREFETCH (1 << C(OP_PREFETCH))
116 #define COP(x) (1 << x)
119 * cache operartion stat
120 * L1I : Read and prefetch only
121 * ITLB and BPU : Read-only
123 static unsigned long hw_cache_stat[C(MAX)] = {
124 [C(L1D)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
125 [C(L1I)] = (CACHE_READ | CACHE_PREFETCH),
126 [C(LL)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
127 [C(DTLB)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
128 [C(ITLB)] = (CACHE_READ),
129 [C(BPU)] = (CACHE_READ),
130 [C(NODE)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
133 #define for_each_subsystem(sys_dir, sys_dirent, sys_next) \
134 while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \
135 if (sys_dirent.d_type == DT_DIR && \
136 (strcmp(sys_dirent.d_name, ".")) && \
137 (strcmp(sys_dirent.d_name, "..")))
139 static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir)
141 char evt_path[MAXPATHLEN];
144 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", tracing_events_path,
145 sys_dir->d_name, evt_dir->d_name);
146 fd = open(evt_path, O_RDONLY);
154 #define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) \
155 while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \
156 if (evt_dirent.d_type == DT_DIR && \
157 (strcmp(evt_dirent.d_name, ".")) && \
158 (strcmp(evt_dirent.d_name, "..")) && \
159 (!tp_event_has_id(&sys_dirent, &evt_dirent)))
161 #define MAX_EVENT_LENGTH 512
164 struct tracepoint_path *tracepoint_id_to_path(u64 config)
166 struct tracepoint_path *path = NULL;
167 DIR *sys_dir, *evt_dir;
168 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
172 char evt_path[MAXPATHLEN];
173 char dir_path[MAXPATHLEN];
175 if (debugfs_valid_mountpoint(tracing_events_path))
178 sys_dir = opendir(tracing_events_path);
182 for_each_subsystem(sys_dir, sys_dirent, sys_next) {
184 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,
186 evt_dir = opendir(dir_path);
190 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) {
192 snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,
194 fd = open(evt_path, O_RDONLY);
197 if (read(fd, id_buf, sizeof(id_buf)) < 0) {
206 path = zalloc(sizeof(*path));
207 path->system = malloc(MAX_EVENT_LENGTH);
212 path->name = malloc(MAX_EVENT_LENGTH);
218 strncpy(path->system, sys_dirent.d_name,
220 strncpy(path->name, evt_dirent.d_name,
232 #define TP_PATH_LEN (MAX_EVENT_LENGTH * 2 + 1)
233 static const char *tracepoint_id_to_name(u64 config)
235 static char buf[TP_PATH_LEN];
236 struct tracepoint_path *path;
238 path = tracepoint_id_to_path(config);
240 snprintf(buf, TP_PATH_LEN, "%s:%s", path->system, path->name);
245 snprintf(buf, TP_PATH_LEN, "%s:%s", "unknown", "unknown");
250 static int is_cache_op_valid(u8 cache_type, u8 cache_op)
252 if (hw_cache_stat[cache_type] & COP(cache_op))
253 return 1; /* valid */
255 return 0; /* invalid */
258 static char *event_cache_name(u8 cache_type, u8 cache_op, u8 cache_result)
260 static char name[50];
263 sprintf(name, "%s-%s-%s", hw_cache[cache_type][0],
264 hw_cache_op[cache_op][0],
265 hw_cache_result[cache_result][0]);
267 sprintf(name, "%s-%s", hw_cache[cache_type][0],
268 hw_cache_op[cache_op][1]);
274 const char *event_type(int type)
277 case PERF_TYPE_HARDWARE:
280 case PERF_TYPE_SOFTWARE:
283 case PERF_TYPE_TRACEPOINT:
286 case PERF_TYPE_HW_CACHE:
287 return "hardware-cache";
296 const char *event_name(struct perf_evsel *evsel)
298 u64 config = evsel->attr.config;
299 int type = evsel->attr.type;
304 return __event_name(type, config);
307 const char *__event_name(int type, u64 config)
311 if (type == PERF_TYPE_RAW) {
312 sprintf(buf, "raw 0x%" PRIx64, config);
317 case PERF_TYPE_HARDWARE:
318 if (config < PERF_COUNT_HW_MAX && hw_event_names[config])
319 return hw_event_names[config];
320 return "unknown-hardware";
322 case PERF_TYPE_HW_CACHE: {
323 u8 cache_type, cache_op, cache_result;
325 cache_type = (config >> 0) & 0xff;
326 if (cache_type > PERF_COUNT_HW_CACHE_MAX)
327 return "unknown-ext-hardware-cache-type";
329 cache_op = (config >> 8) & 0xff;
330 if (cache_op > PERF_COUNT_HW_CACHE_OP_MAX)
331 return "unknown-ext-hardware-cache-op";
333 cache_result = (config >> 16) & 0xff;
334 if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX)
335 return "unknown-ext-hardware-cache-result";
337 if (!is_cache_op_valid(cache_type, cache_op))
338 return "invalid-cache";
340 return event_cache_name(cache_type, cache_op, cache_result);
343 case PERF_TYPE_SOFTWARE:
344 if (config < PERF_COUNT_SW_MAX && sw_event_names[config])
345 return sw_event_names[config];
346 return "unknown-software";
348 case PERF_TYPE_TRACEPOINT:
349 return tracepoint_id_to_name(config);
358 static int add_event(struct list_head *list, int *idx,
359 struct perf_event_attr *attr, char *name)
361 struct perf_evsel *evsel;
363 event_attr_init(attr);
365 evsel = perf_evsel__new(attr, (*idx)++);
369 list_add_tail(&evsel->node, list);
371 evsel->name = strdup(name);
375 static int parse_aliases(char *str, const char *names[][MAX_ALIASES], int size)
380 for (i = 0; i < size; i++) {
381 for (j = 0; j < MAX_ALIASES && names[i][j]; j++) {
382 n = strlen(names[i][j]);
383 if (n > longest && !strncasecmp(str, names[i][j], n))
393 int parse_events_add_cache(struct list_head *list, int *idx,
394 char *type, char *op_result1, char *op_result2)
396 struct perf_event_attr attr;
397 char name[MAX_NAME_LEN];
398 int cache_type = -1, cache_op = -1, cache_result = -1;
399 char *op_result[2] = { op_result1, op_result2 };
403 * No fallback - if we cannot get a clear cache type
406 cache_type = parse_aliases(type, hw_cache,
407 PERF_COUNT_HW_CACHE_MAX);
408 if (cache_type == -1)
411 n = snprintf(name, MAX_NAME_LEN, "%s", type);
413 for (i = 0; (i < 2) && (op_result[i]); i++) {
414 char *str = op_result[i];
416 snprintf(name + n, MAX_NAME_LEN - n, "-%s\n", str);
418 if (cache_op == -1) {
419 cache_op = parse_aliases(str, hw_cache_op,
420 PERF_COUNT_HW_CACHE_OP_MAX);
422 if (!is_cache_op_valid(cache_type, cache_op))
428 if (cache_result == -1) {
429 cache_result = parse_aliases(str, hw_cache_result,
430 PERF_COUNT_HW_CACHE_RESULT_MAX);
431 if (cache_result >= 0)
437 * Fall back to reads:
440 cache_op = PERF_COUNT_HW_CACHE_OP_READ;
443 * Fall back to accesses:
445 if (cache_result == -1)
446 cache_result = PERF_COUNT_HW_CACHE_RESULT_ACCESS;
448 memset(&attr, 0, sizeof(attr));
449 attr.config = cache_type | (cache_op << 8) | (cache_result << 16);
450 attr.type = PERF_TYPE_HW_CACHE;
451 return add_event(list, idx, &attr, name);
454 static int add_tracepoint(struct list_head *list, int *idx,
455 char *sys_name, char *evt_name)
457 struct perf_event_attr attr;
458 char name[MAX_NAME_LEN];
459 char evt_path[MAXPATHLEN];
464 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", tracing_events_path,
467 fd = open(evt_path, O_RDONLY);
471 if (read(fd, id_buf, sizeof(id_buf)) < 0) {
479 memset(&attr, 0, sizeof(attr));
481 attr.type = PERF_TYPE_TRACEPOINT;
482 attr.sample_type |= PERF_SAMPLE_RAW;
483 attr.sample_type |= PERF_SAMPLE_TIME;
484 attr.sample_type |= PERF_SAMPLE_CPU;
485 attr.sample_period = 1;
487 snprintf(name, MAX_NAME_LEN, "%s:%s", sys_name, evt_name);
488 return add_event(list, idx, &attr, name);
491 static int add_tracepoint_multi(struct list_head *list, int *idx,
492 char *sys_name, char *evt_name)
494 char evt_path[MAXPATHLEN];
495 struct dirent *evt_ent;
499 snprintf(evt_path, MAXPATHLEN, "%s/%s", tracing_events_path, sys_name);
500 evt_dir = opendir(evt_path);
502 perror("Can't open event dir");
506 while (!ret && (evt_ent = readdir(evt_dir))) {
507 if (!strcmp(evt_ent->d_name, ".")
508 || !strcmp(evt_ent->d_name, "..")
509 || !strcmp(evt_ent->d_name, "enable")
510 || !strcmp(evt_ent->d_name, "filter"))
513 if (!strglobmatch(evt_ent->d_name, evt_name))
516 ret = add_tracepoint(list, idx, sys_name, evt_ent->d_name);
522 int parse_events_add_tracepoint(struct list_head *list, int *idx,
523 char *sys, char *event)
527 ret = debugfs_valid_mountpoint(tracing_events_path);
531 return strpbrk(event, "*?") ?
532 add_tracepoint_multi(list, idx, sys, event) :
533 add_tracepoint(list, idx, sys, event);
537 parse_breakpoint_type(const char *type, struct perf_event_attr *attr)
541 for (i = 0; i < 3; i++) {
542 if (!type || !type[i])
547 attr->bp_type |= HW_BREAKPOINT_R;
550 attr->bp_type |= HW_BREAKPOINT_W;
553 attr->bp_type |= HW_BREAKPOINT_X;
560 if (!attr->bp_type) /* Default */
561 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
566 int parse_events_add_breakpoint(struct list_head *list, int *idx,
567 void *ptr, char *type)
569 struct perf_event_attr attr;
570 char name[MAX_NAME_LEN];
572 memset(&attr, 0, sizeof(attr));
573 attr.bp_addr = (unsigned long) ptr;
575 if (parse_breakpoint_type(type, &attr))
579 * We should find a nice way to override the access length
580 * Provide some defaults for now
582 if (attr.bp_type == HW_BREAKPOINT_X)
583 attr.bp_len = sizeof(long);
585 attr.bp_len = HW_BREAKPOINT_LEN_4;
587 attr.type = PERF_TYPE_BREAKPOINT;
589 snprintf(name, MAX_NAME_LEN, "mem:%p:%s", ptr, type ? type : "rw");
590 return add_event(list, idx, &attr, name);
593 static int config_term(struct perf_event_attr *attr,
594 struct parse_events__term *term)
596 switch (term->type) {
597 case PARSE_EVENTS__TERM_TYPE_CONFIG:
598 attr->config = term->val.num;
600 case PARSE_EVENTS__TERM_TYPE_CONFIG1:
601 attr->config1 = term->val.num;
603 case PARSE_EVENTS__TERM_TYPE_CONFIG2:
604 attr->config2 = term->val.num;
606 case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
607 attr->sample_period = term->val.num;
609 case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
611 * TODO uncomment when the field is available
612 * attr->branch_sample_type = term->val.num;
621 static int config_attr(struct perf_event_attr *attr,
622 struct list_head *head, int fail)
624 struct parse_events__term *term;
626 list_for_each_entry(term, head, list)
627 if (config_term(attr, term) && fail)
633 int parse_events_add_numeric(struct list_head *list, int *idx,
634 unsigned long type, unsigned long config,
635 struct list_head *head_config)
637 struct perf_event_attr attr;
639 memset(&attr, 0, sizeof(attr));
641 attr.config = config;
644 config_attr(&attr, head_config, 1))
647 return add_event(list, idx, &attr,
648 (char *) __event_name(type, config));
651 int parse_events_add_pmu(struct list_head *list, int *idx,
652 char *name, struct list_head *head_config)
654 struct perf_event_attr attr;
655 struct perf_pmu *pmu;
657 pmu = perf_pmu__find(name);
661 memset(&attr, 0, sizeof(attr));
664 * Configure hardcoded terms first, no need to check
665 * return value when called with fail == 0 ;)
667 config_attr(&attr, head_config, 0);
669 if (perf_pmu__config(pmu, &attr, head_config))
672 return add_event(list, idx, &attr, (char *) "pmu");
675 void parse_events_update_lists(struct list_head *list_event,
676 struct list_head *list_all)
679 * Called for single event definition. Update the
680 * 'all event' list, and reinit the 'signle event'
681 * list, for next event definition.
683 list_splice_tail(list_event, list_all);
684 INIT_LIST_HEAD(list_event);
687 int parse_events_modifier(struct list_head *list, char *str)
689 struct perf_evsel *evsel;
690 int exclude = 0, exclude_GH = 0;
691 int eu = 0, ek = 0, eh = 0, eH = 0, eG = 0, precise = 0;
699 exclude = eu = ek = eh = 1;
701 } else if (*str == 'k') {
703 exclude = eu = ek = eh = 1;
705 } else if (*str == 'h') {
707 exclude = eu = ek = eh = 1;
709 } else if (*str == 'G') {
711 exclude_GH = eG = eH = 1;
713 } else if (*str == 'H') {
715 exclude_GH = eG = eH = 1;
717 } else if (*str == 'p') {
728 * 0 - SAMPLE_IP can have arbitrary skid
729 * 1 - SAMPLE_IP must have constant skid
730 * 2 - SAMPLE_IP requested to have 0 skid
731 * 3 - SAMPLE_IP must have 0 skid
733 * See also PERF_RECORD_MISC_EXACT_IP
738 list_for_each_entry(evsel, list, node) {
739 evsel->attr.exclude_user = eu;
740 evsel->attr.exclude_kernel = ek;
741 evsel->attr.exclude_hv = eh;
742 evsel->attr.precise_ip = precise;
743 evsel->attr.exclude_host = eH;
744 evsel->attr.exclude_guest = eG;
750 int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
754 YY_BUFFER_STATE buffer;
755 int ret, idx = evlist->nr_entries;
757 buffer = parse_events__scan_string(str);
759 ret = parse_events_parse(&list, &list_tmp, &idx);
761 parse_events__flush_buffer(buffer);
762 parse_events__delete_buffer(buffer);
765 int entries = idx - evlist->nr_entries;
766 perf_evlist__splice_list_tail(evlist, &list, entries);
771 * There are 2 users - builtin-record and builtin-test objects.
772 * Both call perf_evlist__delete in case of error, so we dont
775 fprintf(stderr, "invalid or unsupported event: '%s'\n", str);
776 fprintf(stderr, "Run 'perf list' for a list of valid events\n");
780 int parse_events_option(const struct option *opt, const char *str,
783 struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
784 return parse_events(evlist, str, unset);
787 int parse_filter(const struct option *opt, const char *str,
790 struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
791 struct perf_evsel *last = NULL;
793 if (evlist->nr_entries > 0)
794 last = list_entry(evlist->entries.prev, struct perf_evsel, node);
796 if (last == NULL || last->attr.type != PERF_TYPE_TRACEPOINT) {
798 "-F option should follow a -e tracepoint option\n");
802 last->filter = strdup(str);
803 if (last->filter == NULL) {
804 fprintf(stderr, "not enough memory to hold filter string\n");
811 static const char * const event_type_descriptors[] = {
815 "Hardware cache event",
816 "Raw hardware event descriptor",
817 "Hardware breakpoint",
821 * Print the events from <debugfs_mount_point>/tracing/events
824 void print_tracepoint_events(const char *subsys_glob, const char *event_glob)
826 DIR *sys_dir, *evt_dir;
827 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
828 char evt_path[MAXPATHLEN];
829 char dir_path[MAXPATHLEN];
831 if (debugfs_valid_mountpoint(tracing_events_path))
834 sys_dir = opendir(tracing_events_path);
838 for_each_subsystem(sys_dir, sys_dirent, sys_next) {
839 if (subsys_glob != NULL &&
840 !strglobmatch(sys_dirent.d_name, subsys_glob))
843 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,
845 evt_dir = opendir(dir_path);
849 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) {
850 if (event_glob != NULL &&
851 !strglobmatch(evt_dirent.d_name, event_glob))
854 snprintf(evt_path, MAXPATHLEN, "%s:%s",
855 sys_dirent.d_name, evt_dirent.d_name);
856 printf(" %-50s [%s]\n", evt_path,
857 event_type_descriptors[PERF_TYPE_TRACEPOINT]);
865 * Check whether event is in <debugfs_mount_point>/tracing/events
868 int is_valid_tracepoint(const char *event_string)
870 DIR *sys_dir, *evt_dir;
871 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
872 char evt_path[MAXPATHLEN];
873 char dir_path[MAXPATHLEN];
875 if (debugfs_valid_mountpoint(tracing_events_path))
878 sys_dir = opendir(tracing_events_path);
882 for_each_subsystem(sys_dir, sys_dirent, sys_next) {
884 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,
886 evt_dir = opendir(dir_path);
890 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) {
891 snprintf(evt_path, MAXPATHLEN, "%s:%s",
892 sys_dirent.d_name, evt_dirent.d_name);
893 if (!strcmp(evt_path, event_string)) {
905 void print_events_type(u8 type)
907 struct event_symbol *syms = event_symbols;
911 for (i = 0; i < ARRAY_SIZE(event_symbols); i++, syms++) {
912 if (type != syms->type)
915 if (strlen(syms->alias))
916 snprintf(name, sizeof(name), "%s OR %s",
917 syms->symbol, syms->alias);
919 snprintf(name, sizeof(name), "%s", syms->symbol);
921 printf(" %-50s [%s]\n", name,
922 event_type_descriptors[type]);
926 int print_hwcache_events(const char *event_glob)
928 unsigned int type, op, i, printed = 0;
930 for (type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) {
931 for (op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) {
932 /* skip invalid cache type */
933 if (!is_cache_op_valid(type, op))
936 for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
937 char *name = event_cache_name(type, op, i);
939 if (event_glob != NULL && !strglobmatch(name, event_glob))
942 printf(" %-50s [%s]\n", name,
943 event_type_descriptors[PERF_TYPE_HW_CACHE]);
953 * Print the help text for the event symbols:
955 void print_events(const char *event_glob)
957 unsigned int i, type, prev_type = -1, printed = 0, ntypes_printed = 0;
958 struct event_symbol *syms = event_symbols;
959 char name[MAX_NAME_LEN];
962 printf("List of pre-defined events (to be used in -e):\n");
964 for (i = 0; i < ARRAY_SIZE(event_symbols); i++, syms++) {
967 if (type != prev_type && printed) {
973 if (event_glob != NULL &&
974 !(strglobmatch(syms->symbol, event_glob) ||
975 (syms->alias && strglobmatch(syms->alias, event_glob))))
978 if (strlen(syms->alias))
979 snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias);
981 strncpy(name, syms->symbol, MAX_NAME_LEN);
982 printf(" %-50s [%s]\n", name,
983 event_type_descriptors[type]);
989 if (ntypes_printed) {
993 print_hwcache_events(event_glob);
995 if (event_glob != NULL)
999 printf(" %-50s [%s]\n",
1001 event_type_descriptors[PERF_TYPE_RAW]);
1002 printf(" %-50s [%s]\n",
1003 "cpu/t1=v1[,t2=v2,t3 ...]/modifier",
1004 event_type_descriptors[PERF_TYPE_RAW]);
1005 printf(" (see 'perf list --help' on how to encode it)\n");
1008 printf(" %-50s [%s]\n",
1009 "mem:<addr>[:access]",
1010 event_type_descriptors[PERF_TYPE_BREAKPOINT]);
1013 print_tracepoint_events(NULL, NULL);
1016 int parse_events__is_hardcoded_term(struct parse_events__term *term)
1018 return term->type <= PARSE_EVENTS__TERM_TYPE_HARDCODED_MAX;
1021 int parse_events__new_term(struct parse_events__term **_term, int type,
1022 char *config, char *str, long num)
1024 struct parse_events__term *term;
1026 term = zalloc(sizeof(*term));
1030 INIT_LIST_HEAD(&term->list);
1032 term->config = config;
1035 case PARSE_EVENTS__TERM_TYPE_CONFIG:
1036 case PARSE_EVENTS__TERM_TYPE_CONFIG1:
1037 case PARSE_EVENTS__TERM_TYPE_CONFIG2:
1038 case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
1039 case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
1040 case PARSE_EVENTS__TERM_TYPE_NUM:
1041 term->val.num = num;
1043 case PARSE_EVENTS__TERM_TYPE_STR:
1044 term->val.str = str;
1054 void parse_events__free_terms(struct list_head *terms)
1056 struct parse_events__term *term, *h;
1058 list_for_each_entry_safe(term, h, terms, list)