]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
4ea42b18 MH |
2 | #ifndef _PROBE_FINDER_H |
3 | #define _PROBE_FINDER_H | |
4 | ||
804b3606 | 5 | #include <stdbool.h> |
5a62257a | 6 | #include "intlist.h" |
7cd5738d | 7 | #include "build-id.h" |
4235b045 | 8 | #include "probe-event.h" |
3052ba56 | 9 | #include <linux/ctype.h> |
4a58e611 | 10 | |
27f3b24d MH |
11 | #define MAX_PROBE_BUFFER 1024 |
12 | #define MAX_PROBES 128 | |
7969ec77 | 13 | #define MAX_PROBE_ARGS 128 |
4ea42b18 | 14 | |
f8bffbf1 MH |
15 | #define PROBE_ARG_VARS "$vars" |
16 | #define PROBE_ARG_PARAMS "$params" | |
17 | ||
4ea42b18 MH |
18 | static inline int is_c_varname(const char *name) |
19 | { | |
20 | /* TODO */ | |
21 | return isalpha(name[0]) || name[0] == '_'; | |
22 | } | |
23 | ||
89fe808a | 24 | #ifdef HAVE_DWARF_SUPPORT |
ff741783 MH |
25 | |
26 | #include "dwarf-aux.h" | |
27 | ||
28 | /* TODO: export debuginfo data structure even if no dwarf support */ | |
29 | ||
30 | /* debug information structure */ | |
31 | struct debuginfo { | |
32 | Dwarf *dbg; | |
576b5237 | 33 | Dwfl_Module *mod; |
ff741783 MH |
34 | Dwfl *dwfl; |
35 | Dwarf_Addr bias; | |
7cd5738d | 36 | const unsigned char *build_id; |
ff741783 MH |
37 | }; |
38 | ||
a15ad2f5 | 39 | /* This also tries to open distro debuginfo */ |
3938bad4 ACM |
40 | struct debuginfo *debuginfo__new(const char *path); |
41 | void debuginfo__delete(struct debuginfo *dbg); | |
ff741783 | 42 | |
0e60836b | 43 | /* Find probe_trace_events specified by perf_probe_event from debuginfo */ |
3938bad4 ACM |
44 | int debuginfo__find_trace_events(struct debuginfo *dbg, |
45 | struct perf_probe_event *pev, | |
46 | struct probe_trace_event **tevs); | |
4235b045 | 47 | |
fb1587d8 | 48 | /* Find a perf_probe_point from debuginfo */ |
22a66551 | 49 | int debuginfo__find_probe_point(struct debuginfo *dbg, u64 addr, |
3938bad4 | 50 | struct perf_probe_point *ppt); |
fb1587d8 | 51 | |
613f050d MH |
52 | int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs, |
53 | bool adjust_offset); | |
54 | ||
cf6eb489 | 55 | /* Find a line range */ |
3938bad4 | 56 | int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr); |
4ea42b18 | 57 | |
cf6eb489 | 58 | /* Find available variables */ |
3938bad4 ACM |
59 | int debuginfo__find_available_vars_at(struct debuginfo *dbg, |
60 | struct perf_probe_event *pev, | |
61 | struct variable_list **vls); | |
4ea42b18 | 62 | |
09ed8975 | 63 | /* Find a src file from a DWARF tag path */ |
7cd5738d MH |
64 | int find_source_path(const char *raw_path, const char *sbuild_id, |
65 | const char *comp_dir, char **new_path); | |
09ed8975 | 66 | |
4ea42b18 | 67 | struct probe_finder { |
4235b045 | 68 | struct perf_probe_event *pev; /* Target probe event */ |
7cd5738d | 69 | struct debuginfo *dbg; |
cf6eb489 MH |
70 | |
71 | /* Callback when a probe point is found */ | |
221d0611 | 72 | int (*callback)(Dwarf_Die *sc_die, struct probe_finder *pf); |
4ea42b18 MH |
73 | |
74 | /* For function searching */ | |
eed05fe7 | 75 | int lno; /* Line number */ |
804b3606 | 76 | Dwarf_Addr addr; /* Address */ |
4235b045 | 77 | const char *fname; /* Real file name */ |
804b3606 | 78 | Dwarf_Die cu_die; /* Current CU */ |
cd25f8bc | 79 | Dwarf_Die sp_die; |
5a62257a | 80 | struct intlist *lcache; /* Line cache for lazy match */ |
4ea42b18 MH |
81 | |
82 | /* For variable searching */ | |
7752f1b0 | 83 | #if _ELFUTILS_PREREQ(0, 142) |
270bde1e HK |
84 | /* Call Frame Information from .eh_frame */ |
85 | Dwarf_CFI *cfi_eh; | |
86 | /* Call Frame Information from .debug_frame */ | |
87 | Dwarf_CFI *cfi_dbg; | |
7752f1b0 | 88 | #endif |
804b3606 | 89 | Dwarf_Op *fb_ops; /* Frame base attribute */ |
293d5b43 | 90 | unsigned int machine; /* Target machine arch */ |
4235b045 | 91 | struct perf_probe_arg *pvar; /* Current target variable */ |
0e60836b | 92 | struct probe_trace_arg *tvar; /* Current result variable */ |
cb402730 | 93 | bool skip_empty_arg; /* Skip non-exist args */ |
4ea42b18 | 94 | }; |
631c9def | 95 | |
cf6eb489 MH |
96 | struct trace_event_finder { |
97 | struct probe_finder pf; | |
576b5237 | 98 | Dwfl_Module *mod; /* For solving symbols */ |
cf6eb489 MH |
99 | struct probe_trace_event *tevs; /* Found trace events */ |
100 | int ntevs; /* Number of trace events */ | |
101 | int max_tevs; /* Max number of trace events */ | |
102 | }; | |
103 | ||
104 | struct available_var_finder { | |
105 | struct probe_finder pf; | |
576b5237 | 106 | Dwfl_Module *mod; /* For solving symbols */ |
cf6eb489 MH |
107 | struct variable_list *vls; /* Found variable lists */ |
108 | int nvls; /* Number of variable lists */ | |
109 | int max_vls; /* Max no. of variable lists */ | |
fb8c5a56 | 110 | bool child; /* Search child scopes */ |
cf6eb489 MH |
111 | }; |
112 | ||
631c9def | 113 | struct line_finder { |
804b3606 MH |
114 | struct line_range *lr; /* Target line range */ |
115 | ||
116 | const char *fname; /* File name */ | |
117 | int lno_s; /* Start line number */ | |
118 | int lno_e; /* End line number */ | |
804b3606 | 119 | Dwarf_Die cu_die; /* Current CU */ |
cd25f8bc | 120 | Dwarf_Die sp_die; |
631c9def MH |
121 | int found; |
122 | }; | |
123 | ||
89fe808a | 124 | #endif /* HAVE_DWARF_SUPPORT */ |
4ea42b18 MH |
125 | |
126 | #endif /*_PROBE_FINDER_H */ |