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" |
| 6 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 7 | #define MAX_PATH_LEN 256 |
| 8 | #define MAX_PROBE_BUFFER 1024 |
| 9 | #define MAX_PROBES 128 |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 10 | |
| 11 | static inline int is_c_varname(const char *name) |
| 12 | { |
| 13 | /* TODO */ |
| 14 | return isalpha(name[0]) || name[0] == '_'; |
| 15 | } |
| 16 | |
| 17 | struct probe_point { |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 18 | char *event; /* Event name */ |
| 19 | char *group; /* Event group */ |
Masami Hiramatsu | af663d7 | 2009-12-15 10:32:18 -0500 | [diff] [blame] | 20 | |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 21 | /* Inputs */ |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 22 | char *file; /* File name */ |
| 23 | int line; /* Line number */ |
Masami Hiramatsu | 2a9c8c3 | 2010-02-25 08:36:12 -0500 | [diff] [blame] | 24 | char *lazy_line; /* Lazy line pattern */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 25 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 26 | char *function; /* Function name */ |
| 27 | int offset; /* Offset bytes */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 28 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 29 | int nr_args; /* Number of arguments */ |
| 30 | char **args; /* Arguments */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 31 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 32 | int retprobe; /* Return probe */ |
Masami Hiramatsu | 253977b | 2009-10-27 16:43:10 -0400 | [diff] [blame] | 33 | |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 34 | /* Output */ |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 35 | int found; /* Number of found probe points */ |
| 36 | char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 37 | }; |
| 38 | |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 39 | /* Line number container */ |
| 40 | struct line_node { |
| 41 | struct list_head list; |
| 42 | unsigned int line; |
| 43 | }; |
| 44 | |
| 45 | /* Line range */ |
| 46 | struct line_range { |
| 47 | char *file; /* File name */ |
| 48 | char *function; /* Function name */ |
| 49 | unsigned int start; /* Start line number */ |
| 50 | unsigned int end; /* End line number */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 51 | int offset; /* Start line offset */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 52 | char *path; /* Real path name */ |
| 53 | struct list_head line_list; /* Visible lines */ |
| 54 | }; |
| 55 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 56 | #ifndef NO_DWARF_SUPPORT |
Masami Hiramatsu | 81cb8aa | 2010-02-25 08:35:34 -0500 | [diff] [blame] | 57 | extern int find_probe_point(int fd, struct probe_point *pp); |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 58 | extern int find_line_range(int fd, struct line_range *lr); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 59 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 60 | #include <dwarf.h> |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 61 | #include <libdw.h> |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 62 | |
| 63 | struct probe_finder { |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 64 | struct probe_point *pp; /* Target probe point */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 65 | |
| 66 | /* For function searching */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 67 | Dwarf_Addr addr; /* Address */ |
| 68 | const char *fname; /* File name */ |
| 69 | int lno; /* Line number */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 70 | Dwarf_Die cu_die; /* Current CU */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 71 | |
| 72 | /* For variable searching */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 73 | Dwarf_Op *fb_ops; /* Frame base attribute */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 74 | const char *var; /* Current variable name */ |
| 75 | char *buf; /* Current output buffer */ |
| 76 | int len; /* Length of output buffer */ |
Masami Hiramatsu | 2a9c8c3 | 2010-02-25 08:36:12 -0500 | [diff] [blame] | 77 | struct list_head lcache; /* Line cache for lazy match */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 78 | }; |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 79 | |
| 80 | struct line_finder { |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 81 | struct line_range *lr; /* Target line range */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 82 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 83 | const char *fname; /* File name */ |
| 84 | int lno_s; /* Start line number */ |
| 85 | int lno_e; /* End line number */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 86 | Dwarf_Die cu_die; /* Current CU */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 87 | int found; |
| 88 | }; |
| 89 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame] | 90 | #endif /* NO_DWARF_SUPPORT */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 91 | |
| 92 | #endif /*_PROBE_FINDER_H */ |