blob: 306810c32f6bdb2ae958ee9ac6d29eb53ada96a0 [file] [log] [blame]
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -04001#ifndef _PROBE_FINDER_H
2#define _PROBE_FINDER_H
3
4#define _stringify(n) #n
5#define stringify(n) _stringify(n)
6
7#ifdef DEBUG
8#define debug(fmt ...) \
9 fprintf(stderr, "DBG(" __FILE__ ":" stringify(__LINE__) "): " fmt)
10#else
11#define debug(fmt ...) do {} while (0)
12#endif
13
14#define ERR_IF(cnd) \
15 do { if (cnd) { \
16 fprintf(stderr, "Error (" __FILE__ ":" stringify(__LINE__) \
17 "): " stringify(cnd) "\n"); \
18 exit(1); \
19 } } while (0)
20
21#define MAX_PATH_LEN 256
22#define MAX_PROBE_BUFFER 1024
23#define MAX_PROBES 128
24
25static inline int is_c_varname(const char *name)
26{
27 /* TODO */
28 return isalpha(name[0]) || name[0] == '_';
29}
30
31struct probe_point {
32 /* Inputs */
33 char *file; /* File name */
34 int line; /* Line number */
35
36 char *function; /* Function name */
37 int offset; /* Offset bytes */
38
39 int nr_args; /* Number of arguments */
40 char **args; /* Arguments */
41
42 /* Output */
43 int found; /* Number of found probe points */
44 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
45};
46
Masami Hiramatsu23e8ec02009-10-07 18:28:30 -040047#ifndef NO_LIBDWARF
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040048extern int find_probepoint(int fd, struct probe_point *pp);
49
50#include <libdwarf/dwarf.h>
51#include <libdwarf/libdwarf.h>
52
53struct probe_finder {
54 struct probe_point *pp; /* Target probe point */
55
56 /* For function searching */
57 Dwarf_Addr addr; /* Address */
58 Dwarf_Unsigned fno; /* File number */
59 Dwarf_Off inl_offs; /* Inline offset */
60
61 /* For variable searching */
62 Dwarf_Addr cu_base; /* Current CU base address */
63 Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
64 const char *var; /* Current variable name */
65 char *buf; /* Current output buffer */
66 int len; /* Length of output buffer */
67};
Masami Hiramatsu23e8ec02009-10-07 18:28:30 -040068#endif /* NO_LIBDWARF */
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -040069
70#endif /*_PROBE_FINDER_H */