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