blob: ba926c30f8cdcc3718f75cb51ef57f7f3f5c5c95 [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 Hiramatsuddb2f582015-05-08 10:03:31 +090015 int max_probes;
16};
17extern struct probe_conf probe_conf;
Masami Hiramatsuf4d7da42010-03-16 18:06:05 -040018extern bool probe_event_dry_run;
19
Srikar Dronamraju225466f2012-04-16 17:39:09 +053020/* kprobe-tracer and uprobe-tracer tracing point */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053021struct probe_trace_point {
Masami Hiramatsu4c859352015-05-08 10:03:35 +090022 char *realname; /* function real name (if needed) */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040023 char *symbol; /* Base symbol */
Masami Hiramatsu190b57f2011-06-27 16:27:45 +090024 char *module; /* Module name */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040025 unsigned long offset; /* Offset from symbol */
Masami Hiramatsufb7345b2013-12-26 05:41:53 +000026 unsigned long address; /* Actual address of the trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040027 bool retprobe; /* Return probe flag */
28};
29
Srikar Dronamraju0e608362010-07-29 19:43:51 +053030/* probe-tracer tracing argument referencing offset */
31struct probe_trace_arg_ref {
32 struct probe_trace_arg_ref *next; /* Next reference */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040033 long offset; /* Offset value */
34};
35
Srikar Dronamraju225466f2012-04-16 17:39:09 +053036/* kprobe-tracer and uprobe-tracer tracing argument */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053037struct probe_trace_arg {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040038 char *name; /* Argument name */
39 char *value; /* Base value */
Masami Hiramatsu49849122010-04-12 13:17:15 -040040 char *type; /* Type name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053041 struct probe_trace_arg_ref *ref; /* Referencing offset */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040042};
43
Srikar Dronamraju225466f2012-04-16 17:39:09 +053044/* kprobe-tracer and uprobe-tracer tracing event (point + arg) */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053045struct probe_trace_event {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040046 char *event; /* Event name */
47 char *group; /* Group name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053048 struct probe_trace_point point; /* Trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040049 int nargs; /* Number of args */
Srikar Dronamraju225466f2012-04-16 17:39:09 +053050 bool uprobes; /* uprobes only */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053051 struct probe_trace_arg *args; /* Arguments */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040052};
53
54/* Perf probe probing point */
55struct perf_probe_point {
56 char *file; /* File path */
57 char *function; /* Function name */
58 int line; /* Line number */
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030059 bool retprobe; /* Return probe flag */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040060 char *lazy_line; /* Lazy matching pattern */
61 unsigned long offset; /* Offset from function entry */
Wang Nanda15bd92015-08-26 10:57:45 +000062 unsigned long abs_address; /* Absolute address of the point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040063};
64
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040065/* Perf probe probing argument field chain */
66struct perf_probe_arg_field {
67 struct perf_probe_arg_field *next; /* Next field */
68 char *name; /* Name of the field */
Masami Hiramatsub2a3c122010-05-19 15:57:42 -040069 long index; /* Array index number */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040070 bool ref; /* Referencing flag */
71};
72
Masami Hiramatsu4235b042010-03-16 18:06:12 -040073/* Perf probe probing argument */
74struct perf_probe_arg {
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040075 char *name; /* Argument name */
Masami Hiramatsu48481932010-04-12 13:16:53 -040076 char *var; /* Variable name */
Masami Hiramatsu11a1ca32010-04-12 13:17:22 -040077 char *type; /* Type name */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040078 struct perf_probe_arg_field *field; /* Structure fields */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040079};
80
81/* Perf probe probing event (point + arg) */
82struct 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 Hiramatsu7afb3fa2015-04-01 19:25:39 +090087 bool uprobes; /* Uprobe event flag */
88 char *target; /* Target binary */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040089 struct perf_probe_arg *args; /* Arguments */
Wang Nan12fae5e2015-09-04 21:16:00 +090090 struct probe_trace_event *tevs;
91 int ntevs;
Masami Hiramatsu4235b042010-03-16 18:06:12 -040092};
93
Masami Hiramatsu4235b042010-03-16 18:06:12 -040094/* Line range */
95struct line_range {
96 char *file; /* File name */
97 char *function; /* Function name */
Masami Hiramatsud3b63d72010-04-14 18:39:42 -040098 int start; /* Start line number */
99 int end; /* End line number */
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400100 int offset; /* Start line offset */
101 char *path; /* Real path name */
Masami Hiramatsu6a330a32010-07-09 18:29:11 +0900102 char *comp_dir; /* Compile directory */
Masami Hiramatsu5a622572014-02-06 05:32:09 +0000103 struct intlist *line_list; /* Visible lines */
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400104};
105
Masami Hiramatsucf6eb482010-10-21 19:13:23 +0900106/* List of variables */
107struct variable_list {
108 struct probe_trace_point point; /* Actual probepoint */
109 struct strlist *vars; /* Available variables */
110};
111
Wang Nan5a023b52015-06-19 08:42:48 +0000112struct map;
Namhyung Kim9bae1e82015-09-10 11:27:05 +0900113int init_probe_symbol_maps(bool user_only);
114void exit_probe_symbol_maps(void);
Wang Nan5a023b52015-06-19 08:42:48 +0000115
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400116/* Command string to events */
Masami Hiramatsu146a1432010-04-12 13:17:42 -0400117extern int parse_perf_probe_command(const char *cmd,
118 struct perf_probe_event *pev);
Masami Hiramatsu92f6c722015-07-15 18:14:07 +0900119extern int parse_probe_trace_command(const char *cmd,
120 struct probe_trace_event *tev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400121
122/* Events to command string */
123extern char *synthesize_perf_probe_command(struct perf_probe_event *pev);
Srikar Dronamraju0e608362010-07-29 19:43:51 +0530124extern char *synthesize_probe_trace_command(struct probe_trace_event *tev);
Masami Hiramatsu7df2f322010-03-16 18:06:26 -0400125extern int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf,
126 size_t len);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400127
128/* Check the perf_probe_event needs debuginfo */
129extern bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
130
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400131/* Release event contents */
132extern void clear_perf_probe_event(struct perf_probe_event *pev);
Masami Hiramatsu92f6c722015-07-15 18:14:07 +0900133extern void clear_probe_trace_event(struct probe_trace_event *tev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400134
135/* Command string to line-range */
Masami Hiramatsu146a1432010-04-12 13:17:42 -0400136extern int parse_line_range_desc(const char *cmd, struct line_range *lr);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400137
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000138/* Release line range members */
139extern void line_range__clear(struct line_range *lr);
140
141/* Initialize line range */
Masami Hiramatsu5a622572014-02-06 05:32:09 +0000142extern int line_range__init(struct line_range *lr);
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000143
Masami Hiramatsuddb2f582015-05-08 10:03:31 +0900144extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
Wang Nan12fae5e2015-09-04 21:16:00 +0900145extern int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs);
146extern int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs);
147extern void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs);
Masami Hiramatsu307a4642015-05-05 11:29:48 +0900148extern int del_perf_probe_events(struct strfilter *filter);
Namhyung Kime607f142015-09-04 21:16:03 +0900149
Namhyung Kimb02137c2015-09-04 21:16:01 +0900150extern 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 Hiramatsub6a89642015-04-24 18:47:50 +0900153extern int show_perf_probe_events(struct strfilter *filter);
Masami Hiramatsu2b394bc2014-09-17 08:40:54 +0000154extern int show_line_range(struct line_range *lr, const char *module,
155 bool user);
Masami Hiramatsucf6eb482010-10-21 19:13:23 +0900156extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
Masami Hiramatsuddb2f582015-05-08 10:03:31 +0900157 struct strfilter *filter);
Srikar Dronamraju225466f2012-04-16 17:39:09 +0530158extern int show_available_funcs(const char *module, struct strfilter *filter,
159 bool user);
Naveen N. Raod5c2e2c2015-04-28 17:35:39 +0530160bool arch__prefers_symtab(void);
Naveen N. Rao7b6ff0b2015-04-28 17:35:40 +0530161void arch__fix_tev_from_maps(struct perf_probe_event *pev,
162 struct probe_trace_event *tev, struct map *map);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400163
Masami Hiramatsu92f6c722015-07-15 18:14:07 +0900164/* If there is no space to write, returns -E2BIG. */
165int e_snprintf(char *str, size_t size, const char *format, ...)
166 __attribute__((format(printf, 3, 4)));
167
Masami Hiramatsub498ce12009-11-30 19:20:25 -0500168/* Maximum index number of event-name postfix */
169#define MAX_EVENT_INDEX 1024
170
Wang Nanda15bd92015-08-26 10:57:45 +0000171int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
172 struct perf_probe_arg *pvar);
173
Masami Hiramatsu50656ee2009-11-30 19:19:58 -0500174#endif /*_PROBE_EVENT_H */