blob: e1f61dcd18ff7ed18bff7a337ddcdf0dc8c68e36 [file] [log] [blame]
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -04001#ifndef _PROBE_FINDER_H
2#define _PROBE_FINDER_H
3
Masami Hiramatsu804b3602010-02-25 08:35:42 -05004#include <stdbool.h>
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -02005#include "util.h"
Masami Hiramatsu4235b042010-03-16 18:06:12 -04006#include "probe-event.h"
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -02007
Masami Hiramatsu27f3b242009-12-16 17:16:19 -05008#define MAX_PATH_LEN 256
9#define MAX_PROBE_BUFFER 1024
10#define MAX_PROBES 128
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040011
12static inline int is_c_varname(const char *name)
13{
14 /* TODO */
15 return isalpha(name[0]) || name[0] == '_';
16}
17
Masami Hiramatsu4b4da7f2010-03-22 13:10:26 -030018#ifdef DWARF_SUPPORT
Masami Hiramatsu4235b042010-03-16 18:06:12 -040019/* Find kprobe_trace_events specified by perf_probe_event from debuginfo */
20extern int find_kprobe_trace_events(int fd, struct perf_probe_event *pev,
Masami Hiramatsuef4a3562010-04-21 15:56:40 -040021 struct kprobe_trace_event **tevs,
22 int max_tevs);
Masami Hiramatsu4235b042010-03-16 18:06:12 -040023
Masami Hiramatsufb1587d2010-03-16 18:06:19 -040024/* Find a perf_probe_point from debuginfo */
25extern int find_perf_probe_point(int fd, unsigned long addr,
26 struct perf_probe_point *ppt);
27
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050028extern int find_line_range(int fd, struct line_range *lr);
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040029
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050030#include <dwarf.h>
Masami Hiramatsu804b3602010-02-25 08:35:42 -050031#include <libdw.h>
Masami Hiramatsu7752f1b2010-05-10 13:12:07 -040032#include <version.h>
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040033
34struct probe_finder {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040035 struct perf_probe_event *pev; /* Target probe event */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040036 struct kprobe_trace_event *tevs; /* Result trace events */
Masami Hiramatsuef4a3562010-04-21 15:56:40 -040037 int ntevs; /* Number of trace events */
38 int max_tevs; /* Max number of trace events */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040039
40 /* For function searching */
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030041 int lno; /* Line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050042 Dwarf_Addr addr; /* Address */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040043 const char *fname; /* Real file name */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050044 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040045 struct list_head lcache; /* Line cache for lazy match */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040046
47 /* For variable searching */
Masami Hiramatsu7752f1b2010-05-10 13:12:07 -040048#if _ELFUTILS_PREREQ(0, 142)
Masami Hiramatsua34a9852010-04-12 13:17:29 -040049 Dwarf_CFI *cfi; /* Call Frame Information */
Masami Hiramatsu7752f1b2010-05-10 13:12:07 -040050#endif
Masami Hiramatsu804b3602010-02-25 08:35:42 -050051 Dwarf_Op *fb_ops; /* Frame base attribute */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040052 struct perf_probe_arg *pvar; /* Current target variable */
53 struct kprobe_trace_arg *tvar; /* Current result variable */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040054};
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050055
56struct line_finder {
Masami Hiramatsu804b3602010-02-25 08:35:42 -050057 struct line_range *lr; /* Target line range */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050058
Masami Hiramatsu804b3602010-02-25 08:35:42 -050059 const char *fname; /* File name */
60 int lno_s; /* Start line number */
61 int lno_e; /* End line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050062 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050063 int found;
64};
65
Masami Hiramatsu4b4da7f2010-03-22 13:10:26 -030066#endif /* DWARF_SUPPORT */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040067
68#endif /*_PROBE_FINDER_H */