blob: f9f3de8b4220b9c4989016f212192cb48cd83aeb [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 Hiramatsu4de189f2009-11-30 19:20:17 -05005#include "strlist.h"
Masami Hiramatsubd09d7b2011-01-20 23:15:39 +09006#include "strfilter.h"
Masami Hiramatsu50656ee2009-11-30 19:19:58 -05007
Masami Hiramatsuf4d7da42010-03-16 18:06:05 -04008extern bool probe_event_dry_run;
9
Srikar Dronamraju225466f2012-04-16 17:39:09 +053010/* kprobe-tracer and uprobe-tracer tracing point */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053011struct probe_trace_point {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040012 char *symbol; /* Base symbol */
Masami Hiramatsu190b57f2011-06-27 16:27:45 +090013 char *module; /* Module name */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040014 unsigned long offset; /* Offset from symbol */
15 bool retprobe; /* Return probe flag */
16};
17
Srikar Dronamraju0e608362010-07-29 19:43:51 +053018/* probe-tracer tracing argument referencing offset */
19struct probe_trace_arg_ref {
20 struct probe_trace_arg_ref *next; /* Next reference */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040021 long offset; /* Offset value */
22};
23
Srikar Dronamraju225466f2012-04-16 17:39:09 +053024/* kprobe-tracer and uprobe-tracer tracing argument */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053025struct probe_trace_arg {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040026 char *name; /* Argument name */
27 char *value; /* Base value */
Masami Hiramatsu49849122010-04-12 13:17:15 -040028 char *type; /* Type name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053029 struct probe_trace_arg_ref *ref; /* Referencing offset */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040030};
31
Srikar Dronamraju225466f2012-04-16 17:39:09 +053032/* kprobe-tracer and uprobe-tracer tracing event (point + arg) */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053033struct probe_trace_event {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040034 char *event; /* Event name */
35 char *group; /* Group name */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053036 struct probe_trace_point point; /* Trace point */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040037 int nargs; /* Number of args */
Srikar Dronamraju225466f2012-04-16 17:39:09 +053038 bool uprobes; /* uprobes only */
Srikar Dronamraju0e608362010-07-29 19:43:51 +053039 struct probe_trace_arg *args; /* Arguments */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040040};
41
42/* Perf probe probing point */
43struct perf_probe_point {
44 char *file; /* File path */
45 char *function; /* Function name */
46 int line; /* Line number */
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030047 bool retprobe; /* Return probe flag */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040048 char *lazy_line; /* Lazy matching pattern */
49 unsigned long offset; /* Offset from function entry */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040050};
51
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040052/* Perf probe probing argument field chain */
53struct perf_probe_arg_field {
54 struct perf_probe_arg_field *next; /* Next field */
55 char *name; /* Name of the field */
Masami Hiramatsub2a3c122010-05-19 15:57:42 -040056 long index; /* Array index number */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040057 bool ref; /* Referencing flag */
58};
59
Masami Hiramatsu4235b042010-03-16 18:06:12 -040060/* Perf probe probing argument */
61struct perf_probe_arg {
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040062 char *name; /* Argument name */
Masami Hiramatsu48481932010-04-12 13:16:53 -040063 char *var; /* Variable name */
Masami Hiramatsu11a1ca32010-04-12 13:17:22 -040064 char *type; /* Type name */
Masami Hiramatsu7df2f322010-03-16 18:06:26 -040065 struct perf_probe_arg_field *field; /* Structure fields */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040066};
67
68/* Perf probe probing event (point + arg) */
69struct perf_probe_event {
70 char *event; /* Event name */
71 char *group; /* Group name */
72 struct perf_probe_point point; /* Probe point */
73 int nargs; /* Number of arguments */
Srikar Dronamraju225466f2012-04-16 17:39:09 +053074 bool uprobes;
Masami Hiramatsu4235b042010-03-16 18:06:12 -040075 struct perf_probe_arg *args; /* Arguments */
76};
77
78
79/* Line number container */
80struct line_node {
81 struct list_head list;
Masami Hiramatsud3b63d72010-04-14 18:39:42 -040082 int line;
Masami Hiramatsu4235b042010-03-16 18:06:12 -040083};
84
85/* Line range */
86struct line_range {
87 char *file; /* File name */
88 char *function; /* Function name */
Masami Hiramatsud3b63d72010-04-14 18:39:42 -040089 int start; /* Start line number */
90 int end; /* End line number */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040091 int offset; /* Start line offset */
92 char *path; /* Real path name */
Masami Hiramatsu6a330a32010-07-09 18:29:11 +090093 char *comp_dir; /* Compile directory */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040094 struct list_head line_list; /* Visible lines */
95};
96
Masami Hiramatsucf6eb482010-10-21 19:13:23 +090097/* List of variables */
98struct variable_list {
99 struct probe_trace_point point; /* Actual probepoint */
100 struct strlist *vars; /* Available variables */
101};
102
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400103/* Command string to events */
Masami Hiramatsu146a1432010-04-12 13:17:42 -0400104extern int parse_perf_probe_command(const char *cmd,
105 struct perf_probe_event *pev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400106
107/* Events to command string */
108extern char *synthesize_perf_probe_command(struct perf_probe_event *pev);
Srikar Dronamraju0e608362010-07-29 19:43:51 +0530109extern char *synthesize_probe_trace_command(struct probe_trace_event *tev);
Masami Hiramatsu7df2f322010-03-16 18:06:26 -0400110extern int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf,
111 size_t len);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400112
113/* Check the perf_probe_event needs debuginfo */
114extern bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
115
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400116/* Release event contents */
117extern void clear_perf_probe_event(struct perf_probe_event *pev);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400118
119/* Command string to line-range */
Masami Hiramatsu146a1432010-04-12 13:17:42 -0400120extern int parse_line_range_desc(const char *cmd, struct line_range *lr);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400121
Masami Hiramatsu469b9b82010-10-21 19:13:41 +0900122/* Internal use: Return kernel/module path */
123extern const char *kernel_get_module_path(const char *module);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400124
Masami Hiramatsuef4a3562010-04-21 15:56:40 -0400125extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
Masami Hiramatsu469b9b82010-10-21 19:13:41 +0900126 int max_probe_points, const char *module,
127 bool force_add);
Masami Hiramatsu146a1432010-04-12 13:17:42 -0400128extern int del_perf_probe_events(struct strlist *dellist);
129extern int show_perf_probe_events(void);
Masami Hiramatsu469b9b82010-10-21 19:13:41 +0900130extern int show_line_range(struct line_range *lr, const char *module);
Masami Hiramatsucf6eb482010-10-21 19:13:23 +0900131extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
Masami Hiramatsu469b9b82010-10-21 19:13:41 +0900132 int max_probe_points, const char *module,
Masami Hiramatsubd09d7b2011-01-20 23:15:39 +0900133 struct strfilter *filter, bool externs);
Srikar Dronamraju225466f2012-04-16 17:39:09 +0530134extern int show_available_funcs(const char *module, struct strfilter *filter,
135 bool user);
Masami Hiramatsu4235b042010-03-16 18:06:12 -0400136
Masami Hiramatsub498ce12009-11-30 19:20:25 -0500137/* Maximum index number of event-name postfix */
138#define MAX_EVENT_INDEX 1024
139
Masami Hiramatsu50656ee2009-11-30 19:19:58 -0500140#endif /*_PROBE_EVENT_H */