blob: e01e9943139ff3b828ab8820aad9a5add4f34376 [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 Hiramatsuf4d7da42010-03-16 18:06:05 -04009extern bool probe_event_dry_run;
10
Srikar Dronamraju225466f2012-04-16 17:39:09 +053011/* kprobe-tracer and uprobe-tracer tracing point */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053012struct probe_trace_point {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040013 char *symbol; /* Base symbol */
Masami Hiramatsu190b57f2011-06-27 16:27:45 +090014 char *module; /* Module name */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040015 unsigned long offset; /* Offset from symbol */
Masami Hiramatsufb7345b2013-12-26 05:41:53 +000016 unsigned long address; /* Actual address of the trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040017 bool retprobe; /* Return probe flag */
18};
19
Srikar Dronamraju0e608362010-07-29 19:43:51 +053020/* probe-tracer tracing argument referencing offset */
21struct probe_trace_arg_ref {
22 struct probe_trace_arg_ref *next; /* Next reference */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040023 long offset; /* Offset value */
24};
25
Srikar Dronamraju225466f2012-04-16 17:39:09 +053026/* kprobe-tracer and uprobe-tracer tracing argument */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053027struct probe_trace_arg {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040028 char *name; /* Argument name */
29 char *value; /* Base value */
Masami Hiramatsu49849122010-04-12 13:17:15 -040030 char *type; /* Type name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053031 struct probe_trace_arg_ref *ref; /* Referencing offset */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040032};
33
Srikar Dronamraju225466f2012-04-16 17:39:09 +053034/* kprobe-tracer and uprobe-tracer tracing event (point + arg) */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053035struct probe_trace_event {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040036 char *event; /* Event name */
37 char *group; /* Group name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053038 struct probe_trace_point point; /* Trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040039 int nargs; /* Number of args */
Srikar Dronamraju225466f2012-04-16 17:39:09 +053040 bool uprobes; /* uprobes only */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053041 struct probe_trace_arg *args; /* Arguments */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040042};
43
44/* Perf probe probing point */
45struct perf_probe_point {
46 char *file; /* File path */
47 char *function; /* Function name */
48 int line; /* Line number */
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030049 bool retprobe; /* Return probe flag */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040050 char *lazy_line; /* Lazy matching pattern */
51 unsigned long offset; /* Offset from function entry */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040052};
53
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040054/* Perf probe probing argument field chain */
55struct perf_probe_arg_field {
56 struct perf_probe_arg_field *next; /* Next field */
57 char *name; /* Name of the field */
Masami Hiramatsub2a3c122010-05-19 15:57:42 -040058 long index; /* Array index number */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040059 bool ref; /* Referencing flag */
60};
61
Masami Hiramatsu4235b042010-03-16 18:06:12 -040062/* Perf probe probing argument */
63struct perf_probe_arg {
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040064 char *name; /* Argument name */
Masami Hiramatsu48481932010-04-12 13:16:53 -040065 char *var; /* Variable name */
Masami Hiramatsu11a1ca32010-04-12 13:17:22 -040066 char *type; /* Type name */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040067 struct perf_probe_arg_field *field; /* Structure fields */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040068};
69
70/* Perf probe probing event (point + arg) */
71struct perf_probe_event {
72 char *event; /* Event name */
73 char *group; /* Group name */
74 struct perf_probe_point point; /* Probe point */
75 int nargs; /* Number of arguments */
Srikar Dronamraju225466f2012-04-16 17:39:09 +053076 bool uprobes;
Masami Hiramatsu4235b042010-03-16 18:06:12 -040077 struct perf_probe_arg *args; /* Arguments */
78};
79
Masami Hiramatsu4235b042010-03-16 18:06:12 -040080/* Line range */
81struct line_range {
82 char *file; /* File name */
83 char *function; /* Function name */
Masami Hiramatsud3b63d72010-04-14 18:39:42 -040084 int start; /* Start line number */
85 int end; /* End line number */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040086 int offset; /* Start line offset */
87 char *path; /* Real path name */
Masami Hiramatsu6a330a32010-07-09 18:29:11 +090088 char *comp_dir; /* Compile directory */
Masami Hiramatsu5a622572014-02-06 05:32:09 +000089 struct intlist *line_list; /* Visible lines */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040090};
91
Masami Hiramatsucf6eb482010-10-21 19:13:23 +090092/* List of variables */
93struct variable_list {
94 struct probe_trace_point point; /* Actual probepoint */
95 struct strlist *vars; /* Available variables */
96};
97
Masami Hiramatsu4235b042010-03-16 18:06:12 -040098/* Command string to events */
Masami Hiramatsu146a1432010-04-12 13:17:42 -040099extern int parse_perf_probe_command(const char *cmd,
100 struct perf_probe_event *pev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400101
102/* Events to command string */
103extern char *synthesize_perf_probe_command(struct perf_probe_event *pev);
Srikar Dronamraju0e608362010-07-29 19:43:51 +0530104extern char *synthesize_probe_trace_command(struct probe_trace_event *tev);
Masami Hiramatsu7df2f322010-03-16 18:06:26 -0400105extern int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf,
106 size_t len);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400107
108/* Check the perf_probe_event needs debuginfo */
109extern bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
110
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400111/* Release event contents */
112extern void clear_perf_probe_event(struct perf_probe_event *pev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400113
114/* Command string to line-range */
Masami Hiramatsu146a1432010-04-12 13:17:42 -0400115extern int parse_line_range_desc(const char *cmd, struct line_range *lr);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400116
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000117/* Release line range members */
118extern void line_range__clear(struct line_range *lr);
119
120/* Initialize line range */
Masami Hiramatsu5a622572014-02-06 05:32:09 +0000121extern int line_range__init(struct line_range *lr);
Masami Hiramatsue53b00d2014-01-16 09:39:47 +0000122
Masami Hiramatsu469b9b82010-10-21 19:13:41 +0900123/* Internal use: Return kernel/module path */
124extern const char *kernel_get_module_path(const char *module);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400125
Masami Hiramatsuef4a3562010-04-21 15:56:40 -0400126extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
Masami Hiramatsu469b9b82010-10-21 19:13:41 +0900127 int max_probe_points, const char *module,
128 bool force_add);
Masami Hiramatsu146a1432010-04-12 13:17:42 -0400129extern int del_perf_probe_events(struct strlist *dellist);
130extern int show_perf_probe_events(void);
Masami Hiramatsu2b394bc2014-09-17 08:40:54 +0000131extern int show_line_range(struct line_range *lr, const char *module,
132 bool user);
Masami Hiramatsucf6eb482010-10-21 19:13:23 +0900133extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
Masami Hiramatsu469b9b82010-10-21 19:13:41 +0900134 int max_probe_points, const char *module,
Masami Hiramatsubd09d7b2011-01-20 23:15:39 +0900135 struct strfilter *filter, bool externs);
Srikar Dronamraju225466f2012-04-16 17:39:09 +0530136extern int show_available_funcs(const char *module, struct strfilter *filter,
137 bool user);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400138
Masami Hiramatsub498ce12009-11-30 19:20:25 -0500139/* Maximum index number of event-name postfix */
140#define MAX_EVENT_INDEX 1024
141
Masami Hiramatsu50656ee2009-11-30 19:19:58 -0500142#endif /*_PROBE_EVENT_H */