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