blob: 5d4e940614024ddf9a5d0420b8bdfa51ee07cd38 [file] [log] [blame]
Masami Hiramatsu50656ee2009-11-30 19:19:58 -05001#ifndef _PROBE_EVENT_H
2#define _PROBE_EVENT_H
3
Masami Hiramatsufac13fd2009-12-15 10:31:14 -05004#include <stdbool.h>
Masami Hiramatsu5a622572014-02-06 05:32:09 +00005#include "intlist.h"
Masami Hiramatsu4de189f2009-11-30 19:20:17 -05006#include "strlist.h"
Masami Hiramatsubd09d7b2011-01-20 23:15:39 +09007#include "strfilter.h"
Masami Hiramatsu50656ee2009-11-30 19:19:58 -05008
Masami Hiramatsuddb2f582015-05-08 10:03:31 +09009/* Probe related configurations */
10struct probe_conf {
11 bool show_ext_vars;
He Kuang349e8d22015-05-11 09:25:03 +000012 bool show_location_range;
Masami Hiramatsuddb2f582015-05-08 10:03:31 +090013 bool force_add;
Masami Hiramatsu6cfd1f62015-05-08 10:03:33 +090014 bool no_inlines;
Masami Hiramatsu2fd457a2016-06-15 12:28:40 +090015 bool cache;
Masami Hiramatsuddb2f582015-05-08 10:03:31 +090016 int max_probes;
17};
18extern struct probe_conf probe_conf;
Masami Hiramatsuf4d7da42010-03-16 18:06:05 -040019extern bool probe_event_dry_run;
20
Wang Nand6be1672016-11-15 04:05:46 +000021struct symbol;
22
Srikar Dronamraju225466f2012-04-16 17:39:09 +053023/* kprobe-tracer and uprobe-tracer tracing point */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053024struct probe_trace_point {
Masami Hiramatsu4c859352015-05-08 10:03:35 +090025 char *realname; /* function real name (if needed) */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040026 char *symbol; /* Base symbol */
Masami Hiramatsu190b57f2011-06-27 16:27:45 +090027 char *module; /* Module name */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040028 unsigned long offset; /* Offset from symbol */
Masami Hiramatsufb7345b2013-12-26 05:41:53 +000029 unsigned long address; /* Actual address of the trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040030 bool retprobe; /* Return probe flag */
31};
32
Srikar Dronamraju0e608362010-07-29 19:43:51 +053033/* probe-tracer tracing argument referencing offset */
34struct probe_trace_arg_ref {
35 struct probe_trace_arg_ref *next; /* Next reference */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040036 long offset; /* Offset value */
37};
38
Srikar Dronamraju225466f2012-04-16 17:39:09 +053039/* kprobe-tracer and uprobe-tracer tracing argument */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053040struct probe_trace_arg {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040041 char *name; /* Argument name */
42 char *value; /* Base value */
Masami Hiramatsu49849122010-04-12 13:17:15 -040043 char *type; /* Type name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053044 struct probe_trace_arg_ref *ref; /* Referencing offset */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040045};
46
Srikar Dronamraju225466f2012-04-16 17:39:09 +053047/* kprobe-tracer and uprobe-tracer tracing event (point + arg) */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053048struct probe_trace_event {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040049 char *event; /* Event name */
50 char *group; /* Group name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053051 struct probe_trace_point point; /* Trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040052 int nargs; /* Number of args */
Srikar Dronamraju225466f2012-04-16 17:39:09 +053053 bool uprobes; /* uprobes only */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053054 struct probe_trace_arg *args; /* Arguments */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040055};
56
57/* Perf probe probing point */
58struct perf_probe_point {
59 char *file; /* File path */
60 char *function; /* Function name */
61 int line; /* Line number */
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030062 bool retprobe; /* Return probe flag */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040063 char *lazy_line; /* Lazy matching pattern */
64 unsigned long offset; /* Offset from function entry */
Wang Nanda15bd92015-08-26 10:57:45 +000065 unsigned long abs_address; /* Absolute address of the point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040066};
67
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040068/* Perf probe probing argument field chain */
69struct perf_probe_arg_field {
70 struct perf_probe_arg_field *next; /* Next field */
71 char *name; /* Name of the field */
Masami Hiramatsub2a3c122010-05-19 15:57:42 -040072 long index; /* Array index number */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040073 bool ref; /* Referencing flag */
74};
75
Masami Hiramatsu4235b042010-03-16 18:06:12 -040076/* Perf probe probing argument */
77struct perf_probe_arg {
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040078 char *name; /* Argument name */
Masami Hiramatsu48481932010-04-12 13:16:53 -040079 char *var; /* Variable name */
Masami Hiramatsu11a1ca32010-04-12 13:17:22 -040080 char *type; /* Type name */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040081 struct perf_probe_arg_field *field; /* Structure fields */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040082};
83
84/* Perf probe probing event (point + arg) */
85struct 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 Hiramatsu36a009f2016-07-12 19:04:43 +090090 bool sdt; /* SDT/cached event flag */
Masami Hiramatsu7afb3fa2015-04-01 19:25:39 +090091 bool uprobes; /* Uprobe event flag */
92 char *target; /* Target binary */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040093 struct perf_probe_arg *args; /* Arguments */
Wang Nan12fae5e2015-09-04 21:16:00 +090094 struct probe_trace_event *tevs;
95 int ntevs;
Masami Hiramatsu4235b042010-03-16 18:06:12 -040096};
97
Masami Hiramatsu4235b042010-03-16 18:06:12 -040098/* Line range */
99struct line_range {
100 char *file; /* File name */
101 char *function; /* Function name */
Masami Hiramatsud3b63d72010-04-14 18:39:42 -0400102 int start; /* Start line number */
103 int end; /* End line number */
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400104 int offset; /* Start line offset */
105 char *path; /* Real path name */
Masami Hiramatsu6a330a32010-07-09 18:29:11 +0900106 char *comp_dir; /* Compile directory */
Masami Hiramatsu5a622572014-02-06 05:32:09 +0000107 struct intlist *line_list; /* Visible lines */
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400108};
109
Masami Hiramatsucf6eb482010-10-21 19:13:23 +0900110/* List of variables */
111struct variable_list {
112 struct probe_trace_point point; /* Actual probepoint */
113 struct strlist *vars; /* Available variables */
114};
115
Wang Nan5a023b52015-06-19 08:42:48 +0000116struct map;
Namhyung Kim9bae1e82015-09-10 11:27:05 +0900117int init_probe_symbol_maps(bool user_only);
118void exit_probe_symbol_maps(void);
Wang Nan5a023b52015-06-19 08:42:48 +0000119
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400120/* Command string to events */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300121int parse_perf_probe_command(const char *cmd, struct perf_probe_event *pev);
122int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400123
124/* Events to command string */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300125char *synthesize_perf_probe_command(struct perf_probe_event *pev);
126char *synthesize_probe_trace_command(struct probe_trace_event *tev);
Masami Hiramatsu909b0362016-04-28 03:37:14 +0900127char *synthesize_perf_probe_arg(struct perf_probe_arg *pa);
Masami Hiramatsuc4ff4922016-06-08 18:29:50 +0900128char *synthesize_perf_probe_point(struct perf_probe_point *pp);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400129
Masami Hiramatsu0542bb92016-06-08 18:29:40 +0900130int perf_probe_event__copy(struct perf_probe_event *dst,
131 struct perf_probe_event *src);
132
Ravi Bangoriab3f33f92016-08-03 14:28:44 +0530133bool perf_probe_with_var(struct perf_probe_event *pev);
134
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400135/* Check the perf_probe_event needs debuginfo */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300136bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400137
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400138/* Release event contents */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300139void clear_perf_probe_event(struct perf_probe_event *pev);
140void clear_probe_trace_event(struct probe_trace_event *tev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400141
142/* Command string to line-range */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300143int parse_line_range_desc(const char *cmd, struct line_range *lr);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400144
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000145/* Release line range members */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300146void line_range__clear(struct line_range *lr);
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000147
148/* Initialize line range */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300149int line_range__init(struct line_range *lr);
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000150
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300151int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
152int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs);
153int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs);
Masami Hiramatsu1c20b1d2016-08-26 01:24:27 +0900154int show_probe_trace_events(struct perf_probe_event *pevs, int npevs);
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300155void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs);
156int del_perf_probe_events(struct strfilter *filter);
Namhyung Kime607f142015-09-04 21:16:03 +0900157
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300158int show_perf_probe_event(const char *group, const char *event,
159 struct perf_probe_event *pev,
160 const char *module, bool use_stdout);
161int show_perf_probe_events(struct strfilter *filter);
162int show_line_range(struct line_range *lr, const char *module, bool user);
163int show_available_vars(struct perf_probe_event *pevs, int npevs,
164 struct strfilter *filter);
165int show_available_funcs(const char *module, struct strfilter *filter, bool user);
Naveen N. Rao7b6ff0b2015-04-28 17:35:40 +0530166void arch__fix_tev_from_maps(struct perf_probe_event *pev,
Naveen N. Rao0b3c2262016-04-12 14:40:50 +0530167 struct probe_trace_event *tev, struct map *map,
168 struct symbol *sym);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400169
Masami Hiramatsu92f6c722015-07-15 18:14:07 +0900170/* If there is no space to write, returns -E2BIG. */
171int e_snprintf(char *str, size_t size, const char *format, ...)
172 __attribute__((format(printf, 3, 4)));
173
Masami Hiramatsub498ce12009-11-30 19:20:25 -0500174/* Maximum index number of event-name postfix */
175#define MAX_EVENT_INDEX 1024
176
Wang Nanda15bd92015-08-26 10:57:45 +0000177int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
178 struct perf_probe_arg *pvar);
179
Ravi Bangoria99e608b2016-08-09 01:23:25 -0500180struct map *get_target_map(const char *target, bool user);
181
182void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
183 int ntevs);
184
Masami Hiramatsu50656ee2009-11-30 19:19:58 -0500185#endif /*_PROBE_EVENT_H */