blob: 66f1980e3855477c86602485e43803b98b0032a8 [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 Hiramatsu4ea42b12009-10-08 17:17:38 -040032
33struct probe_finder {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040034 struct perf_probe_event *pev; /* Target probe event */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040035 struct kprobe_trace_event *tevs; /* Result trace events */
Masami Hiramatsuef4a3562010-04-21 15:56:40 -040036 int ntevs; /* Number of trace events */
37 int max_tevs; /* Max number of trace events */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040038
39 /* For function searching */
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030040 int lno; /* Line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050041 Dwarf_Addr addr; /* Address */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040042 const char *fname; /* Real file name */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050043 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040044 struct list_head lcache; /* Line cache for lazy match */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040045
46 /* For variable searching */
Masami Hiramatsua34a9852010-04-12 13:17:29 -040047 Dwarf_CFI *cfi; /* Call Frame Information */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050048 Dwarf_Op *fb_ops; /* Frame base attribute */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040049 struct perf_probe_arg *pvar; /* Current target variable */
50 struct kprobe_trace_arg *tvar; /* Current result variable */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040051};
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050052
53struct line_finder {
Masami Hiramatsu804b3602010-02-25 08:35:42 -050054 struct line_range *lr; /* Target line range */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050055
Masami Hiramatsu804b3602010-02-25 08:35:42 -050056 const char *fname; /* File name */
57 int lno_s; /* Start line number */
58 int lno_e; /* End line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050059 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050060 int found;
61};
62
Masami Hiramatsu4b4da7f2010-03-22 13:10:26 -030063#endif /* DWARF_SUPPORT */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040064
65#endif /*_PROBE_FINDER_H */