parse-events.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #ifndef __PERF_PARSE_EVENTS_H
  2. #define __PERF_PARSE_EVENTS_H
  3. /*
  4. * Parse symbolic events/counts passed in as options:
  5. */
  6. #include <linux/list.h>
  7. #include <stdbool.h>
  8. #include <linux/types.h>
  9. #include <linux/perf_event.h>
  10. struct list_head;
  11. struct perf_evsel;
  12. struct perf_evlist;
  13. struct parse_events_error;
  14. struct option;
  15. struct tracepoint_path {
  16. char *system;
  17. char *name;
  18. struct tracepoint_path *next;
  19. };
  20. struct tracepoint_path *tracepoint_id_to_path(u64 config);
  21. struct tracepoint_path *tracepoint_name_to_path(const char *name);
  22. bool have_tracepoints(struct list_head *evlist);
  23. const char *event_type(int type);
  24. int parse_events_option(const struct option *opt, const char *str, int unset);
  25. int parse_events(struct perf_evlist *evlist, const char *str,
  26. struct parse_events_error *error);
  27. int parse_events_terms(struct list_head *terms, const char *str);
  28. int parse_filter(const struct option *opt, const char *str, int unset);
  29. int exclude_perf(const struct option *opt, const char *arg, int unset);
  30. #define EVENTS_HELP_MAX (128*1024)
  31. enum perf_pmu_event_symbol_type {
  32. PMU_EVENT_SYMBOL_ERR, /* not a PMU EVENT */
  33. PMU_EVENT_SYMBOL, /* normal style PMU event */
  34. PMU_EVENT_SYMBOL_PREFIX, /* prefix of pre-suf style event */
  35. PMU_EVENT_SYMBOL_SUFFIX, /* suffix of pre-suf style event */
  36. };
  37. struct perf_pmu_event_symbol {
  38. char *symbol;
  39. enum perf_pmu_event_symbol_type type;
  40. };
  41. enum {
  42. PARSE_EVENTS__TERM_TYPE_NUM,
  43. PARSE_EVENTS__TERM_TYPE_STR,
  44. };
  45. enum {
  46. PARSE_EVENTS__TERM_TYPE_USER,
  47. PARSE_EVENTS__TERM_TYPE_CONFIG,
  48. PARSE_EVENTS__TERM_TYPE_CONFIG1,
  49. PARSE_EVENTS__TERM_TYPE_CONFIG2,
  50. PARSE_EVENTS__TERM_TYPE_NAME,
  51. PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD,
  52. PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ,
  53. PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE,
  54. PARSE_EVENTS__TERM_TYPE_TIME,
  55. PARSE_EVENTS__TERM_TYPE_CALLGRAPH,
  56. PARSE_EVENTS__TERM_TYPE_STACKSIZE,
  57. PARSE_EVENTS__TERM_TYPE_NOINHERIT,
  58. PARSE_EVENTS__TERM_TYPE_INHERIT,
  59. PARSE_EVENTS__TERM_TYPE_MAX_STACK,
  60. PARSE_EVENTS__TERM_TYPE_NOOVERWRITE,
  61. PARSE_EVENTS__TERM_TYPE_OVERWRITE,
  62. PARSE_EVENTS__TERM_TYPE_DRV_CFG,
  63. __PARSE_EVENTS__TERM_TYPE_NR,
  64. };
  65. struct parse_events_array {
  66. size_t nr_ranges;
  67. struct {
  68. unsigned int start;
  69. size_t length;
  70. } *ranges;
  71. };
  72. struct parse_events_term {
  73. char *config;
  74. struct parse_events_array array;
  75. union {
  76. char *str;
  77. u64 num;
  78. } val;
  79. int type_val;
  80. int type_term;
  81. struct list_head list;
  82. bool used;
  83. /* error string indexes for within parsed string */
  84. int err_term;
  85. int err_val;
  86. };
  87. struct parse_events_error {
  88. int idx; /* index in the parsed string */
  89. char *str; /* string to display at the index */
  90. char *help; /* optional help string */
  91. };
  92. struct parse_events_evlist {
  93. struct list_head list;
  94. int idx;
  95. int nr_groups;
  96. struct parse_events_error *error;
  97. struct perf_evlist *evlist;
  98. };
  99. struct parse_events_terms {
  100. struct list_head *terms;
  101. };
  102. void parse_events__shrink_config_terms(void);
  103. int parse_events__is_hardcoded_term(struct parse_events_term *term);
  104. int parse_events_term__num(struct parse_events_term **term,
  105. int type_term, char *config, u64 num,
  106. void *loc_term, void *loc_val);
  107. int parse_events_term__str(struct parse_events_term **term,
  108. int type_term, char *config, char *str,
  109. void *loc_term, void *loc_val);
  110. int parse_events_term__sym_hw(struct parse_events_term **term,
  111. char *config, unsigned idx);
  112. int parse_events_term__clone(struct parse_events_term **new,
  113. struct parse_events_term *term);
  114. void parse_events_terms__delete(struct list_head *terms);
  115. void parse_events_terms__purge(struct list_head *terms);
  116. void parse_events__clear_array(struct parse_events_array *a);
  117. int parse_events__modifier_event(struct list_head *list, char *str, bool add);
  118. int parse_events__modifier_group(struct list_head *list, char *event_mod);
  119. int parse_events_name(struct list_head *list, char *name);
  120. int parse_events_add_tracepoint(struct list_head *list, int *idx,
  121. const char *sys, const char *event,
  122. struct parse_events_error *error,
  123. struct list_head *head_config);
  124. int parse_events_load_bpf(struct parse_events_evlist *data,
  125. struct list_head *list,
  126. char *bpf_file_name,
  127. bool source,
  128. struct list_head *head_config);
  129. /* Provide this function for perf test */
  130. struct bpf_object;
  131. int parse_events_load_bpf_obj(struct parse_events_evlist *data,
  132. struct list_head *list,
  133. struct bpf_object *obj,
  134. struct list_head *head_config);
  135. int parse_events_add_numeric(struct parse_events_evlist *data,
  136. struct list_head *list,
  137. u32 type, u64 config,
  138. struct list_head *head_config);
  139. int parse_events_add_cache(struct list_head *list, int *idx,
  140. char *type, char *op_result1, char *op_result2,
  141. struct parse_events_error *error,
  142. struct list_head *head_config);
  143. int parse_events_add_breakpoint(struct list_head *list, int *idx,
  144. void *ptr, char *type, u64 len);
  145. int parse_events_add_pmu(struct parse_events_evlist *data,
  146. struct list_head *list, char *name,
  147. struct list_head *head_config);
  148. enum perf_pmu_event_symbol_type
  149. perf_pmu__parse_check(const char *name);
  150. void parse_events__set_leader(char *name, struct list_head *list);
  151. void parse_events_update_lists(struct list_head *list_event,
  152. struct list_head *list_all);
  153. void parse_events_evlist_error(struct parse_events_evlist *data,
  154. int idx, const char *str);
  155. void print_events(const char *event_glob, bool name_only, bool quiet,
  156. bool long_desc);
  157. struct event_symbol {
  158. const char *symbol;
  159. const char *alias;
  160. };
  161. extern struct event_symbol event_symbols_hw[];
  162. extern struct event_symbol event_symbols_sw[];
  163. void print_symbol_events(const char *event_glob, unsigned type,
  164. struct event_symbol *syms, unsigned max,
  165. bool name_only);
  166. void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
  167. bool name_only);
  168. int print_hwcache_events(const char *event_glob, bool name_only);
  169. void print_sdt_events(const char *subsys_glob, const char *event_glob,
  170. bool name_only);
  171. int is_valid_tracepoint(const char *event_string);
  172. int valid_event_mount(const char *eventfs);
  173. char *parse_events_formats_error_string(char *additional_terms);
  174. #endif /* __PERF_PARSE_EVENTS_H */