blob: 633aba77e0cb6666de06eb289891b4a4209035ba [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;
12 bool force_add;
Masami Hiramatsu6cfd1f62015-05-08 10:03:33 +090013 bool no_inlines;
Masami Hiramatsuddb2f582015-05-08 10:03:31 +090014 int max_probes;
15};
16extern struct probe_conf probe_conf;
Masami Hiramatsuf4d7da42010-03-16 18:06:05 -040017extern bool probe_event_dry_run;
18
Srikar Dronamraju225466f2012-04-16 17:39:09 +053019/* kprobe-tracer and uprobe-tracer tracing point */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053020struct probe_trace_point {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040021 char *symbol; /* Base symbol */
Masami Hiramatsu190b57f2011-06-27 16:27:45 +090022 char *module; /* Module name */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040023 unsigned long offset; /* Offset from symbol */
Masami Hiramatsufb7345b2013-12-26 05:41:53 +000024 unsigned long address; /* Actual address of the trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040025 bool retprobe; /* Return probe flag */
26};
27
Srikar Dronamraju0e608362010-07-29 19:43:51 +053028/* probe-tracer tracing argument referencing offset */
29struct probe_trace_arg_ref {
30 struct probe_trace_arg_ref *next; /* Next reference */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040031 long offset; /* Offset value */
32};
33
Srikar Dronamraju225466f2012-04-16 17:39:09 +053034/* kprobe-tracer and uprobe-tracer tracing argument */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053035struct probe_trace_arg {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040036 char *name; /* Argument name */
37 char *value; /* Base value */
Masami Hiramatsu49849122010-04-12 13:17:15 -040038 char *type; /* Type name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053039 struct probe_trace_arg_ref *ref; /* Referencing offset */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040040};
41
Srikar Dronamraju225466f2012-04-16 17:39:09 +053042/* kprobe-tracer and uprobe-tracer tracing event (point + arg) */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053043struct probe_trace_event {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040044 char *event; /* Event name */
45 char *group; /* Group name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053046 struct probe_trace_point point; /* Trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040047 int nargs; /* Number of args */
Srikar Dronamraju225466f2012-04-16 17:39:09 +053048 bool uprobes; /* uprobes only */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053049 struct probe_trace_arg *args; /* Arguments */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040050};
51
52/* Perf probe probing point */
53struct perf_probe_point {
54 char *file; /* File path */
55 char *function; /* Function name */
56 int line; /* Line number */
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030057 bool retprobe; /* Return probe flag */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040058 char *lazy_line; /* Lazy matching pattern */
59 unsigned long offset; /* Offset from function entry */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040060};
61
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040062/* Perf probe probing argument field chain */
63struct perf_probe_arg_field {
64 struct perf_probe_arg_field *next; /* Next field */
65 char *name; /* Name of the field */
Masami Hiramatsub2a3c122010-05-19 15:57:42 -040066 long index; /* Array index number */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040067 bool ref; /* Referencing flag */
68};
69
Masami Hiramatsu4235b042010-03-16 18:06:12 -040070/* Perf probe probing argument */
71struct perf_probe_arg {
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040072 char *name; /* Argument name */
Masami Hiramatsu48481932010-04-12 13:16:53 -040073 char *var; /* Variable name */
Masami Hiramatsu11a1ca32010-04-12 13:17:22 -040074 char *type; /* Type name */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040075 struct perf_probe_arg_field *field; /* Structure fields */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040076};
77
78/* Perf probe probing event (point + arg) */
79struct perf_probe_event {
80 char *event; /* Event name */
81 char *group; /* Group name */
82 struct perf_probe_point point; /* Probe point */
83 int nargs; /* Number of arguments */
Masami Hiramatsu7afb3fa2015-04-01 19:25:39 +090084 bool uprobes; /* Uprobe event flag */
85 char *target; /* Target binary */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040086 struct perf_probe_arg *args; /* Arguments */
87};
88
Masami Hiramatsu4235b042010-03-16 18:06:12 -040089/* Line range */
90struct line_range {
91 char *file; /* File name */
92 char *function; /* Function name */
Masami Hiramatsud3b63d72010-04-14 18:39:42 -040093 int start; /* Start line number */
94 int end; /* End line number */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040095 int offset; /* Start line offset */
96 char *path; /* Real path name */
Masami Hiramatsu6a330a32010-07-09 18:29:11 +090097 char *comp_dir; /* Compile directory */
Masami Hiramatsu5a622572014-02-06 05:32:09 +000098 struct intlist *line_list; /* Visible lines */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040099};
100
Masami Hiramatsucf6eb482010-10-21 19:13:23 +0900101/* List of variables */
102struct variable_list {
103 struct probe_trace_point point; /* Actual probepoint */
104 struct strlist *vars; /* Available variables */
105};
106
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400107/* Command string to events */
Masami Hiramatsu146a1432010-04-12 13:17:42 -0400108extern int parse_perf_probe_command(const char *cmd,
109 struct perf_probe_event *pev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400110
111/* Events to command string */
112extern char *synthesize_perf_probe_command(struct perf_probe_event *pev);
Srikar Dronamraju0e608362010-07-29 19:43:51 +0530113extern char *synthesize_probe_trace_command(struct probe_trace_event *tev);
Masami Hiramatsu7df2f322010-03-16 18:06:26 -0400114extern int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf,
115 size_t len);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400116
117/* Check the perf_probe_event needs debuginfo */
118extern bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
119
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400120/* Release event contents */
121extern void clear_perf_probe_event(struct perf_probe_event *pev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400122
123/* Command string to line-range */
Masami Hiramatsu146a1432010-04-12 13:17:42 -0400124extern int parse_line_range_desc(const char *cmd, struct line_range *lr);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400125
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000126/* Release line range members */
127extern void line_range__clear(struct line_range *lr);
128
129/* Initialize line range */
Masami Hiramatsu5a622572014-02-06 05:32:09 +0000130extern int line_range__init(struct line_range *lr);
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000131
Masami Hiramatsu469b9b82010-10-21 19:13:41 +0900132/* Internal use: Return kernel/module path */
133extern const char *kernel_get_module_path(const char *module);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400134
Masami Hiramatsuddb2f582015-05-08 10:03:31 +0900135extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
Masami Hiramatsu307a4642015-05-05 11:29:48 +0900136extern int del_perf_probe_events(struct strfilter *filter);
Masami Hiramatsub6a89642015-04-24 18:47:50 +0900137extern int show_perf_probe_events(struct strfilter *filter);
Masami Hiramatsu2b394bc2014-09-17 08:40:54 +0000138extern int show_line_range(struct line_range *lr, const char *module,
139 bool user);
Masami Hiramatsucf6eb482010-10-21 19:13:23 +0900140extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
Masami Hiramatsuddb2f582015-05-08 10:03:31 +0900141 struct strfilter *filter);
Srikar Dronamraju225466f2012-04-16 17:39:09 +0530142extern int show_available_funcs(const char *module, struct strfilter *filter,
143 bool user);
Naveen N. Raod5c2e2c2015-04-28 17:35:39 +0530144bool arch__prefers_symtab(void);
Naveen N. Rao7b6ff0b2015-04-28 17:35:40 +0530145void arch__fix_tev_from_maps(struct perf_probe_event *pev,
146 struct probe_trace_event *tev, struct map *map);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400147
Masami Hiramatsub498ce12009-11-30 19:20:25 -0500148/* Maximum index number of event-name postfix */
149#define MAX_EVENT_INDEX 1024
150
Masami Hiramatsu50656ee2009-11-30 19:19:58 -0500151#endif /*_PROBE_EVENT_H */