Commit | Line | Data |
---|---|---|
4ea42b18 MH |
1 | #ifndef _PROBE_FINDER_H |
2 | #define _PROBE_FINDER_H | |
3 | ||
804b3606 | 4 | #include <stdbool.h> |
4a58e611 | 5 | #include "util.h" |
5a62257a | 6 | #include "intlist.h" |
4235b045 | 7 | #include "probe-event.h" |
4a58e611 | 8 | |
27f3b24d MH |
9 | #define MAX_PROBE_BUFFER 1024 |
10 | #define MAX_PROBES 128 | |
7969ec77 | 11 | #define MAX_PROBE_ARGS 128 |
4ea42b18 MH |
12 | |
13 | static inline int is_c_varname(const char *name) | |
14 | { | |
15 | /* TODO */ | |
16 | return isalpha(name[0]) || name[0] == '_'; | |
17 | } | |
18 | ||
89fe808a | 19 | #ifdef HAVE_DWARF_SUPPORT |
ff741783 MH |
20 | |
21 | #include "dwarf-aux.h" | |
22 | ||
23 | /* TODO: export debuginfo data structure even if no dwarf support */ | |
24 | ||
25 | /* debug information structure */ | |
26 | struct debuginfo { | |
27 | Dwarf *dbg; | |
576b5237 | 28 | Dwfl_Module *mod; |
ff741783 MH |
29 | Dwfl *dwfl; |
30 | Dwarf_Addr bias; | |
31 | }; | |
32 | ||
a15ad2f5 | 33 | /* This also tries to open distro debuginfo */ |
ff741783 | 34 | extern struct debuginfo *debuginfo__new(const char *path); |
316c7136 | 35 | extern void debuginfo__delete(struct debuginfo *dbg); |
ff741783 | 36 | |
0e60836b | 37 | /* Find probe_trace_events specified by perf_probe_event from debuginfo */ |
316c7136 | 38 | extern int debuginfo__find_trace_events(struct debuginfo *dbg, |
ff741783 MH |
39 | struct perf_probe_event *pev, |
40 | struct probe_trace_event **tevs, | |
41 | int max_tevs); | |
4235b045 | 42 | |
fb1587d8 | 43 | /* Find a perf_probe_point from debuginfo */ |
316c7136 | 44 | extern int debuginfo__find_probe_point(struct debuginfo *dbg, |
ff741783 MH |
45 | unsigned long addr, |
46 | struct perf_probe_point *ppt); | |
fb1587d8 | 47 | |
cf6eb489 | 48 | /* Find a line range */ |
316c7136 | 49 | extern int debuginfo__find_line_range(struct debuginfo *dbg, |
ff741783 | 50 | struct line_range *lr); |
4ea42b18 | 51 | |
cf6eb489 | 52 | /* Find available variables */ |
316c7136 | 53 | extern int debuginfo__find_available_vars_at(struct debuginfo *dbg, |
ff741783 MH |
54 | struct perf_probe_event *pev, |
55 | struct variable_list **vls, | |
56 | int max_points, bool externs); | |
4ea42b18 MH |
57 | |
58 | struct probe_finder { | |
4235b045 | 59 | struct perf_probe_event *pev; /* Target probe event */ |
cf6eb489 MH |
60 | |
61 | /* Callback when a probe point is found */ | |
221d0611 | 62 | int (*callback)(Dwarf_Die *sc_die, struct probe_finder *pf); |
4ea42b18 MH |
63 | |
64 | /* For function searching */ | |
eed05fe7 | 65 | int lno; /* Line number */ |
804b3606 | 66 | Dwarf_Addr addr; /* Address */ |
4235b045 | 67 | const char *fname; /* Real file name */ |
804b3606 | 68 | Dwarf_Die cu_die; /* Current CU */ |
cd25f8bc | 69 | Dwarf_Die sp_die; |
5a62257a | 70 | struct intlist *lcache; /* Line cache for lazy match */ |
4ea42b18 MH |
71 | |
72 | /* For variable searching */ | |
7752f1b0 | 73 | #if _ELFUTILS_PREREQ(0, 142) |
a34a9854 | 74 | Dwarf_CFI *cfi; /* Call Frame Information */ |
7752f1b0 | 75 | #endif |
804b3606 | 76 | Dwarf_Op *fb_ops; /* Frame base attribute */ |
4235b045 | 77 | struct perf_probe_arg *pvar; /* Current target variable */ |
0e60836b | 78 | struct probe_trace_arg *tvar; /* Current result variable */ |
4ea42b18 | 79 | }; |
631c9def | 80 | |
cf6eb489 MH |
81 | struct trace_event_finder { |
82 | struct probe_finder pf; | |
576b5237 | 83 | Dwfl_Module *mod; /* For solving symbols */ |
cf6eb489 MH |
84 | struct probe_trace_event *tevs; /* Found trace events */ |
85 | int ntevs; /* Number of trace events */ | |
86 | int max_tevs; /* Max number of trace events */ | |
87 | }; | |
88 | ||
89 | struct available_var_finder { | |
90 | struct probe_finder pf; | |
576b5237 | 91 | Dwfl_Module *mod; /* For solving symbols */ |
cf6eb489 MH |
92 | struct variable_list *vls; /* Found variable lists */ |
93 | int nvls; /* Number of variable lists */ | |
94 | int max_vls; /* Max no. of variable lists */ | |
fb8c5a56 MH |
95 | bool externs; /* Find external vars too */ |
96 | bool child; /* Search child scopes */ | |
cf6eb489 MH |
97 | }; |
98 | ||
631c9def | 99 | struct line_finder { |
804b3606 MH |
100 | struct line_range *lr; /* Target line range */ |
101 | ||
102 | const char *fname; /* File name */ | |
103 | int lno_s; /* Start line number */ | |
104 | int lno_e; /* End line number */ | |
804b3606 | 105 | Dwarf_Die cu_die; /* Current CU */ |
cd25f8bc | 106 | Dwarf_Die sp_die; |
631c9def MH |
107 | int found; |
108 | }; | |
109 | ||
89fe808a | 110 | #endif /* HAVE_DWARF_SUPPORT */ |
4ea42b18 MH |
111 | |
112 | #endif /*_PROBE_FINDER_H */ |