blob: 494952619b9c892b483806a3ce49f22b9f933945 [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 Hiramatsu804b3602010-02-25 08:35:42 -050018#ifndef NO_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,
21 struct kprobe_trace_event **tevs);
22
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050023extern int find_line_range(int fd, struct line_range *lr);
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040024
Masami Hiramatsu27f3b242009-12-16 17:16:19 -050025#include <dwarf.h>
Masami Hiramatsu804b3602010-02-25 08:35:42 -050026#include <libdw.h>
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040027
28struct probe_finder {
Masami Hiramatsu4235b042010-03-16 18:06:12 -040029 struct perf_probe_event *pev; /* Target probe event */
30 int ntevs; /* number of trace events */
31 struct kprobe_trace_event *tevs; /* Result trace events */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040032
33 /* For function searching */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050034 Dwarf_Addr addr; /* Address */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040035 const char *fname; /* Real file name */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050036 int lno; /* Line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050037 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040038 struct list_head lcache; /* Line cache for lazy match */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040039
40 /* For variable searching */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050041 Dwarf_Op *fb_ops; /* Frame base attribute */
Masami Hiramatsu4235b042010-03-16 18:06:12 -040042 struct perf_probe_arg *pvar; /* Current target variable */
43 struct kprobe_trace_arg *tvar; /* Current result variable */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040044};
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050045
46struct line_finder {
Masami Hiramatsu804b3602010-02-25 08:35:42 -050047 struct line_range *lr; /* Target line range */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050048
Masami Hiramatsu804b3602010-02-25 08:35:42 -050049 const char *fname; /* File name */
50 int lno_s; /* Start line number */
51 int lno_e; /* End line number */
Masami Hiramatsu804b3602010-02-25 08:35:42 -050052 Dwarf_Die cu_die; /* Current CU */
Masami Hiramatsu631c9de2010-01-06 09:45:34 -050053 int found;
54};
55
Masami Hiramatsu804b3602010-02-25 08:35:42 -050056#endif /* NO_DWARF_SUPPORT */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040057
58#endif /*_PROBE_FINDER_H */