Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 1 | #ifndef _PROBE_EVENT_H |
| 2 | #define _PROBE_EVENT_H |
| 3 | |
Masami Hiramatsu | fac13fd | 2009-12-15 10:31:14 -0500 | [diff] [blame] | 4 | #include <stdbool.h> |
Masami Hiramatsu | 5a62257 | 2014-02-06 05:32:09 +0000 | [diff] [blame] | 5 | #include "intlist.h" |
Masami Hiramatsu | 4de189f | 2009-11-30 19:20:17 -0500 | [diff] [blame] | 6 | #include "strlist.h" |
Masami Hiramatsu | bd09d7b | 2011-01-20 23:15:39 +0900 | [diff] [blame] | 7 | #include "strfilter.h" |
Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 8 | |
Masami Hiramatsu | ddb2f58 | 2015-05-08 10:03:31 +0900 | [diff] [blame] | 9 | /* Probe related configurations */ |
| 10 | struct probe_conf { |
| 11 | bool show_ext_vars; |
He Kuang | 349e8d2 | 2015-05-11 09:25:03 +0000 | [diff] [blame] | 12 | bool show_location_range; |
Masami Hiramatsu | ddb2f58 | 2015-05-08 10:03:31 +0900 | [diff] [blame] | 13 | bool force_add; |
Masami Hiramatsu | 6cfd1f6 | 2015-05-08 10:03:33 +0900 | [diff] [blame] | 14 | bool no_inlines; |
Masami Hiramatsu | 2fd457a | 2016-06-15 12:28:40 +0900 | [diff] [blame] | 15 | bool cache; |
Masami Hiramatsu | ddb2f58 | 2015-05-08 10:03:31 +0900 | [diff] [blame] | 16 | int max_probes; |
| 17 | }; |
| 18 | extern struct probe_conf probe_conf; |
Masami Hiramatsu | f4d7da4 | 2010-03-16 18:06:05 -0400 | [diff] [blame] | 19 | extern bool probe_event_dry_run; |
| 20 | |
Wang Nan | d6be167 | 2016-11-15 04:05:46 +0000 | [diff] [blame] | 21 | struct symbol; |
| 22 | |
Srikar Dronamraju | 225466f | 2012-04-16 17:39:09 +0530 | [diff] [blame] | 23 | /* kprobe-tracer and uprobe-tracer tracing point */ |
Srikar Dronamraju | 0e60836 | 2010-07-29 19:43:51 +0530 | [diff] [blame] | 24 | struct probe_trace_point { |
Masami Hiramatsu | 4c85935 | 2015-05-08 10:03:35 +0900 | [diff] [blame] | 25 | char *realname; /* function real name (if needed) */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 26 | char *symbol; /* Base symbol */ |
Masami Hiramatsu | 190b57f | 2011-06-27 16:27:45 +0900 | [diff] [blame] | 27 | char *module; /* Module name */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 28 | unsigned long offset; /* Offset from symbol */ |
Masami Hiramatsu | fb7345b | 2013-12-26 05:41:53 +0000 | [diff] [blame] | 29 | unsigned long address; /* Actual address of the trace point */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 30 | bool retprobe; /* Return probe flag */ |
| 31 | }; |
| 32 | |
Srikar Dronamraju | 0e60836 | 2010-07-29 19:43:51 +0530 | [diff] [blame] | 33 | /* probe-tracer tracing argument referencing offset */ |
| 34 | struct probe_trace_arg_ref { |
| 35 | struct probe_trace_arg_ref *next; /* Next reference */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 36 | long offset; /* Offset value */ |
| 37 | }; |
| 38 | |
Srikar Dronamraju | 225466f | 2012-04-16 17:39:09 +0530 | [diff] [blame] | 39 | /* kprobe-tracer and uprobe-tracer tracing argument */ |
Srikar Dronamraju | 0e60836 | 2010-07-29 19:43:51 +0530 | [diff] [blame] | 40 | struct probe_trace_arg { |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 41 | char *name; /* Argument name */ |
| 42 | char *value; /* Base value */ |
Masami Hiramatsu | 4984912 | 2010-04-12 13:17:15 -0400 | [diff] [blame] | 43 | char *type; /* Type name */ |
Srikar Dronamraju | 0e60836 | 2010-07-29 19:43:51 +0530 | [diff] [blame] | 44 | struct probe_trace_arg_ref *ref; /* Referencing offset */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 45 | }; |
| 46 | |
Srikar Dronamraju | 225466f | 2012-04-16 17:39:09 +0530 | [diff] [blame] | 47 | /* kprobe-tracer and uprobe-tracer tracing event (point + arg) */ |
Srikar Dronamraju | 0e60836 | 2010-07-29 19:43:51 +0530 | [diff] [blame] | 48 | struct probe_trace_event { |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 49 | char *event; /* Event name */ |
| 50 | char *group; /* Group name */ |
Srikar Dronamraju | 0e60836 | 2010-07-29 19:43:51 +0530 | [diff] [blame] | 51 | struct probe_trace_point point; /* Trace point */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 52 | int nargs; /* Number of args */ |
Srikar Dronamraju | 225466f | 2012-04-16 17:39:09 +0530 | [diff] [blame] | 53 | bool uprobes; /* uprobes only */ |
Srikar Dronamraju | 0e60836 | 2010-07-29 19:43:51 +0530 | [diff] [blame] | 54 | struct probe_trace_arg *args; /* Arguments */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | /* Perf probe probing point */ |
| 58 | struct perf_probe_point { |
| 59 | char *file; /* File path */ |
| 60 | char *function; /* Function name */ |
| 61 | int line; /* Line number */ |
Arnaldo Carvalho de Melo | eed05fe | 2010-04-05 12:53:45 -0300 | [diff] [blame] | 62 | bool retprobe; /* Return probe flag */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 63 | char *lazy_line; /* Lazy matching pattern */ |
| 64 | unsigned long offset; /* Offset from function entry */ |
Wang Nan | da15bd9 | 2015-08-26 10:57:45 +0000 | [diff] [blame] | 65 | unsigned long abs_address; /* Absolute address of the point */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 66 | }; |
| 67 | |
Masami Hiramatsu | 7df2f32 | 2010-03-16 18:06:26 -0400 | [diff] [blame] | 68 | /* Perf probe probing argument field chain */ |
| 69 | struct perf_probe_arg_field { |
| 70 | struct perf_probe_arg_field *next; /* Next field */ |
| 71 | char *name; /* Name of the field */ |
Masami Hiramatsu | b2a3c12 | 2010-05-19 15:57:42 -0400 | [diff] [blame] | 72 | long index; /* Array index number */ |
Masami Hiramatsu | 7df2f32 | 2010-03-16 18:06:26 -0400 | [diff] [blame] | 73 | bool ref; /* Referencing flag */ |
| 74 | }; |
| 75 | |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 76 | /* Perf probe probing argument */ |
| 77 | struct perf_probe_arg { |
Masami Hiramatsu | 7df2f32 | 2010-03-16 18:06:26 -0400 | [diff] [blame] | 78 | char *name; /* Argument name */ |
Masami Hiramatsu | 4848193 | 2010-04-12 13:16:53 -0400 | [diff] [blame] | 79 | char *var; /* Variable name */ |
Masami Hiramatsu | 11a1ca3 | 2010-04-12 13:17:22 -0400 | [diff] [blame] | 80 | char *type; /* Type name */ |
Masami Hiramatsu | 7df2f32 | 2010-03-16 18:06:26 -0400 | [diff] [blame] | 81 | struct perf_probe_arg_field *field; /* Structure fields */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | /* Perf probe probing event (point + arg) */ |
| 85 | struct perf_probe_event { |
| 86 | char *event; /* Event name */ |
| 87 | char *group; /* Group name */ |
| 88 | struct perf_probe_point point; /* Probe point */ |
| 89 | int nargs; /* Number of arguments */ |
Masami Hiramatsu | 36a009f | 2016-07-12 19:04:43 +0900 | [diff] [blame] | 90 | bool sdt; /* SDT/cached event flag */ |
Masami Hiramatsu | 7afb3fa | 2015-04-01 19:25:39 +0900 | [diff] [blame] | 91 | bool uprobes; /* Uprobe event flag */ |
| 92 | char *target; /* Target binary */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 93 | struct perf_probe_arg *args; /* Arguments */ |
Wang Nan | 12fae5e | 2015-09-04 21:16:00 +0900 | [diff] [blame] | 94 | struct probe_trace_event *tevs; |
| 95 | int ntevs; |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 96 | }; |
| 97 | |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 98 | /* Line range */ |
| 99 | struct line_range { |
| 100 | char *file; /* File name */ |
| 101 | char *function; /* Function name */ |
Masami Hiramatsu | d3b63d7 | 2010-04-14 18:39:42 -0400 | [diff] [blame] | 102 | int start; /* Start line number */ |
| 103 | int end; /* End line number */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 104 | int offset; /* Start line offset */ |
| 105 | char *path; /* Real path name */ |
Masami Hiramatsu | 6a330a3 | 2010-07-09 18:29:11 +0900 | [diff] [blame] | 106 | char *comp_dir; /* Compile directory */ |
Masami Hiramatsu | 5a62257 | 2014-02-06 05:32:09 +0000 | [diff] [blame] | 107 | struct intlist *line_list; /* Visible lines */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 108 | }; |
| 109 | |
Masami Hiramatsu | cf6eb48 | 2010-10-21 19:13:23 +0900 | [diff] [blame] | 110 | /* List of variables */ |
| 111 | struct variable_list { |
| 112 | struct probe_trace_point point; /* Actual probepoint */ |
| 113 | struct strlist *vars; /* Available variables */ |
| 114 | }; |
| 115 | |
Wang Nan | 5a023b5 | 2015-06-19 08:42:48 +0000 | [diff] [blame] | 116 | struct map; |
Namhyung Kim | 9bae1e8 | 2015-09-10 11:27:05 +0900 | [diff] [blame] | 117 | int init_probe_symbol_maps(bool user_only); |
| 118 | void exit_probe_symbol_maps(void); |
Wang Nan | 5a023b5 | 2015-06-19 08:42:48 +0000 | [diff] [blame] | 119 | |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 120 | /* Command string to events */ |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 121 | int parse_perf_probe_command(const char *cmd, struct perf_probe_event *pev); |
| 122 | int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev); |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 123 | |
| 124 | /* Events to command string */ |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 125 | char *synthesize_perf_probe_command(struct perf_probe_event *pev); |
| 126 | char *synthesize_probe_trace_command(struct probe_trace_event *tev); |
Masami Hiramatsu | 909b036 | 2016-04-28 03:37:14 +0900 | [diff] [blame] | 127 | char *synthesize_perf_probe_arg(struct perf_probe_arg *pa); |
Masami Hiramatsu | c4ff492 | 2016-06-08 18:29:50 +0900 | [diff] [blame] | 128 | char *synthesize_perf_probe_point(struct perf_probe_point *pp); |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 129 | |
Masami Hiramatsu | 0542bb9 | 2016-06-08 18:29:40 +0900 | [diff] [blame] | 130 | int perf_probe_event__copy(struct perf_probe_event *dst, |
| 131 | struct perf_probe_event *src); |
| 132 | |
Ravi Bangoria | b3f33f9 | 2016-08-03 14:28:44 +0530 | [diff] [blame] | 133 | bool perf_probe_with_var(struct perf_probe_event *pev); |
| 134 | |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 135 | /* Check the perf_probe_event needs debuginfo */ |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 136 | bool perf_probe_event_need_dwarf(struct perf_probe_event *pev); |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 137 | |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 138 | /* Release event contents */ |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 139 | void clear_perf_probe_event(struct perf_probe_event *pev); |
| 140 | void clear_probe_trace_event(struct probe_trace_event *tev); |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 141 | |
| 142 | /* Command string to line-range */ |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 143 | int parse_line_range_desc(const char *cmd, struct line_range *lr); |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 144 | |
Masami Hiramatsu | e53b00d | 2014-01-16 09:39:47 +0000 | [diff] [blame] | 145 | /* Release line range members */ |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 146 | void line_range__clear(struct line_range *lr); |
Masami Hiramatsu | e53b00d | 2014-01-16 09:39:47 +0000 | [diff] [blame] | 147 | |
| 148 | /* Initialize line range */ |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 149 | int line_range__init(struct line_range *lr); |
Masami Hiramatsu | e53b00d | 2014-01-16 09:39:47 +0000 | [diff] [blame] | 150 | |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 151 | int add_perf_probe_events(struct perf_probe_event *pevs, int npevs); |
| 152 | int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs); |
| 153 | int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs); |
Masami Hiramatsu | 1c20b1d | 2016-08-26 01:24:27 +0900 | [diff] [blame] | 154 | int show_probe_trace_events(struct perf_probe_event *pevs, int npevs); |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 155 | void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs); |
| 156 | int del_perf_probe_events(struct strfilter *filter); |
Namhyung Kim | e607f14 | 2015-09-04 21:16:03 +0900 | [diff] [blame] | 157 | |
Arnaldo Carvalho de Melo | 3938bad | 2016-03-23 15:06:35 -0300 | [diff] [blame] | 158 | int show_perf_probe_event(const char *group, const char *event, |
| 159 | struct perf_probe_event *pev, |
| 160 | const char *module, bool use_stdout); |
| 161 | int show_perf_probe_events(struct strfilter *filter); |
| 162 | int show_line_range(struct line_range *lr, const char *module, bool user); |
| 163 | int show_available_vars(struct perf_probe_event *pevs, int npevs, |
| 164 | struct strfilter *filter); |
| 165 | int show_available_funcs(const char *module, struct strfilter *filter, bool user); |
Naveen N. Rao | 7b6ff0b | 2015-04-28 17:35:40 +0530 | [diff] [blame] | 166 | void arch__fix_tev_from_maps(struct perf_probe_event *pev, |
Naveen N. Rao | 0b3c226 | 2016-04-12 14:40:50 +0530 | [diff] [blame] | 167 | struct probe_trace_event *tev, struct map *map, |
| 168 | struct symbol *sym); |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 169 | |
Masami Hiramatsu | 92f6c72 | 2015-07-15 18:14:07 +0900 | [diff] [blame] | 170 | /* If there is no space to write, returns -E2BIG. */ |
| 171 | int e_snprintf(char *str, size_t size, const char *format, ...) |
| 172 | __attribute__((format(printf, 3, 4))); |
| 173 | |
Masami Hiramatsu | b498ce1 | 2009-11-30 19:20:25 -0500 | [diff] [blame] | 174 | /* Maximum index number of event-name postfix */ |
| 175 | #define MAX_EVENT_INDEX 1024 |
| 176 | |
Wang Nan | da15bd9 | 2015-08-26 10:57:45 +0000 | [diff] [blame] | 177 | int copy_to_probe_trace_arg(struct probe_trace_arg *tvar, |
| 178 | struct perf_probe_arg *pvar); |
| 179 | |
Ravi Bangoria | 99e608b | 2016-08-09 01:23:25 -0500 | [diff] [blame] | 180 | struct map *get_target_map(const char *target, bool user); |
| 181 | |
| 182 | void arch__post_process_probe_trace_events(struct perf_probe_event *pev, |
| 183 | int ntevs); |
| 184 | |
Masami Hiramatsu | 50656ee | 2009-11-30 19:19:58 -0500 | [diff] [blame] | 185 | #endif /*_PROBE_EVENT_H */ |