Return unique_xmalloc_ptr from call_site_find_chain
[deliverable/binutils-gdb.git] / gdb / dwarf2 / loc.h
CommitLineData
852483bc
MK
1/* DWARF 2 location expression support for GDB.
2
b811d2c2 3 Copyright (C) 2003-2020 Free Software Foundation, Inc.
4c2df51b
DJ
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
4c2df51b
DJ
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
4c2df51b
DJ
19
20#if !defined (DWARF2LOC_H)
21#define DWARF2LOC_H
22
82ca8957 23#include "dwarf2/expr.h"
b64f50a1 24
768a979c 25struct symbol_computed_ops;
ae0d2f24
UW
26struct objfile;
27struct dwarf2_per_cu_data;
8cf6f0b1 28struct dwarf2_loclist_baton;
9f6f94ff
TT
29struct agent_expr;
30struct axs_value;
a67af2b9 31
4c2df51b
DJ
32/* This header is private to the DWARF-2 reader. It is shared between
33 dwarf2read.c and dwarf2loc.c. */
34
8e3b41a9 35/* `set debug entry-values' setting. */
ccce17b0 36extern unsigned int entry_values_debug;
8e3b41a9 37
8cf6f0b1
TT
38/* Find a particular location expression from a location list. */
39const gdb_byte *dwarf2_find_location_expression
40 (struct dwarf2_loclist_baton *baton,
41 size_t *locexpr_length,
42 CORE_ADDR pc);
43
8b9737bf
TT
44struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_sect_off
45 (sect_offset offset_in_cu, struct dwarf2_per_cu_data *per_cu,
46 CORE_ADDR (*get_frame_pc) (void *baton),
e4a62c65 47 void *baton, bool resolve_abstract_p = false);
8b9737bf
TT
48
49struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_cu_off
b64f50a1 50 (cu_offset offset_in_cu, struct dwarf2_per_cu_data *per_cu,
8cf6f0b1
TT
51 CORE_ADDR (*get_frame_pc) (void *baton),
52 void *baton);
5c631832 53
b6807d98
TT
54extern const gdb_byte *dwarf2_fetch_constant_bytes (sect_offset,
55 struct dwarf2_per_cu_data *,
56 struct obstack *,
57 LONGEST *);
58
7942e96e
AA
59struct type *dwarf2_fetch_die_type_sect_off (sect_offset,
60 struct dwarf2_per_cu_data *);
61
b64f50a1 62struct type *dwarf2_get_die_type (cu_offset die_offset,
8a9b8146
TT
63 struct dwarf2_per_cu_data *per_cu);
64
af945b75
TT
65/* Find the frame base information for FRAMEFUNC at PC. START is an
66 out parameter which is set to point to the DWARF expression to
67 compute. LENGTH is an out parameter which is set to the length of
68 the DWARF expression. This throws an exception on error or if an
69 expression is not found; the returned length will never be
70 zero. */
71
72extern void func_get_frame_base_dwarf_block (struct symbol *framefunc,
73 CORE_ADDR pc,
74 const gdb_byte **start,
75 size_t *length);
76
98bfdba5
PA
77/* Evaluate a location description, starting at DATA and with length
78 SIZE, to find the current location of variable of TYPE in the context
79 of FRAME. */
80
81struct value *dwarf2_evaluate_loc_desc (struct type *type,
82 struct frame_info *frame,
83 const gdb_byte *data,
56eb65bd 84 size_t size,
98bfdba5
PA
85 struct dwarf2_per_cu_data *per_cu);
86
df25ebbd
JB
87/* A chain of addresses that might be needed to resolve a dynamic
88 property. */
89
90struct property_addr_info
91{
92 /* The type of the object whose dynamic properties, if any, are
93 being resolved. */
94 struct type *type;
95
c3345124
JB
96 /* If not NULL, a buffer containing the object's value. */
97 const gdb_byte *valaddr;
98
df25ebbd
JB
99 /* The address of that object. */
100 CORE_ADDR addr;
101
102 /* If not NULL, a pointer to the info for the object containing
103 the object described by this node. */
104 struct property_addr_info *next;
105};
106
63e43d3a
PMR
107/* Converts a dynamic property into a static one. FRAME is the frame in which
108 the property is evaluated; if NULL, the selected frame (if any) is used
109 instead.
110
111 ADDR_STACK is the stack of addresses that might be needed to evaluate the
112 property. When evaluating a property that is not related to a type, it can
113 be NULL.
114
603490bf
AB
115 Returns true if PROP could be converted and the static value is passed
116 back into VALUE, otherwise returns false. */
80180f79 117
603490bf
AB
118bool dwarf2_evaluate_property (const struct dynamic_prop *prop,
119 struct frame_info *frame,
120 struct property_addr_info *addr_stack,
121 CORE_ADDR *value);
80180f79 122
bb2ec1b3
TT
123/* A helper for the compiler interface that compiles a single dynamic
124 property to C code.
125
126 STREAM is where the C code is to be written.
127 RESULT_NAME is the name of the generated variable.
128 GDBARCH is the architecture to use.
129 REGISTERS_USED is a bit-vector that is filled to note which
130 registers are required by the generated expression.
131 PROP is the property for which code is generated.
132 ADDRESS is the address at which the property is considered to be
133 evaluated.
134 SYM the originating symbol, used for error reporting. */
135
d82b3862 136void dwarf2_compile_property_to_c (string_file *stream,
bb2ec1b3
TT
137 const char *result_name,
138 struct gdbarch *gdbarch,
139 unsigned char *registers_used,
140 const struct dynamic_prop *prop,
141 CORE_ADDR address,
142 struct symbol *sym);
143
3019eac3
DE
144CORE_ADDR dwarf2_read_addr_index (struct dwarf2_per_cu_data *per_cu,
145 unsigned int addr_index);
146
0d53c4c4
DJ
147/* The symbol location baton types used by the DWARF-2 reader (i.e.
148 SYMBOL_LOCATION_BATON for a LOC_COMPUTED symbol). "struct
149 dwarf2_locexpr_baton" is for a symbol with a single location
150 expression; "struct dwarf2_loclist_baton" is for a symbol with a
151 location list. */
4c2df51b
DJ
152
153struct dwarf2_locexpr_baton
154{
1d6edc3c
JK
155 /* Pointer to the start of the location expression. Valid only if SIZE is
156 not zero. */
947bb88f 157 const gdb_byte *data;
0d53c4c4 158
1d6edc3c
JK
159 /* Length of the location expression. For optimized out expressions it is
160 zero. */
56eb65bd 161 size_t size;
0d53c4c4 162
9a49df9d
AB
163 /* When true this location expression is a reference and actually
164 describes the address at which the value of the attribute can be
165 found. When false the expression provides the value of the attribute
166 directly. */
167 bool is_reference;
168
ae0d2f24
UW
169 /* The compilation unit containing the symbol whose location
170 we're computing. */
171 struct dwarf2_per_cu_data *per_cu;
0d53c4c4
DJ
172};
173
174struct dwarf2_loclist_baton
175{
176 /* The initial base address for the location list, based on the compilation
177 unit. */
178 CORE_ADDR base_address;
179
180 /* Pointer to the start of the location list. */
947bb88f 181 const gdb_byte *data;
0d53c4c4
DJ
182
183 /* Length of the location list. */
56eb65bd 184 size_t size;
0d53c4c4 185
ae0d2f24
UW
186 /* The compilation unit containing the symbol whose location
187 we're computing. */
188 struct dwarf2_per_cu_data *per_cu;
f664829e
DE
189
190 /* Non-zero if the location list lives in .debug_loc.dwo.
191 The format of entries in this section are different. */
192 unsigned char from_dwo;
4c2df51b
DJ
193};
194
df25ebbd
JB
195/* The baton used when a dynamic property is an offset to a parent
196 type. This can be used, for instance, then the bound of an array
197 inside a record is determined by the value of another field inside
198 that record. */
199
200struct dwarf2_offset_baton
201{
202 /* The offset from the parent type where the value of the property
203 is stored. In the example provided above, this would be the offset
204 of the field being used as the array bound. */
205 LONGEST offset;
206
207 /* The type of the object whose property is dynamic. In the example
6471e7d2 208 provided above, this would the array's index type. */
df25ebbd
JB
209 struct type *type;
210};
211
80180f79
SA
212/* A dynamic property is either expressed as a single location expression
213 or a location list. If the property is an indirection, pointing to
9a49df9d
AB
214 another die, keep track of the targeted type in PROPERTY_TYPE.
215 Alternatively, if the property location gives the property value
216 directly then it will have PROPERTY_TYPE. */
80180f79
SA
217
218struct dwarf2_property_baton
219{
220 /* If the property is an indirection, we need to evaluate the location
9a49df9d
AB
221 in the context of the type PROPERTY_TYPE. If the property is supplied
222 by value then it will be of PROPERTY_TYPE. This field should never be
223 NULL. */
224 struct type *property_type;
80180f79
SA
225 union
226 {
9a49df9d
AB
227 /* Location expression either evaluated in the context of
228 PROPERTY_TYPE, or a value of type PROPERTY_TYPE. */
80180f79
SA
229 struct dwarf2_locexpr_baton locexpr;
230
9a49df9d 231 /* Location list to be evaluated in the context of PROPERTY_TYPE. */
80180f79 232 struct dwarf2_loclist_baton loclist;
df25ebbd 233
9a49df9d 234 /* The location is an offset to PROPERTY_TYPE. */
df25ebbd 235 struct dwarf2_offset_baton offset_info;
80180f79
SA
236 };
237};
238
768a979c
UW
239extern const struct symbol_computed_ops dwarf2_locexpr_funcs;
240extern const struct symbol_computed_ops dwarf2_loclist_funcs;
4c2df51b 241
f1e6e072
TT
242extern const struct symbol_block_ops dwarf2_block_frame_base_locexpr_funcs;
243extern const struct symbol_block_ops dwarf2_block_frame_base_loclist_funcs;
244
9f6f94ff
TT
245/* Compile a DWARF location expression to an agent expression.
246
247 EXPR is the agent expression we are building.
248 LOC is the agent value we modify.
249 ARCH is the architecture.
250 ADDR_SIZE is the size of addresses, in bytes.
251 OP_PTR is the start of the location expression.
252 OP_END is one past the last byte of the location expression.
253
254 This will throw an exception for various kinds of errors -- for
255 example, if the expression cannot be compiled, or if the expression
256 is invalid. */
257
258extern void dwarf2_compile_expr_to_ax (struct agent_expr *expr,
259 struct axs_value *loc,
9f6f94ff
TT
260 unsigned int addr_size,
261 const gdb_byte *op_ptr,
262 const gdb_byte *op_end,
263 struct dwarf2_per_cu_data *per_cu);
264
111c6489
JK
265/* Determined tail calls for constructing virtual tail call frames. */
266
267struct call_site_chain
268 {
269 /* Initially CALLERS == CALLEES == LENGTH. For partially ambiguous result
270 CALLERS + CALLEES < LENGTH. */
271 int callers, callees, length;
272
273 /* Variably sized array with LENGTH elements. Later [0..CALLERS-1] contain
274 top (GDB "prev") sites and [LENGTH-CALLEES..LENGTH-1] contain bottom
275 (GDB "next") sites. One is interested primarily in the PC field. */
276 struct call_site *call_site[1];
277 };
278
279struct call_site_stuff;
8084e579
TT
280extern gdb::unique_xmalloc_ptr<call_site_chain> call_site_find_chain
281 (struct gdbarch *gdbarch, CORE_ADDR caller_pc, CORE_ADDR callee_pc);
111c6489 282
d064d1be
JK
283/* A helper function to convert a DWARF register to an arch register.
284 ARCH is the architecture.
285 DWARF_REG is the register.
0fde2c53
DE
286 If DWARF_REG is bad then a complaint is issued and -1 is returned.
287 Note: Some targets get this wrong. */
d064d1be 288
0fde2c53
DE
289extern int dwarf_reg_to_regnum (struct gdbarch *arch, int dwarf_reg);
290
291/* A wrapper on dwarf_reg_to_regnum to throw an exception if the
292 DWARF register cannot be translated to an architecture register.
293 This takes a ULONGEST instead of an int because some callers actually have
294 a ULONGEST. Negative values passed as ints will still be flagged as
295 invalid. */
296
297extern int dwarf_reg_to_regnum_or_error (struct gdbarch *arch,
298 ULONGEST dwarf_reg);
d064d1be 299
852483bc 300#endif /* dwarf2loc.h */
This page took 1.322475 seconds and 4 git commands to generate.