perf probe: Use libdw callback routines
[safe/jmp/linux-2.6] / tools / perf / util / probe-finder.h
1 #ifndef _PROBE_FINDER_H
2 #define _PROBE_FINDER_H
3
4 #include <stdbool.h>
5 #include "util.h"
6
7 #define MAX_PATH_LEN             256
8 #define MAX_PROBE_BUFFER        1024
9 #define MAX_PROBES               128
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 {
18         char                    *event;                 /* Event name */
19         char                    *group;                 /* Event group */
20
21         /* Inputs */
22         char                    *file;                  /* File name */
23         int                     line;                   /* Line number */
24
25         char                    *function;              /* Function name */
26         int                     offset;                 /* Offset bytes */
27
28         int                     nr_args;                /* Number of arguments */
29         char                    **args;                 /* Arguments */
30
31         int                     retprobe;               /* Return probe */
32
33         /* Output */
34         int                     found;                  /* Number of found probe points */
35         char                    *probes[MAX_PROBES];    /* Output buffers (will be allocated)*/
36 };
37
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 */
50         int                     offset;                 /* Start line offset */
51         char                    *path;                  /* Real path name */
52         struct list_head        line_list;              /* Visible lines */
53 };
54
55 #ifndef NO_DWARF_SUPPORT
56 extern int find_probe_point(int fd, struct probe_point *pp);
57 extern int find_line_range(int fd, struct line_range *lr);
58
59 #include <dwarf.h>
60 #include <libdw.h>
61
62 struct probe_finder {
63         struct probe_point      *pp;            /* Target probe point */
64
65         /* For function searching */
66         Dwarf_Addr              addr;           /* Address */
67         const char              *fname;         /* File name */
68         int                     lno;            /* Line number */
69         Dwarf_Die               cu_die;         /* Current CU */
70
71         /* For variable searching */
72         Dwarf_Op                *fb_ops;        /* Frame base attribute */
73         Dwarf_Addr              cu_base;        /* Current CU base address */
74         const char              *var;           /* Current variable name */
75         char                    *buf;           /* Current output buffer */
76         int                     len;            /* Length of output buffer */
77 };
78
79 struct line_finder {
80         struct line_range       *lr;            /* Target line range */
81
82         const char              *fname;         /* File name */
83         int                     lno_s;          /* Start line number */
84         int                     lno_e;          /* End line number */
85         Dwarf_Addr              addr_s;         /* Start address */
86         Dwarf_Addr              addr_e;         /* End address */
87         Dwarf_Die               cu_die;         /* Current CU */
88         int                     found;
89 };
90
91 #endif /* NO_DWARF_SUPPORT */
92
93 #endif /*_PROBE_FINDER_H */