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