]>
Commit | Line | Data |
---|---|---|
7a053d3b | 1 | #include <elfutils/libdw.h> |
77de5e9e GH |
2 | |
3 | struct obstack; /* Use <obstack.h> */ | |
4 | struct location; /* Opaque */ | |
5 | ||
112b531a FCE |
6 | /* G++ 3.3 doesn't seem to like the __attribute__ constructs below. */ |
7 | #if (__GNUG__ == 3) && (__GNUC_MINOR__ == 3) | |
8 | #define __attribute__(x) /* nothing */ | |
9 | #endif | |
77de5e9e GH |
10 | |
11 | /* Translate a C fragment for the location expression, using *INPUT | |
12 | as the starting location, begin from scratch if *INPUT is null. | |
13 | If DW_OP_fbreg is used, it may have a subfragment computing from | |
00b01a99 | 14 | the FB_ATTR location expression. The call_frame might need to be |
24c7957b MW |
15 | calculated by the cfa_ops for the given pc_address. If known the |
16 | locattr provides the attribute from which the locexpr array was | |
17 | retrieved. | |
77de5e9e | 18 | |
ccc358b1 RM |
19 | On errors, call FAIL, which should not return. Any later errors will use |
20 | FAIL and FAIL_ARG from the first c_translate_location call. | |
21 | ||
22 | On success, return the first fragment created, which is also chained | |
23 | onto (*INPUT)->next. *INPUT is then updated with the new tail of that | |
b075db48 | 24 | chain. */ |
ccc358b1 RM |
25 | struct location *c_translate_location (struct obstack *, |
26 | void (*fail) (void *arg, | |
27 | const char *fmt, ...) | |
28 | __attribute__ ((noreturn, | |
29 | format (printf, 2, 3))), | |
30 | void *fail_arg, | |
4b1ad75e RM |
31 | void (*emit_address) (void *fail_arg, |
32 | struct obstack *, | |
33 | Dwarf_Addr), | |
ccc358b1 | 34 | int indent, |
77de5e9e | 35 | Dwarf_Addr bias, |
d1531387 | 36 | Dwarf_Addr pc_address, |
24c7957b | 37 | Dwarf_Attribute *attr, |
d1531387 RM |
38 | const Dwarf_Op *locexpr, |
39 | size_t locexprlen, | |
77de5e9e | 40 | struct location **input, |
00b01a99 MW |
41 | Dwarf_Attribute *fb_attr, |
42 | const Dwarf_Op *cfa_ops); | |
77de5e9e | 43 | |
2e2a5d82 RM |
44 | /* Translate a fragment for a compile-time constant from DW_AT_const_value. |
45 | */ | |
46 | struct location *c_translate_constant (struct obstack *, | |
47 | void (*fail) (void *arg, | |
48 | const char *fmt, ...) | |
49 | __attribute__ ((noreturn, | |
50 | format (printf, 2, 3))), | |
51 | void *fail_arg, | |
52 | void (*emit_address) (void *fail_arg, | |
53 | struct obstack *, | |
54 | Dwarf_Addr), | |
55 | int indent, Dwarf_Addr dwbias, | |
56 | Dwarf_Attribute *attr); | |
57 | ||
d50f5149 | 58 | /* Translate a fragment to dereference the given DW_TAG_pointer_type DIE, |
77de5e9e GH |
59 | where *INPUT is the location of the pointer with that type. */ |
60 | void c_translate_pointer (struct obstack *pool, int indent, | |
61 | Dwarf_Addr dwbias, Dwarf_Die *typedie, | |
62 | struct location **input); | |
63 | ||
d50f5149 | 64 | /* Translate a fragment to index a DW_TAG_array_type DIE (turning the location |
77de5e9e GH |
65 | of the array into the location of an element). If IDX is non-null, |
66 | it's a string of C code to emit in the fragment as the array index. | |
67 | If the index is a known constant, IDX should be null and CONST_IDX | |
68 | is used instead (this case can handle local arrays in registers). */ | |
69 | void c_translate_array (struct obstack *pool, int indent, | |
70 | Dwarf_Addr dwbias, Dwarf_Die *typedie, | |
71 | struct location **input, | |
72 | const char *idx, Dwarf_Word const_idx); | |
73 | ||
f3b5366d JS |
74 | /* Translate a pointer as if it were an array, for cases where we have an |
75 | address and pointee type DIE, but perhaps don't have a pointer DIE. */ | |
76 | void c_translate_array_pointer (struct obstack *pool, int indent, | |
77 | Dwarf_Die *typedie, struct location **input, | |
78 | const char *idx, Dwarf_Word const_idx); | |
79 | ||
77de5e9e GH |
80 | /* Translate a fragment to compute the address of the input location |
81 | and assign it to the variable TARGET. This doesn't really do anything | |
82 | (it always emits "TARGET = addr;"), but it will barf if the location | |
83 | is a register or noncontiguous object. */ | |
84 | void c_translate_addressof (struct obstack *pool, int indent, | |
85 | Dwarf_Addr dwbias, Dwarf_Die *die, | |
f0df19a2 | 86 | Dwarf_Die *typedie, |
77de5e9e GH |
87 | struct location **input, const char *target); |
88 | ||
89 | /* Translate a fragment to fetch the value of variable or member DIE | |
2413637c | 90 | at the *INPUT location and store it in lvalue TARGET. |
d50f5149 | 91 | This handles base integer types and bit fields, i.e. DW_TAG_base_type. */ |
77de5e9e GH |
92 | void c_translate_fetch (struct obstack *pool, int indent, |
93 | Dwarf_Addr dwbias __attribute__ ((unused)), | |
d50f5149 | 94 | Dwarf_Die *die, Dwarf_Die *typedie, |
77de5e9e GH |
95 | struct location **input, const char *target); |
96 | ||
2413637c RM |
97 | /* Translate a fragment to locate the value of variable or member DIE |
98 | at the *INPUT location and set it to the C expression RVALUE. | |
d50f5149 | 99 | This handles base integer types and bit fields, i.e. DW_TAG_base_type. */ |
2413637c RM |
100 | void c_translate_store (struct obstack *pool, int indent, |
101 | Dwarf_Addr dwbias __attribute__ ((unused)), | |
d50f5149 | 102 | Dwarf_Die *die, Dwarf_Die *typedie, |
2413637c RM |
103 | struct location **input, const char *rvalue); |
104 | ||
b0be9bdb FCE |
105 | /* Translate a fragment to write the given pointer value, |
106 | where *INPUT is the location of the pointer with that type. */ | |
107 | void | |
108 | c_translate_pointer_store (struct obstack *pool, int indent, | |
109 | Dwarf_Addr dwbias __attribute__ ((unused)), | |
110 | Dwarf_Die *typedie, struct location **input, | |
111 | const char *rvalue); | |
112 | ||
c4ce66a1 JS |
113 | /* Translate a C fragment for a direct argument VALUE. On errors, call FAIL, |
114 | which should not return. Any later errors will use FAIL and FAIL_ARG from | |
115 | this translate call. On success, return the fragment created. */ | |
116 | struct location *c_translate_argument (struct obstack *, | |
117 | void (*fail) (void *arg, | |
118 | const char *fmt, ...) | |
119 | __attribute__ ((noreturn, | |
120 | format (printf, 2, 3))), | |
121 | void *fail_arg, | |
122 | void (*emit_address) (void *fail_arg, | |
123 | struct obstack *, | |
124 | Dwarf_Addr), | |
125 | int indent, const char *value); | |
126 | ||
127 | ||
b0be9bdb | 128 | |
77de5e9e GH |
129 | /* Emit the C fragment built up at LOC (i.e., the return value from the |
130 | first c_translate_location call made). INDENT should match that | |
131 | passed to c_translate_* previously. | |
132 | ||
133 | Writes complete lines of C99, code forming a complete C block, to STREAM. | |
134 | Return value is true iff that code uses the `deref' runtime macros. */ | |
85dfc5c8 RM |
135 | bool c_emit_location (FILE *stream, struct location *loc, int indent, |
136 | unsigned int *max_stack); | |
73267b89 JS |
137 | |
138 | /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ |