1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _PROBE_FINDER_H
3 #define _PROBE_FINDER_H
8 #include "probe-event.h"
9 #include <linux/ctype.h>
11 #define MAX_PROBE_BUFFER 1024
12 #define MAX_PROBES 128
13 #define MAX_PROBE_ARGS 128
15 #define PROBE_ARG_VARS "$vars"
16 #define PROBE_ARG_PARAMS "$params"
18 static inline int is_c_varname(const char *name
)
21 return isalpha(name
[0]) || name
[0] == '_';
24 #ifdef HAVE_DWARF_SUPPORT
26 #include "dwarf-aux.h"
28 /* TODO: export debuginfo data structure even if no dwarf support */
30 /* debug information structure */
36 const unsigned char *build_id
;
39 /* This also tries to open distro debuginfo */
40 struct debuginfo
*debuginfo__new(const char *path
);
41 void debuginfo__delete(struct debuginfo
*dbg
);
43 /* Find probe_trace_events specified by perf_probe_event from debuginfo */
44 int debuginfo__find_trace_events(struct debuginfo
*dbg
,
45 struct perf_probe_event
*pev
,
46 struct probe_trace_event
**tevs
);
48 /* Find a perf_probe_point from debuginfo */
49 int debuginfo__find_probe_point(struct debuginfo
*dbg
, unsigned long addr
,
50 struct perf_probe_point
*ppt
);
52 int debuginfo__get_text_offset(struct debuginfo
*dbg
, Dwarf_Addr
*offs
,
55 /* Find a line range */
56 int debuginfo__find_line_range(struct debuginfo
*dbg
, struct line_range
*lr
);
58 /* Find available variables */
59 int debuginfo__find_available_vars_at(struct debuginfo
*dbg
,
60 struct perf_probe_event
*pev
,
61 struct variable_list
**vls
);
63 /* Find a src file from a DWARF tag path */
64 int find_source_path(const char *raw_path
, const char *sbuild_id
,
65 const char *comp_dir
, char **new_path
);
68 struct perf_probe_event
*pev
; /* Target probe event */
69 struct debuginfo
*dbg
;
71 /* Callback when a probe point is found */
72 int (*callback
)(Dwarf_Die
*sc_die
, struct probe_finder
*pf
);
74 /* For function searching */
75 int lno
; /* Line number */
76 Dwarf_Addr addr
; /* Address */
77 const char *fname
; /* Real file name */
78 Dwarf_Die cu_die
; /* Current CU */
80 struct intlist
*lcache
; /* Line cache for lazy match */
82 /* For variable searching */
83 #if _ELFUTILS_PREREQ(0, 142)
84 /* Call Frame Information from .eh_frame */
86 /* Call Frame Information from .debug_frame */
89 Dwarf_Op
*fb_ops
; /* Frame base attribute */
90 unsigned int machine
; /* Target machine arch */
91 struct perf_probe_arg
*pvar
; /* Current target variable */
92 struct probe_trace_arg
*tvar
; /* Current result variable */
93 bool skip_empty_arg
; /* Skip non-exist args */
96 struct trace_event_finder
{
97 struct probe_finder pf
;
98 Dwfl_Module
*mod
; /* For solving symbols */
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 */
104 struct available_var_finder
{
105 struct probe_finder pf
;
106 Dwfl_Module
*mod
; /* For solving symbols */
107 struct variable_list
*vls
; /* Found variable lists */
108 int nvls
; /* Number of variable lists */
109 int max_vls
; /* Max no. of variable lists */
110 bool child
; /* Search child scopes */
114 struct line_range
*lr
; /* Target line range */
116 const char *fname
; /* File name */
117 int lno_s
; /* Start line number */
118 int lno_e
; /* End line number */
119 Dwarf_Die cu_die
; /* Current CU */
124 #endif /* HAVE_DWARF_SUPPORT */
126 #endif /*_PROBE_FINDER_H */