fix a kmap leak in virtio_console
[linux/fpc-iii.git] / tools / perf / util / probe-finder.h
blobffc33cdd25cc343816fd9e05586832bf48b82205
1 #ifndef _PROBE_FINDER_H
2 #define _PROBE_FINDER_H
4 #include <stdbool.h>
5 #include "util.h"
6 #include "probe-event.h"
8 #define MAX_PROBE_BUFFER 1024
9 #define MAX_PROBES 128
10 #define MAX_PROBE_ARGS 128
12 static inline int is_c_varname(const char *name)
14 /* TODO */
15 return isalpha(name[0]) || name[0] == '_';
18 #ifdef HAVE_DWARF_SUPPORT
20 #include "dwarf-aux.h"
22 /* TODO: export debuginfo data structure even if no dwarf support */
24 /* debug information structure */
25 struct debuginfo {
26 Dwarf *dbg;
27 Dwfl_Module *mod;
28 Dwfl *dwfl;
29 Dwarf_Addr bias;
32 extern struct debuginfo *debuginfo__new(const char *path);
33 extern struct debuginfo *debuginfo__new_online_kernel(unsigned long addr);
34 extern void debuginfo__delete(struct debuginfo *dbg);
36 /* Find probe_trace_events specified by perf_probe_event from debuginfo */
37 extern int debuginfo__find_trace_events(struct debuginfo *dbg,
38 struct perf_probe_event *pev,
39 struct probe_trace_event **tevs,
40 int max_tevs);
42 /* Find a perf_probe_point from debuginfo */
43 extern int debuginfo__find_probe_point(struct debuginfo *dbg,
44 unsigned long addr,
45 struct perf_probe_point *ppt);
47 /* Find a line range */
48 extern int debuginfo__find_line_range(struct debuginfo *dbg,
49 struct line_range *lr);
51 /* Find available variables */
52 extern int debuginfo__find_available_vars_at(struct debuginfo *dbg,
53 struct perf_probe_event *pev,
54 struct variable_list **vls,
55 int max_points, bool externs);
57 struct probe_finder {
58 struct perf_probe_event *pev; /* Target probe event */
60 /* Callback when a probe point is found */
61 int (*callback)(Dwarf_Die *sc_die, struct probe_finder *pf);
63 /* For function searching */
64 int lno; /* Line number */
65 Dwarf_Addr addr; /* Address */
66 const char *fname; /* Real file name */
67 Dwarf_Die cu_die; /* Current CU */
68 Dwarf_Die sp_die;
69 struct list_head lcache; /* Line cache for lazy match */
71 /* For variable searching */
72 #if _ELFUTILS_PREREQ(0, 142)
73 Dwarf_CFI *cfi; /* Call Frame Information */
74 #endif
75 Dwarf_Op *fb_ops; /* Frame base attribute */
76 struct perf_probe_arg *pvar; /* Current target variable */
77 struct probe_trace_arg *tvar; /* Current result variable */
80 struct trace_event_finder {
81 struct probe_finder pf;
82 Dwfl_Module *mod; /* For solving symbols */
83 struct probe_trace_event *tevs; /* Found trace events */
84 int ntevs; /* Number of trace events */
85 int max_tevs; /* Max number of trace events */
88 struct available_var_finder {
89 struct probe_finder pf;
90 Dwfl_Module *mod; /* For solving symbols */
91 struct variable_list *vls; /* Found variable lists */
92 int nvls; /* Number of variable lists */
93 int max_vls; /* Max no. of variable lists */
94 bool externs; /* Find external vars too */
95 bool child; /* Search child scopes */
98 struct line_finder {
99 struct line_range *lr; /* Target line range */
101 const char *fname; /* File name */
102 int lno_s; /* Start line number */
103 int lno_e; /* End line number */
104 Dwarf_Die cu_die; /* Current CU */
105 Dwarf_Die sp_die;
106 int found;
109 #endif /* HAVE_DWARF_SUPPORT */
111 #endif /*_PROBE_FINDER_H */