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 | 4b4da7f | 2010-03-22 13:10:26 -0300 | [diff] [blame] | 18 | #ifdef DWARF_SUPPORT |
Srikar Dronamraju | 0e60836 | 2010-07-29 19:43:51 +0530 | [diff] [blame] | 19 | /* Find probe_trace_events specified by perf_probe_event from debuginfo */ |
| 20 | extern int find_probe_trace_events(int fd, struct perf_probe_event *pev, |
| 21 | struct probe_trace_event **tevs, |
Masami Hiramatsu | ef4a356 | 2010-04-21 15:56:40 -0400 | [diff] [blame] | 22 | int max_tevs); |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 23 | |
Masami Hiramatsu | fb1587d | 2010-03-16 18:06:19 -0400 | [diff] [blame] | 24 | /* Find a perf_probe_point from debuginfo */ |
Masami Hiramatsu | 469b9b8 | 2010-10-21 19:13:41 +0900 | [diff] [blame] | 25 | extern int find_perf_probe_point(unsigned long addr, |
Masami Hiramatsu | fb1587d | 2010-03-16 18:06:19 -0400 | [diff] [blame] | 26 | struct perf_probe_point *ppt); |
| 27 | |
Masami Hiramatsu | cf6eb48 | 2010-10-21 19:13:23 +0900 | [diff] [blame] | 28 | /* Find a line range */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 29 | extern int find_line_range(int fd, struct line_range *lr); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 30 | |
Masami Hiramatsu | cf6eb48 | 2010-10-21 19:13:23 +0900 | [diff] [blame] | 31 | /* Find available variables */ |
| 32 | extern int find_available_vars_at(int fd, struct perf_probe_event *pev, |
Masami Hiramatsu | fb8c5a5 | 2010-10-21 19:13:35 +0900 | [diff] [blame] | 33 | struct variable_list **vls, int max_points, |
| 34 | bool externs); |
Masami Hiramatsu | cf6eb48 | 2010-10-21 19:13:23 +0900 | [diff] [blame] | 35 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 36 | #include <dwarf.h> |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 37 | #include <libdw.h> |
Masami Hiramatsu | 469b9b8 | 2010-10-21 19:13:41 +0900 | [diff] [blame] | 38 | #include <libdwfl.h> |
Masami Hiramatsu | 7752f1b | 2010-05-10 13:12:07 -0400 | [diff] [blame] | 39 | #include <version.h> |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 40 | |
| 41 | struct probe_finder { |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 42 | struct perf_probe_event *pev; /* Target probe event */ |
Masami Hiramatsu | cf6eb48 | 2010-10-21 19:13:23 +0900 | [diff] [blame] | 43 | |
| 44 | /* Callback when a probe point is found */ |
| 45 | int (*callback)(Dwarf_Die *sp_die, struct probe_finder *pf); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 46 | |
| 47 | /* For function searching */ |
Arnaldo Carvalho de Melo | eed05fe | 2010-04-05 12:53:45 -0300 | [diff] [blame] | 48 | int lno; /* Line number */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 49 | Dwarf_Addr addr; /* Address */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 50 | const char *fname; /* Real file name */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 51 | Dwarf_Die cu_die; /* Current CU */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 52 | struct list_head lcache; /* Line cache for lazy match */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 53 | |
| 54 | /* For variable searching */ |
Masami Hiramatsu | 7752f1b | 2010-05-10 13:12:07 -0400 | [diff] [blame] | 55 | #if _ELFUTILS_PREREQ(0, 142) |
Masami Hiramatsu | a34a985 | 2010-04-12 13:17:29 -0400 | [diff] [blame] | 56 | Dwarf_CFI *cfi; /* Call Frame Information */ |
Masami Hiramatsu | 7752f1b | 2010-05-10 13:12:07 -0400 | [diff] [blame] | 57 | #endif |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 58 | Dwarf_Op *fb_ops; /* Frame base attribute */ |
Masami Hiramatsu | 4235b04 | 2010-03-16 18:06:12 -0400 | [diff] [blame] | 59 | struct perf_probe_arg *pvar; /* Current target variable */ |
Srikar Dronamraju | 0e60836 | 2010-07-29 19:43:51 +0530 | [diff] [blame] | 60 | struct probe_trace_arg *tvar; /* Current result variable */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 61 | }; |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 62 | |
Masami Hiramatsu | cf6eb48 | 2010-10-21 19:13:23 +0900 | [diff] [blame] | 63 | struct trace_event_finder { |
| 64 | struct probe_finder pf; |
| 65 | struct probe_trace_event *tevs; /* Found trace events */ |
| 66 | int ntevs; /* Number of trace events */ |
| 67 | int max_tevs; /* Max number of trace events */ |
| 68 | }; |
| 69 | |
| 70 | struct available_var_finder { |
| 71 | struct probe_finder pf; |
| 72 | struct variable_list *vls; /* Found variable lists */ |
| 73 | int nvls; /* Number of variable lists */ |
| 74 | int max_vls; /* Max no. of variable lists */ |
Masami Hiramatsu | fb8c5a5 | 2010-10-21 19:13:35 +0900 | [diff] [blame] | 75 | bool externs; /* Find external vars too */ |
| 76 | bool child; /* Search child scopes */ |
Masami Hiramatsu | cf6eb48 | 2010-10-21 19:13:23 +0900 | [diff] [blame] | 77 | }; |
| 78 | |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 79 | struct line_finder { |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 80 | struct line_range *lr; /* Target line range */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 81 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 82 | const char *fname; /* File name */ |
| 83 | int lno_s; /* Start line number */ |
| 84 | int lno_e; /* End line number */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 85 | Dwarf_Die cu_die; /* Current CU */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 86 | int found; |
| 87 | }; |
| 88 | |
Masami Hiramatsu | 4b4da7f | 2010-03-22 13:10:26 -0300 | [diff] [blame] | 89 | #endif /* DWARF_SUPPORT */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 90 | |
| 91 | #endif /*_PROBE_FINDER_H */ |