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 | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 24 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 25 | char *function; /* Function name */ |
| 26 | int offset; /* Offset bytes */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 27 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 28 | int nr_args; /* Number of arguments */ |
| 29 | char **args; /* Arguments */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 30 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 31 | int retprobe; /* Return probe */ |
Masami Hiramatsu | 253977b | 2009-10-27 16:43:10 -0400 | [diff] [blame] | 32 | |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 33 | /* Output */ |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 34 | int found; /* Number of found probe points */ |
| 35 | char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 36 | }; |
| 37 | |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 38 | /* Line number container */ |
| 39 | struct line_node { |
| 40 | struct list_head list; |
| 41 | unsigned int line; |
| 42 | }; |
| 43 | |
| 44 | /* Line range */ |
| 45 | struct line_range { |
| 46 | char *file; /* File name */ |
| 47 | char *function; /* Function name */ |
| 48 | unsigned int start; /* Start line number */ |
| 49 | unsigned int end; /* End line number */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame^] | 50 | int offset; /* Start line offset */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 51 | char *path; /* Real path name */ |
| 52 | struct list_head line_list; /* Visible lines */ |
| 53 | }; |
| 54 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame^] | 55 | #ifndef NO_DWARF_SUPPORT |
Masami Hiramatsu | 81cb8aa | 2010-02-25 08:35:34 -0500 | [diff] [blame] | 56 | extern int find_probe_point(int fd, struct probe_point *pp); |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 57 | extern int find_line_range(int fd, struct line_range *lr); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 58 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 59 | #include <dwarf.h> |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame^] | 60 | #include <libdw.h> |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 61 | |
| 62 | struct probe_finder { |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame^] | 63 | struct probe_point *pp; /* Target probe point */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 64 | |
| 65 | /* For function searching */ |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame^] | 66 | Dwarf_Addr addr; /* Address */ |
| 67 | const char *fname; /* File name */ |
| 68 | int lno; /* Line number */ |
| 69 | void *origin; /* Inline origin addr */ |
| 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 */ |
| 74 | Dwarf_Addr cu_base; /* Current CU base address */ |
| 75 | const char *var; /* Current variable name */ |
| 76 | char *buf; /* Current output buffer */ |
| 77 | int len; /* Length of output buffer */ |
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 */ |
| 86 | Dwarf_Addr addr_s; /* Start address */ |
| 87 | Dwarf_Addr addr_e; /* End address */ |
| 88 | Dwarf_Die cu_die; /* Current CU */ |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame] | 89 | int found; |
| 90 | }; |
| 91 | |
Masami Hiramatsu | 804b360 | 2010-02-25 08:35:42 -0500 | [diff] [blame^] | 92 | #endif /* NO_DWARF_SUPPORT */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 93 | |
| 94 | #endif /*_PROBE_FINDER_H */ |