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