Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 1 | #ifndef _PROBE_FINDER_H |
| 2 | #define _PROBE_FINDER_H |
| 3 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 4 | #include <stdbool.h> |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 5 | #include "util.h" |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame^] | 6 | #include "probe-event.h" |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 7 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 8 | #define MAX_PATH_LEN 256 |
| 9 | #define MAX_PROBE_BUFFER 1024 |
| 10 | #define MAX_PROBES 128 |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 11 | |
| 12 | static inline int is_c_varname(const char *name) |
| 13 | { |
| 14 | /* TODO */ |
| 15 | return isalpha(name[0]) || name[0] == '_'; |
| 16 | } |
| 17 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 18 | #ifndef NO_DWARF_SUPPORT |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame^] | 19 | /* Find kprobe_trace_events specified by perf_probe_event from debuginfo */ |
| 20 | extern int find_kprobe_trace_events(int fd, struct perf_probe_event *pev, |
| 21 | struct kprobe_trace_event **tevs); |
| 22 | |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 23 | extern int find_line_range(int fd, struct line_range *lr); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 24 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 25 | #include <dwarf.h> |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 26 | #include <libdw.h> |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 27 | |
| 28 | struct probe_finder { |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame^] | 29 | 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 Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 32 | |
| 33 | /* For function searching */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 34 | Dwarf_Addr addr; /* Address */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame^] | 35 | const char *fname; /* Real file name */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 36 | int lno; /* Line number */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 37 | Dwarf_Die cu_die; /* Current CU */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame^] | 38 | struct list_head lcache; /* Line cache for lazy match */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 39 | |
| 40 | /* For variable searching */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 41 | Dwarf_Op *fb_ops; /* Frame base attribute */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame^] | 42 | struct perf_probe_arg *pvar; /* Current target variable */ |
| 43 | struct kprobe_trace_arg *tvar; /* Current result variable */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 44 | }; |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 45 | |
| 46 | struct line_finder { |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 47 | struct line_range *lr; /* Target line range */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 48 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 49 | const char *fname; /* File name */ |
| 50 | int lno_s; /* Start line number */ |
| 51 | int lno_e; /* End line number */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 52 | Dwarf_Die cu_die; /* Current CU */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 53 | int found; |
| 54 | }; |
| 55 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 56 | #endif /* NO_DWARF_SUPPORT */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 57 | |
| 58 | #endif /*_PROBE_FINDER_H */ |