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 | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 37 | #ifndef NO_LIBDWARF |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 38 | extern int find_probepoint(int fd, struct probe_point *pp); |
| 39 | |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 40 | /* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */ |
| 41 | #ifndef _MIPS_SZLONG |
| 42 | # define _MIPS_SZLONG 0 |
| 43 | #endif |
| 44 | |
| 45 | #include <dwarf.h> |
| 46 | #include <libdwarf.h> |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 47 | |
| 48 | struct probe_finder { |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 49 | struct probe_point *pp; /* Target probe point */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 50 | |
| 51 | /* For function searching */ |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 52 | Dwarf_Addr addr; /* Address */ |
| 53 | Dwarf_Unsigned fno; /* File number */ |
| 54 | Dwarf_Unsigned lno; /* Line number */ |
| 55 | Dwarf_Off inl_offs; /* Inline offset */ |
| 56 | Dwarf_Die cu_die; /* Current CU */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 57 | |
| 58 | /* For variable searching */ |
Masami Hiramatsu | 27f3b24 | 2009-12-16 17:16:19 -0500 | [diff] [blame] | 59 | Dwarf_Addr cu_base; /* Current CU base address */ |
| 60 | Dwarf_Locdesc fbloc; /* Location of Current Frame Base */ |
| 61 | const char *var; /* Current variable name */ |
| 62 | char *buf; /* Current output buffer */ |
| 63 | int len; /* Length of output buffer */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 64 | }; |
Masami Hiramatsu | 23e8ec0 | 2009-10-07 18:28:30 -0400 | [diff] [blame] | 65 | #endif /* NO_LIBDWARF */ |
Masami Hiramatsu | 4ea42b1 | 2009-10-08 17:17:38 -0400 | [diff] [blame] | 66 | |
| 67 | #endif /*_PROBE_FINDER_H */ |