1 #ifndef _PROBE_EVENT_H
2 #define _PROBE_EVENT_H
3 
4 #include <stdbool.h>
5 #include "strlist.h"
6 #include "strfilter.h"
7 
8 extern bool probe_event_dry_run;
9 
10 /* kprobe-tracer tracing point */
11 struct probe_trace_point {
12 	char		*symbol;	/* Base symbol */
13 	unsigned long	offset;		/* Offset from symbol */
14 	bool		retprobe;	/* Return probe flag */
15 };
16 
17 /* probe-tracer tracing argument referencing offset */
18 struct probe_trace_arg_ref {
19 	struct probe_trace_arg_ref	*next;	/* Next reference */
20 	long				offset;	/* Offset value */
21 };
22 
23 /* kprobe-tracer tracing argument */
24 struct probe_trace_arg {
25 	char				*name;	/* Argument name */
26 	char				*value;	/* Base value */
27 	char				*type;	/* Type name */
28 	struct probe_trace_arg_ref	*ref;	/* Referencing offset */
29 };
30 
31 /* kprobe-tracer tracing event (point + arg) */
32 struct probe_trace_event {
33 	char				*event;	/* Event name */
34 	char				*group;	/* Group name */
35 	struct probe_trace_point	point;	/* Trace point */
36 	int				nargs;	/* Number of args */
37 	struct probe_trace_arg		*args;	/* Arguments */
38 };
39 
40 /* Perf probe probing point */
41 struct perf_probe_point {
42 	char		*file;		/* File path */
43 	char		*function;	/* Function name */
44 	int		line;		/* Line number */
45 	bool		retprobe;	/* Return probe flag */
46 	char		*lazy_line;	/* Lazy matching pattern */
47 	unsigned long	offset;		/* Offset from function entry */
48 };
49 
50 /* Perf probe probing argument field chain */
51 struct perf_probe_arg_field {
52 	struct perf_probe_arg_field	*next;	/* Next field */
53 	char				*name;	/* Name of the field */
54 	long				index;	/* Array index number */
55 	bool				ref;	/* Referencing flag */
56 };
57 
58 /* Perf probe probing argument */
59 struct perf_probe_arg {
60 	char				*name;	/* Argument name */
61 	char				*var;	/* Variable name */
62 	char				*type;	/* Type name */
63 	struct perf_probe_arg_field	*field;	/* Structure fields */
64 };
65 
66 /* Perf probe probing event (point + arg) */
67 struct perf_probe_event {
68 	char			*event;	/* Event name */
69 	char			*group;	/* Group name */
70 	struct perf_probe_point	point;	/* Probe point */
71 	int			nargs;	/* Number of arguments */
72 	struct perf_probe_arg	*args;	/* Arguments */
73 };
74 
75 
76 /* Line number container */
77 struct line_node {
78 	struct list_head	list;
79 	int			line;
80 };
81 
82 /* Line range */
83 struct line_range {
84 	char			*file;		/* File name */
85 	char			*function;	/* Function name */
86 	int			start;		/* Start line number */
87 	int			end;		/* End line number */
88 	int			offset;		/* Start line offset */
89 	char			*path;		/* Real path name */
90 	char			*comp_dir;	/* Compile directory */
91 	struct list_head	line_list;	/* Visible lines */
92 };
93 
94 /* List of variables */
95 struct variable_list {
96 	struct probe_trace_point	point;	/* Actual probepoint */
97 	struct strlist			*vars;	/* Available variables */
98 };
99 
100 /* Command string to events */
101 extern int parse_perf_probe_command(const char *cmd,
102 				    struct perf_probe_event *pev);
103 
104 /* Events to command string */
105 extern char *synthesize_perf_probe_command(struct perf_probe_event *pev);
106 extern char *synthesize_probe_trace_command(struct probe_trace_event *tev);
107 extern int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf,
108 				     size_t len);
109 
110 /* Check the perf_probe_event needs debuginfo */
111 extern bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
112 
113 /* Release event contents */
114 extern void clear_perf_probe_event(struct perf_probe_event *pev);
115 
116 /* Command string to line-range */
117 extern int parse_line_range_desc(const char *cmd, struct line_range *lr);
118 
119 /* Internal use: Return kernel/module path */
120 extern const char *kernel_get_module_path(const char *module);
121 
122 extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
123 				 int max_probe_points, const char *module,
124 				 bool force_add);
125 extern int del_perf_probe_events(struct strlist *dellist);
126 extern int show_perf_probe_events(void);
127 extern int show_line_range(struct line_range *lr, const char *module);
128 extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
129 			       int max_probe_points, const char *module,
130 			       struct strfilter *filter, bool externs);
131 extern int show_available_funcs(const char *module, struct strfilter *filter);
132 
133 
134 /* Maximum index number of event-name postfix */
135 #define MAX_EVENT_INDEX	1024
136 
137 #endif /*_PROBE_EVENT_H */
138