aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-finder.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/probe-finder.h')
-rw-r--r--tools/perf/util/probe-finder.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
new file mode 100644
index 000000000000..af920de64866
--- /dev/null
+++ b/tools/perf/util/probe-finder.h
@@ -0,0 +1,68 @@
1#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
47extern int find_probepoint(int fd, struct probe_point *pp);
48
49#include <libdwarf/dwarf.h>
50#include <libdwarf/libdwarf.h>
51
52struct probe_finder {
53 struct probe_point *pp; /* Target probe point */
54
55 /* For function searching */
56 Dwarf_Addr addr; /* Address */
57 Dwarf_Unsigned fno; /* File number */
58 Dwarf_Off inl_offs; /* Inline offset */
59
60 /* For variable searching */
61 Dwarf_Addr cu_base; /* Current CU base address */
62 Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
63 const char *var; /* Current variable name */
64 char *buf; /* Current output buffer */
65 int len; /* Length of output buffer */
66};
67
68#endif /*_PROBE_FINDER_H */