perf probe: Support --line option to show probable source-code lines
[deliverable/linux.git] / tools / perf / util / probe-finder.h
1 #ifndef _PROBE_FINDER_H
2 #define _PROBE_FINDER_H
3
4 #include "util.h"
5
6 #define MAX_PATH_LEN 256
7 #define MAX_PROBE_BUFFER 1024
8 #define MAX_PROBES 128
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 {
17 char *event; /* Event name */
18 char *group; /* Event group */
19
20 /* Inputs */
21 char *file; /* File name */
22 int line; /* Line number */
23
24 char *function; /* Function name */
25 int offset; /* Offset bytes */
26
27 int nr_args; /* Number of arguments */
28 char **args; /* Arguments */
29
30 int retprobe; /* Return probe */
31
32 /* Output */
33 int found; /* Number of found probe points */
34 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
35 };
36
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
54 #ifndef NO_LIBDWARF
55 extern int find_probepoint(int fd, struct probe_point *pp);
56 extern int find_line_range(int fd, struct line_range *lr);
57
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>
65
66 struct probe_finder {
67 struct probe_point *pp; /* Target probe point */
68
69 /* For function searching */
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 */
75
76 /* For variable searching */
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 */
82 };
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
96 #endif /* NO_LIBDWARF */
97
98 #endif /*_PROBE_FINDER_H */
This page took 0.0336 seconds and 6 git commands to generate.