blob: e18ea9fe63857cb7a9b382dac563fd2c8cdfbd85 [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
Srikar Dronamraju225466f2012-04-16 17:39:09 +053021/* kprobe-tracer and uprobe-tracer tracing point */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053022struct probe_trace_point {
Masami Hiramatsu4c859352015-05-08 10:03:35 +090023 char *realname; /* function real name (if needed) */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040024 char *symbol; /* Base symbol */
Masami Hiramatsu190b57f2011-06-27 16:27:45 +090025 char *module; /* Module name */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040026 unsigned long offset; /* Offset from symbol */
Masami Hiramatsufb7345b2013-12-26 05:41:53 +000027 unsigned long address; /* Actual address of the trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040028 bool retprobe; /* Return probe flag */
29};
30
Srikar Dronamraju0e608362010-07-29 19:43:51 +053031/* probe-tracer tracing argument referencing offset */
32struct probe_trace_arg_ref {
33 struct probe_trace_arg_ref *next; /* Next reference */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040034 long offset; /* Offset value */
35};
36
Srikar Dronamraju225466f2012-04-16 17:39:09 +053037/* kprobe-tracer and uprobe-tracer tracing argument */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053038struct probe_trace_arg {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040039 char *name; /* Argument name */
40 char *value; /* Base value */
Masami Hiramatsu49849122010-04-12 13:17:15 -040041 char *type; /* Type name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053042 struct probe_trace_arg_ref *ref; /* Referencing offset */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040043};
44
Srikar Dronamraju225466f2012-04-16 17:39:09 +053045/* kprobe-tracer and uprobe-tracer tracing event (point + arg) */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053046struct probe_trace_event {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040047 char *event; /* Event name */
48 char *group; /* Group name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053049 struct probe_trace_point point; /* Trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040050 int nargs; /* Number of args */
Srikar Dronamraju225466f2012-04-16 17:39:09 +053051 bool uprobes; /* uprobes only */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053052 struct probe_trace_arg *args; /* Arguments */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040053};
54
55/* Perf probe probing point */
56struct perf_probe_point {
57 char *file; /* File path */
58 char *function; /* Function name */
59 int line; /* Line number */
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030060 bool retprobe; /* Return probe flag */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040061 char *lazy_line; /* Lazy matching pattern */
62 unsigned long offset; /* Offset from function entry */
Wang Nanda15bd92015-08-26 10:57:45 +000063 unsigned long abs_address; /* Absolute address of the point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040064};
65
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040066/* Perf probe probing argument field chain */
67struct perf_probe_arg_field {
68 struct perf_probe_arg_field *next; /* Next field */
69 char *name; /* Name of the field */
Masami Hiramatsub2a3c122010-05-19 15:57:42 -040070 long index; /* Array index number */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040071 bool ref; /* Referencing flag */
72};
73
Masami Hiramatsu4235b042010-03-16 18:06:12 -040074/* Perf probe probing argument */
75struct perf_probe_arg {
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040076 char *name; /* Argument name */
Masami Hiramatsu48481932010-04-12 13:16:53 -040077 char *var; /* Variable name */
Masami Hiramatsu11a1ca32010-04-12 13:17:22 -040078 char *type; /* Type name */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040079 struct perf_probe_arg_field *field; /* Structure fields */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040080};
81
82/* Perf probe probing event (point + arg) */
83struct 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 Hiramatsu36a009f2016-07-12 19:04:43 +090088 bool sdt; /* SDT/cached event flag */
Masami Hiramatsu7afb3fa2015-04-01 19:25:39 +090089 bool uprobes; /* Uprobe event flag */
90 char *target; /* Target binary */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040091 struct perf_probe_arg *args; /* Arguments */
Wang Nan12fae5e2015-09-04 21:16:00 +090092 struct probe_trace_event *tevs;
93 int ntevs;
Masami Hiramatsu4235b042010-03-16 18:06:12 -040094};
95
Masami Hiramatsu4235b042010-03-16 18:06:12 -040096/* Line range */
97struct line_range {
98 char *file; /* File name */
99 char *function; /* Function name */
Masami Hiramatsud3b63d72010-04-14 18:39:42 -0400100 int start; /* Start line number */
101 int end; /* End line number */
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400102 int offset; /* Start line offset */
103 char *path; /* Real path name */
Masami Hiramatsu6a330a32010-07-09 18:29:11 +0900104 char *comp_dir; /* Compile directory */
Masami Hiramatsu5a622572014-02-06 05:32:09 +0000105 struct intlist *line_list; /* Visible lines */
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400106};
107
Masami Hiramatsucf6eb482010-10-21 19:13:23 +0900108/* List of variables */
109struct variable_list {
110 struct probe_trace_point point; /* Actual probepoint */
111 struct strlist *vars; /* Available variables */
112};
113
Wang Nan5a023b52015-06-19 08:42:48 +0000114struct map;
Namhyung Kim9bae1e82015-09-10 11:27:05 +0900115int init_probe_symbol_maps(bool user_only);
116void exit_probe_symbol_maps(void);
Wang Nan5a023b52015-06-19 08:42:48 +0000117
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400118/* Command string to events */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300119int parse_perf_probe_command(const char *cmd, struct perf_probe_event *pev);
120int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400121
122/* Events to command string */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300123char *synthesize_perf_probe_command(struct perf_probe_event *pev);
124char *synthesize_probe_trace_command(struct probe_trace_event *tev);
Masami Hiramatsu909b0362016-04-28 03:37:14 +0900125char *synthesize_perf_probe_arg(struct perf_probe_arg *pa);
Masami Hiramatsuc4ff4922016-06-08 18:29:50 +0900126char *synthesize_perf_probe_point(struct perf_probe_point *pp);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400127
Masami Hiramatsu0542bb92016-06-08 18:29:40 +0900128int perf_probe_event__copy(struct perf_probe_event *dst,
129 struct perf_probe_event *src);
130
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400131/* Check the perf_probe_event needs debuginfo */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300132bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400133
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400134/* Release event contents */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300135void clear_perf_probe_event(struct perf_probe_event *pev);
136void clear_probe_trace_event(struct probe_trace_event *tev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400137
138/* Command string to line-range */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300139int parse_line_range_desc(const char *cmd, struct line_range *lr);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400140
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000141/* Release line range members */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300142void line_range__clear(struct line_range *lr);
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000143
144/* Initialize line range */
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300145int line_range__init(struct line_range *lr);
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000146
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300147int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
148int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs);
149int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs);
150void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs);
151int del_perf_probe_events(struct strfilter *filter);
Namhyung Kime607f142015-09-04 21:16:03 +0900152
Arnaldo Carvalho de Melo3938bad2016-03-23 15:06:35 -0300153int show_perf_probe_event(const char *group, const char *event,
154 struct perf_probe_event *pev,
155 const char *module, bool use_stdout);
156int show_perf_probe_events(struct strfilter *filter);
157int show_line_range(struct line_range *lr, const char *module, bool user);
158int show_available_vars(struct perf_probe_event *pevs, int npevs,
159 struct strfilter *filter);
160int show_available_funcs(const char *module, struct strfilter *filter, bool user);
Naveen N. Raod5c2e2c2015-04-28 17:35:39 +0530161bool arch__prefers_symtab(void);
Naveen N. Rao7b6ff0b2015-04-28 17:35:40 +0530162void arch__fix_tev_from_maps(struct perf_probe_event *pev,
Naveen N. Rao0b3c2262016-04-12 14:40:50 +0530163 struct probe_trace_event *tev, struct map *map,
164 struct symbol *sym);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400165
Masami Hiramatsu92f6c722015-07-15 18:14:07 +0900166/* If there is no space to write, returns -E2BIG. */
167int e_snprintf(char *str, size_t size, const char *format, ...)
168 __attribute__((format(printf, 3, 4)));
169
Masami Hiramatsub498ce12009-11-30 19:20:25 -0500170/* Maximum index number of event-name postfix */
171#define MAX_EVENT_INDEX 1024
172
Wang Nanda15bd92015-08-26 10:57:45 +0000173int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
174 struct perf_probe_arg *pvar);
175
Masami Hiramatsu50656ee2009-11-30 19:19:58 -0500176#endif /*_PROBE_EVENT_H */