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