Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / tools / perf / util / probe-finder.h
blob17e94d0c36f981dbf8dbc245410b9a4aa511d16c
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
11 static inline int is_c_varname(const char *name)
13 /* TODO */
14 return isalpha(name[0]) || name[0] == '_';
17 #ifdef DWARF_SUPPORT
19 #include "dwarf-aux.h"
21 /* TODO: export debuginfo data structure even if no dwarf support */
23 /* debug information structure */
24 struct debuginfo {
25 Dwarf *dbg;
26 Dwfl *dwfl;
27 Dwarf_Addr bias;
30 extern struct debuginfo *debuginfo__new(const char *path);
31 extern struct debuginfo *debuginfo__new_online_kernel(unsigned long addr);
32 extern void debuginfo__delete(struct debuginfo *self);
34 /* Find probe_trace_events specified by perf_probe_event from debuginfo */
35 extern int debuginfo__find_trace_events(struct debuginfo *self,
36 struct perf_probe_event *pev,
37 struct probe_trace_event **tevs,
38 int max_tevs);
40 /* Find a perf_probe_point from debuginfo */
41 extern int debuginfo__find_probe_point(struct debuginfo *self,
42 unsigned long addr,
43 struct perf_probe_point *ppt);
45 /* Find a line range */
46 extern int debuginfo__find_line_range(struct debuginfo *self,
47 struct line_range *lr);
49 /* Find available variables */
50 extern int debuginfo__find_available_vars_at(struct debuginfo *self,
51 struct perf_probe_event *pev,
52 struct variable_list **vls,
53 int max_points, bool externs);
55 struct probe_finder {
56 struct perf_probe_event *pev; /* Target probe event */
58 /* Callback when a probe point is found */
59 int (*callback)(Dwarf_Die *sc_die, struct probe_finder *pf);
61 /* For function searching */
62 int lno; /* Line number */
63 Dwarf_Addr addr; /* Address */
64 const char *fname; /* Real file name */
65 Dwarf_Die cu_die; /* Current CU */
66 Dwarf_Die sp_die;
67 struct list_head lcache; /* Line cache for lazy match */
69 /* For variable searching */
70 #if _ELFUTILS_PREREQ(0, 142)
71 Dwarf_CFI *cfi; /* Call Frame Information */
72 #endif
73 Dwarf_Op *fb_ops; /* Frame base attribute */
74 struct perf_probe_arg *pvar; /* Current target variable */
75 struct probe_trace_arg *tvar; /* Current result variable */
78 struct trace_event_finder {
79 struct probe_finder pf;
80 struct probe_trace_event *tevs; /* Found trace events */
81 int ntevs; /* Number of trace events */
82 int max_tevs; /* Max number of trace events */
85 struct available_var_finder {
86 struct probe_finder pf;
87 struct variable_list *vls; /* Found variable lists */
88 int nvls; /* Number of variable lists */
89 int max_vls; /* Max no. of variable lists */
90 bool externs; /* Find external vars too */
91 bool child; /* Search child scopes */
94 struct line_finder {
95 struct line_range *lr; /* Target line range */
97 const char *fname; /* File name */
98 int lno_s; /* Start line number */
99 int lno_e; /* End line number */
100 Dwarf_Die cu_die; /* Current CU */
101 Dwarf_Die sp_die;
102 int found;
105 #endif /* DWARF_SUPPORT */
107 #endif /*_PROBE_FINDER_H */