0001
0002 #ifndef _PROBE_FINDER_H
0003 #define _PROBE_FINDER_H
0004
0005 #include <stdbool.h>
0006 #include "intlist.h"
0007 #include "build-id.h"
0008 #include "probe-event.h"
0009 #include <linux/ctype.h>
0010
0011 #define MAX_PROBE_BUFFER 1024
0012 #define MAX_PROBES 128
0013 #define MAX_PROBE_ARGS 128
0014
0015 #define PROBE_ARG_VARS "$vars"
0016 #define PROBE_ARG_PARAMS "$params"
0017
0018 static inline int is_c_varname(const char *name)
0019 {
0020
0021 return isalpha(name[0]) || name[0] == '_';
0022 }
0023
0024 #ifdef HAVE_DWARF_SUPPORT
0025
0026 #include "dwarf-aux.h"
0027
0028
0029
0030
0031 struct debuginfo {
0032 Dwarf *dbg;
0033 Dwfl_Module *mod;
0034 Dwfl *dwfl;
0035 Dwarf_Addr bias;
0036 const unsigned char *build_id;
0037 };
0038
0039
0040 struct debuginfo *debuginfo__new(const char *path);
0041 void debuginfo__delete(struct debuginfo *dbg);
0042
0043
0044 int debuginfo__find_trace_events(struct debuginfo *dbg,
0045 struct perf_probe_event *pev,
0046 struct probe_trace_event **tevs);
0047
0048
0049 int debuginfo__find_probe_point(struct debuginfo *dbg, u64 addr,
0050 struct perf_probe_point *ppt);
0051
0052 int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs,
0053 bool adjust_offset);
0054
0055
0056 int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr);
0057
0058
0059 int debuginfo__find_available_vars_at(struct debuginfo *dbg,
0060 struct perf_probe_event *pev,
0061 struct variable_list **vls);
0062
0063
0064 int find_source_path(const char *raw_path, const char *sbuild_id,
0065 const char *comp_dir, char **new_path);
0066
0067 struct probe_finder {
0068 struct perf_probe_event *pev;
0069 struct debuginfo *dbg;
0070
0071
0072 int (*callback)(Dwarf_Die *sc_die, struct probe_finder *pf);
0073
0074
0075 int lno;
0076 Dwarf_Addr addr;
0077 const char *fname;
0078 Dwarf_Die cu_die;
0079 Dwarf_Die sp_die;
0080 struct intlist *lcache;
0081
0082
0083 #if _ELFUTILS_PREREQ(0, 142)
0084
0085 Dwarf_CFI *cfi_eh;
0086
0087 Dwarf_CFI *cfi_dbg;
0088 #endif
0089 Dwarf_Op *fb_ops;
0090 unsigned int machine;
0091 struct perf_probe_arg *pvar;
0092 struct probe_trace_arg *tvar;
0093 bool skip_empty_arg;
0094 };
0095
0096 struct trace_event_finder {
0097 struct probe_finder pf;
0098 Dwfl_Module *mod;
0099 struct probe_trace_event *tevs;
0100 int ntevs;
0101 int max_tevs;
0102 };
0103
0104 struct available_var_finder {
0105 struct probe_finder pf;
0106 Dwfl_Module *mod;
0107 struct variable_list *vls;
0108 int nvls;
0109 int max_vls;
0110 bool child;
0111 };
0112
0113 struct line_finder {
0114 struct line_range *lr;
0115
0116 const char *fname;
0117 int lno_s;
0118 int lno_e;
0119 Dwarf_Die cu_die;
0120 Dwarf_Die sp_die;
0121 int found;
0122 };
0123
0124 #endif
0125
0126 #endif