Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 1 | #ifndef _PROBE_FINDER_H |
| 2 | #define _PROBE_FINDER_H |
| 3 | |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 4 | #include "util.h" |
| 5 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 6 | #define MAX_PATH_LEN 256 |
| 7 | #define MAX_PROBE_BUFFER 1024 |
| 8 | #define MAX_PROBES 128 |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 9 | |
| 10 | static inline int is_c_varname(const char *name) |
| 11 | { |
| 12 | /* TODO */ |
| 13 | return isalpha(name[0]) || name[0] == '_'; |
| 14 | } |
| 15 | |
| 16 | struct probe_point { |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 17 | char *event; /* Event name */ |
| 18 | char *group; /* Event group */ |
Masami Hiramatsu | af663d7 | 2009-12-15 10:32:18 -0500 | [diff] [blame] | 19 | |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 20 | /* Inputs */ |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 21 | char *file; /* File name */ |
| 22 | int line; /* Line number */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 23 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 24 | char *function; /* Function name */ |
| 25 | int offset; /* Offset bytes */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 26 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 27 | int nr_args; /* Number of arguments */ |
| 28 | char **args; /* Arguments */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 29 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 30 | int retprobe; /* Return probe */ |
Masami Hiramatsu | 253977b | 2009-10-27 16:43:10 -0400 | [diff] [blame] | 31 | |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 32 | /* Output */ |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 33 | int found; /* Number of found probe points */ |
| 34 | char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 35 | }; |
| 36 | |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame^] | 37 | /* Line number container */ |
| 38 | struct line_node { |
| 39 | struct list_head list; |
| 40 | unsigned int line; |
| 41 | }; |
| 42 | |
| 43 | /* Line range */ |
| 44 | struct line_range { |
| 45 | char *file; /* File name */ |
| 46 | char *function; /* Function name */ |
| 47 | unsigned int start; /* Start line number */ |
| 48 | unsigned int end; /* End line number */ |
| 49 | unsigned int offset; /* Start line offset */ |
| 50 | char *path; /* Real path name */ |
| 51 | struct list_head line_list; /* Visible lines */ |
| 52 | }; |
| 53 | |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 54 | #ifndef NO_LIBDWARF |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 55 | extern int find_probepoint(int fd, struct probe_point *pp); |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame^] | 56 | extern int find_line_range(int fd, struct line_range *lr); |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 57 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 58 | /* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */ |
| 59 | #ifndef _MIPS_SZLONG |
| 60 | # define _MIPS_SZLONG 0 |
| 61 | #endif |
| 62 | |
| 63 | #include <dwarf.h> |
| 64 | #include <libdwarf.h> |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 65 | |
| 66 | struct probe_finder { |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 67 | struct probe_point *pp; /* Target probe point */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 68 | |
| 69 | /* For function searching */ |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 70 | Dwarf_Addr addr; /* Address */ |
| 71 | Dwarf_Unsigned fno; /* File number */ |
| 72 | Dwarf_Unsigned lno; /* Line number */ |
| 73 | Dwarf_Off inl_offs; /* Inline offset */ |
| 74 | Dwarf_Die cu_die; /* Current CU */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 75 | |
| 76 | /* For variable searching */ |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 77 | Dwarf_Addr cu_base; /* Current CU base address */ |
| 78 | Dwarf_Locdesc fbloc; /* Location of Current Frame Base */ |
| 79 | const char *var; /* Current variable name */ |
| 80 | char *buf; /* Current output buffer */ |
| 81 | int len; /* Length of output buffer */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 82 | }; |
Masami Hiramatsu | 631c9de | 2010-01-06 09:45:34 -0500 | [diff] [blame^] | 83 | |
| 84 | struct line_finder { |
| 85 | struct line_range *lr; /* Target line range */ |
| 86 | |
| 87 | Dwarf_Unsigned fno; /* File number */ |
| 88 | Dwarf_Unsigned lno_s; /* Start line number */ |
| 89 | Dwarf_Unsigned lno_e; /* End line number */ |
| 90 | Dwarf_Addr addr_s; /* Start address */ |
| 91 | Dwarf_Addr addr_e; /* End address */ |
| 92 | Dwarf_Die cu_die; /* Current CU */ |
| 93 | int found; |
| 94 | }; |
| 95 | |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 96 | #endif /* NO_LIBDWARF */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 97 | |
| 98 | #endif /*_PROBE_FINDER_H */ |