Commit | Line | Data |
---|---|---|
4ea42b18 MH |
1 | #ifndef _PROBE_FINDER_H |
2 | #define _PROBE_FINDER_H | |
3 | ||
4a58e611 ACM |
4 | #include "util.h" |
5 | ||
27f3b24d MH |
6 | #define MAX_PATH_LEN 256 |
7 | #define MAX_PROBE_BUFFER 1024 | |
8 | #define MAX_PROBES 128 | |
4ea42b18 MH |
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 { | |
27f3b24d MH |
17 | char *event; /* Event name */ |
18 | char *group; /* Event group */ | |
af663d75 | 19 | |
4ea42b18 | 20 | /* Inputs */ |
27f3b24d MH |
21 | char *file; /* File name */ |
22 | int line; /* Line number */ | |
4ea42b18 | 23 | |
27f3b24d MH |
24 | char *function; /* Function name */ |
25 | int offset; /* Offset bytes */ | |
4ea42b18 | 26 | |
27f3b24d MH |
27 | int nr_args; /* Number of arguments */ |
28 | char **args; /* Arguments */ | |
4ea42b18 | 29 | |
27f3b24d | 30 | int retprobe; /* Return probe */ |
253977b0 | 31 | |
4ea42b18 | 32 | /* Output */ |
27f3b24d MH |
33 | int found; /* Number of found probe points */ |
34 | char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/ | |
4ea42b18 MH |
35 | }; |
36 | ||
631c9def MH |
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 | ||
23e8ec0d | 54 | #ifndef NO_LIBDWARF |
4ea42b18 | 55 | extern int find_probepoint(int fd, struct probe_point *pp); |
631c9def | 56 | extern int find_line_range(int fd, struct line_range *lr); |
4ea42b18 | 57 | |
27f3b24d MH |
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> | |
4ea42b18 MH |
65 | |
66 | struct probe_finder { | |
27f3b24d | 67 | struct probe_point *pp; /* Target probe point */ |
4ea42b18 MH |
68 | |
69 | /* For function searching */ | |
27f3b24d MH |
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 */ | |
4ea42b18 MH |
75 | |
76 | /* For variable searching */ | |
27f3b24d MH |
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 */ | |
4ea42b18 | 82 | }; |
631c9def MH |
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 | ||
23e8ec0d | 96 | #endif /* NO_LIBDWARF */ |
4ea42b18 MH |
97 | |
98 | #endif /*_PROBE_FINDER_H */ |