]>
Commit | Line | Data |
---|---|---|
0dbac951 RH |
1 | #ifndef LOC2STAP_H |
2 | #define LOC2STAP_H 1 | |
3 | ||
4 | #include "staptree.h" | |
5 | #include <elfutils/libdw.h> | |
6 | ||
7 | enum location_type | |
8 | { | |
9 | loc_address, loc_register, loc_noncontiguous, loc_unavailable, | |
10 | loc_value, loc_constant, loc_implicit_pointer, | |
11 | loc_decl, loc_fragment, loc_final | |
12 | }; | |
13 | ||
14 | struct location | |
15 | { | |
16 | location_type type; | |
17 | unsigned byte_size; | |
18 | ||
19 | // loc_address, loc_value, loc_fragment, loc_final | |
20 | expression *program; | |
21 | ||
22 | // loc_register | |
23 | unsigned int regno; | |
24 | ||
25 | // loc_noncontiguous | |
26 | location *pieces; | |
27 | location *piece_next; | |
28 | ||
29 | // loc_constant | |
30 | const void *constant_block; | |
31 | ||
32 | // loc_implicit_pointer | |
33 | location *target; | |
34 | ||
35 | // loc_register, loc_implicit_pointer | |
36 | Dwarf_Word offset; | |
37 | ||
38 | location(location_type t = loc_unavailable) | |
39 | : type(t), byte_size(0), program(0), regno(0), pieces(0), | |
40 | piece_next(0), constant_block(0), target(0), offset(0) | |
41 | { } | |
42 | }; | |
43 | ||
a5a7bca4 | 44 | class dwflpp; |
0dbac951 RH |
45 | class location_context |
46 | { | |
47 | public: | |
5552db3a FCE |
48 | const target_symbol *e_orig; // unmodified original |
49 | target_symbol *e; // deep-copied + rewritten, for use within synthetic _dwarf_tvar* function body | |
50 | ||
0dbac951 RH |
51 | // These three form the argument list to the function, in sequence. |
52 | // They will be referenced by the expression(s) computing the location. | |
53 | vardecl *pointer; | |
54 | std::vector<vardecl *> indicies; | |
55 | vardecl *value; | |
56 | ||
57 | Dwarf_Attribute *attr; | |
58 | Dwarf_Addr dwbias; | |
59 | Dwarf_Addr pc; | |
60 | Dwarf_Attribute *fb_attr; | |
61 | const Dwarf_Op *cfa_ops; | |
a5a7bca4 | 62 | dwflpp *dw; |
0dbac951 RH |
63 | |
64 | // Temporaries required while computing EVALS and LOCATIONS. | |
65 | symbol *frame_base; | |
66 | std::vector<vardecl *> locals; | |
9da6c217 | 67 | std::vector<statement *> evals; |
0dbac951 | 68 | |
b3627d9a JU |
69 | std::vector<vardecl *> globals; |
70 | std::map<Dwarf_Addr, block *> entry_probes; | |
68bd23fd | 71 | |
9da6c217 JU |
72 | Dwarf_Die *function; |
73 | Dwarf_Die *parameter_ref; | |
74 | std::vector<location_context> call_site_values; | |
75 | int param_ref_depth; | |
76 | ||
0dbac951 RH |
77 | // A set of locations which have been requested to be evaluated. |
78 | // The last one can be considered "current", and thus the result | |
79 | // is locations.back()->program. | |
80 | // ??? This is the old loc->next list. Should we just have a | |
81 | // single pointer here instead? | |
82 | std::vector<location *> locations; // ??? old loc->next list | |
83 | ||
84 | // The dwarf is within a user (vs kernel) context. | |
85 | bool userspace_p; | |
86 | ||
87 | location *new_location(location_type); | |
88 | location *new_location(const location &old); | |
89 | ||
90 | symbol *new_symref(vardecl *var); | |
91 | symbol *new_local(const char *namebase); | |
92 | expression *new_target_reg(unsigned regno); | |
ae0c91ce | 93 | expression *new_plus_const(expression *, int64_t); |
0dbac951 RH |
94 | expression *save_expression(expression *); |
95 | symbol *frame_location(); | |
16b2359a | 96 | void adapt_pointer_to_bpf(int size, int offset, bool is_signed); |
b3627d9a | 97 | expression *handle_GNU_entry_value(Dwarf_Op expr); |
9da6c217 | 98 | expression *handle_GNU_parameter_ref(Dwarf_Op expr); |
0dbac951 RH |
99 | |
100 | location *translate(const Dwarf_Op *expr, size_t len, size_t start, | |
101 | location *input, bool may_use_fb, bool computing_value); | |
102 | location *location_from_address (const Dwarf_Op *expr, size_t len, | |
103 | location *input); | |
104 | location *translate_offset (const Dwarf_Op *expr, size_t len, size_t i, | |
105 | location *input, Dwarf_Word offset); | |
106 | location *location_relative (const Dwarf_Op *expr, size_t len, | |
107 | location *input); | |
108 | location *translate_array_1(Dwarf_Die *anydie, Dwarf_Word stride, | |
109 | location *loc, expression *index); | |
110 | ||
111 | public: | |
112 | location_context(target_symbol *, expression * = NULL); | |
113 | ||
a5a7bca4 | 114 | expression *translate_address(Dwarf_Addr a); |
0dbac951 RH |
115 | location *translate_constant(Dwarf_Attribute *a); |
116 | location *translate_location(const Dwarf_Op *locexpr, | |
117 | size_t locexprlen, location *input); | |
118 | location *translate_argument (expression *value); | |
119 | location *translate_argument (vardecl *var); | |
120 | location *translate_array(Dwarf_Die *typedie, location *, expression *); | |
121 | location *translate_array_pointer(Dwarf_Die *typedie, location *input, | |
122 | expression *index); | |
123 | location *translate_array_pointer (Dwarf_Die *, location *input, | |
124 | vardecl *index); | |
125 | location *discontiguify(location *loc, Dwarf_Word total_bytes, | |
126 | Dwarf_Word max_piece_bytes); | |
127 | ||
128 | }; | |
129 | ||
130 | #endif |