]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Definitions for values of C expressions, for GDB. |
dea7f9ba | 2 | |
213516ef | 3 | Copyright (C) 1986-2023 Free Software Foundation, Inc. |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
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 |
c5aa993b | 10 | (at your option) any later version. |
c906108c | 11 | |
c5aa993b JM |
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. | |
c906108c | 16 | |
c5aa993b | 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/>. */ |
c906108c SS |
19 | |
20 | #if !defined (VALUE_H) | |
21 | #define VALUE_H 1 | |
22 | ||
1df6926e | 23 | #include "frame.h" /* For struct frame_id. */ |
ba18742c | 24 | #include "extension.h" |
268a13a5 | 25 | #include "gdbsupport/gdb_ref_ptr.h" |
b49180ac | 26 | #include "gmp-utils.h" |
dea7f9ba MK |
27 | |
28 | struct block; | |
da3331ec | 29 | struct expression; |
dea7f9ba | 30 | struct regcache; |
da3331ec AC |
31 | struct symbol; |
32 | struct type; | |
dea7f9ba | 33 | struct ui_file; |
d8ca156b | 34 | struct language_defn; |
79a45b7d | 35 | struct value_print_options; |
d16aafd8 | 36 | |
9a0dc9e3 PA |
37 | /* Values can be partially 'optimized out' and/or 'unavailable'. |
38 | These are distinct states and have different string representations | |
39 | and related error strings. | |
40 | ||
41 | 'unavailable' has a specific meaning in this context. It means the | |
42 | value exists in the program (at the machine level), but GDB has no | |
43 | means to get to it. Such a value is normally printed as | |
44 | <unavailable>. Examples of how to end up with an unavailable value | |
45 | would be: | |
46 | ||
47 | - We're inspecting a traceframe, and the memory or registers the | |
48 | debug information says the value lives on haven't been collected. | |
49 | ||
50 | - We're inspecting a core dump, the memory or registers the debug | |
51 | information says the value lives aren't present in the dump | |
52 | (that is, we have a partial/trimmed core dump, or we don't fully | |
53 | understand/handle the core dump's format). | |
54 | ||
55 | - We're doing live debugging, but the debug API has no means to | |
56 | get at where the value lives in the machine, like e.g., ptrace | |
57 | not having access to some register or register set. | |
58 | ||
59 | - Any other similar scenario. | |
60 | ||
61 | OTOH, "optimized out" is about what the compiler decided to generate | |
62 | (or not generate). A chunk of a value that was optimized out does | |
63 | not actually exist in the program. There's no way to get at it | |
64 | short of compiling the program differently. | |
65 | ||
66 | A register that has not been saved in a frame is likewise considered | |
67 | optimized out, except not-saved registers have a different string | |
68 | representation and related error strings. E.g., we'll print them as | |
69 | <not-saved> instead of <optimized out>, as in: | |
70 | ||
71 | (gdb) p/x $rax | |
72 | $1 = <not saved> | |
73 | (gdb) info registers rax | |
74 | rax <not saved> | |
75 | ||
76 | If the debug info describes a variable as being in such a register, | |
77 | we'll still print the variable as <optimized out>. IOW, <not saved> | |
78 | is reserved for inspecting registers at the machine level. | |
79 | ||
80 | When comparing value contents, optimized out chunks, unavailable | |
81 | chunks, and valid contents data are all considered different. See | |
82 | value_contents_eq for more info. | |
83 | */ | |
84 | ||
e4153ae6 CB |
85 | extern bool overload_resolution; |
86 | ||
7cf57bc5 | 87 | /* Defines an [OFFSET, OFFSET + LENGTH) range. */ |
c906108c | 88 | |
7cf57bc5 TT |
89 | struct range |
90 | { | |
91 | /* Lowest offset in the range. */ | |
92 | LONGEST offset; | |
93 | ||
94 | /* Length of the range. */ | |
95 | ULONGEST length; | |
96 | ||
97 | /* Returns true if THIS is strictly less than OTHER, useful for | |
98 | searching. We keep ranges sorted by offset and coalesce | |
99 | overlapping and contiguous ranges, so this just compares the | |
100 | starting offset. */ | |
101 | ||
102 | bool operator< (const range &other) const | |
103 | { | |
104 | return offset < other.offset; | |
105 | } | |
106 | ||
107 | /* Returns true if THIS is equal to OTHER. */ | |
108 | bool operator== (const range &other) const | |
109 | { | |
110 | return offset == other.offset && length == other.length; | |
111 | } | |
112 | }; | |
c906108c | 113 | |
22bc8444 TT |
114 | /* A policy class to interface gdb::ref_ptr with struct value. */ |
115 | ||
116 | struct value_ref_policy | |
117 | { | |
d3824ae1 TT |
118 | static void incref (struct value *ptr); |
119 | static void decref (struct value *ptr); | |
22bc8444 TT |
120 | }; |
121 | ||
122 | /* A gdb:;ref_ptr pointer to a struct value. */ | |
123 | ||
124 | typedef gdb::ref_ptr<struct value, value_ref_policy> value_ref_ptr; | |
125 | ||
7cf57bc5 TT |
126 | /* Note that the fields in this structure are arranged to save a bit |
127 | of memory. */ | |
128 | ||
129 | struct value | |
130 | { | |
cbe793af TT |
131 | private: |
132 | ||
133 | /* Values can only be created via "static constructors". */ | |
7cf57bc5 TT |
134 | explicit value (struct type *type_) |
135 | : m_modifiable (1), | |
136 | m_lazy (1), | |
137 | m_initialized (1), | |
138 | m_stack (0), | |
139 | m_is_zero (false), | |
140 | m_in_history (false), | |
141 | m_type (type_), | |
142 | m_enclosing_type (type_) | |
143 | { | |
144 | } | |
145 | ||
cbe793af TT |
146 | public: |
147 | ||
148 | /* Allocate a lazy value for type TYPE. Its actual content is | |
149 | "lazily" allocated too: the content field of the return value is | |
150 | NULL; it will be allocated when it is fetched from the target. */ | |
151 | static struct value *allocate_lazy (struct type *type); | |
152 | ||
317c3ed9 TT |
153 | /* Allocate a value and its contents for type TYPE. */ |
154 | static struct value *allocate (struct type *type); | |
155 | ||
b64e2602 TT |
156 | /* Create a computed lvalue, with type TYPE, function pointers |
157 | FUNCS, and closure CLOSURE. */ | |
158 | static struct value *allocate_computed (struct type *type, | |
159 | const struct lval_funcs *funcs, | |
160 | void *closure); | |
161 | ||
b27556e3 TT |
162 | /* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */ |
163 | static struct value *allocate_optimized_out (struct type *type); | |
164 | ||
ee7bb294 TT |
165 | /* Create a value of type TYPE that is zero, and return it. */ |
166 | static struct value *zero (struct type *type, enum lval_type lv); | |
167 | ||
cda03344 TT |
168 | /* Return a copy of the value. It contains the same contents, for |
169 | the same memory address, but it's a different block of | |
170 | storage. */ | |
171 | struct value *copy () const; | |
172 | ||
7cf57bc5 TT |
173 | ~value (); |
174 | ||
175 | DISABLE_COPY_AND_ASSIGN (value); | |
176 | ||
d0c97917 TT |
177 | /* Type of the value. */ |
178 | struct type *type () const | |
179 | { return m_type; } | |
180 | ||
81ae560c TT |
181 | /* This is being used to change the type of an existing value, that |
182 | code should instead be creating a new value with the changed type | |
183 | (but possibly shared content). */ | |
184 | void deprecated_set_type (struct type *type) | |
185 | { m_type = type; } | |
186 | ||
f9ee742c TT |
187 | /* Return the gdbarch associated with the value. */ |
188 | struct gdbarch *arch () const; | |
189 | ||
f49d5fa2 TT |
190 | /* Only used for bitfields; number of bits contained in them. */ |
191 | LONGEST bitsize () const | |
192 | { return m_bitsize; } | |
193 | ||
194 | void set_bitsize (LONGEST bit) | |
195 | { m_bitsize = bit; } | |
196 | ||
5011c493 TT |
197 | /* Only used for bitfields; position of start of field. For |
198 | little-endian targets, it is the position of the LSB. For | |
199 | big-endian targets, it is the position of the MSB. */ | |
200 | LONGEST bitpos () const | |
201 | { return m_bitpos; } | |
202 | ||
203 | void set_bitpos (LONGEST bit) | |
204 | { m_bitpos = bit; } | |
205 | ||
fac7bdaa TT |
206 | /* Only used for bitfields; the containing value. This allows a |
207 | single read from the target when displaying multiple | |
208 | bitfields. */ | |
209 | value *parent () const | |
210 | { return m_parent.get (); } | |
211 | ||
212 | void set_parent (struct value *parent) | |
213 | { m_parent = value_ref_ptr::new_reference (parent); } | |
214 | ||
76675c4d TT |
215 | /* Describes offset of a value within lval of a structure in bytes. |
216 | If lval == lval_memory, this is an offset to the address. If | |
217 | lval == lval_register, this is a further offset from | |
218 | location.address within the registers structure. Note also the | |
219 | member embedded_offset below. */ | |
220 | LONGEST offset () const | |
221 | { return m_offset; } | |
222 | ||
223 | void set_offset (LONGEST offset) | |
224 | { m_offset = offset; } | |
225 | ||
4b53ca88 TT |
226 | /* The comment from "struct value" reads: ``Is it modifiable? Only |
227 | relevant if lval != not_lval.''. Shouldn't the value instead be | |
228 | not_lval and be done with it? */ | |
229 | int deprecated_modifiable () const | |
230 | { return m_modifiable; } | |
231 | ||
e6cf1e1b TT |
232 | /* Set or clear the modifiable flag. */ |
233 | void set_modifiable (int val) | |
234 | { m_modifiable = val; } | |
235 | ||
391f8628 TT |
236 | LONGEST pointed_to_offset () const |
237 | { return m_pointed_to_offset; } | |
238 | ||
239 | void set_pointed_to_offset (LONGEST val) | |
240 | { m_pointed_to_offset = val; } | |
241 | ||
242 | LONGEST embedded_offset () const | |
243 | { return m_embedded_offset; } | |
244 | ||
245 | void set_embedded_offset (LONGEST val) | |
246 | { m_embedded_offset = val; } | |
247 | ||
3ee3b270 TT |
248 | /* If zero, contents of this value are in the contents field. If |
249 | nonzero, contents are in inferior. If the lval field is lval_memory, | |
250 | the contents are in inferior memory at location.address plus offset. | |
251 | The lval field may also be lval_register. | |
252 | ||
253 | WARNING: This field is used by the code which handles watchpoints | |
254 | (see breakpoint.c) to decide whether a particular value can be | |
255 | watched by hardware watchpoints. If the lazy flag is set for some | |
256 | member of a value chain, it is assumed that this member of the | |
257 | chain doesn't need to be watched as part of watching the value | |
258 | itself. This is how GDB avoids watching the entire struct or array | |
259 | when the user wants to watch a single struct member or array | |
260 | element. If you ever change the way lazy flag is set and reset, be | |
261 | sure to consider this use as well! */ | |
262 | ||
263 | int lazy () const | |
264 | { return m_lazy; } | |
265 | ||
266 | void set_lazy (int val) | |
267 | { m_lazy = val; } | |
268 | ||
463b870d TT |
269 | /* If a value represents a C++ object, then the `type' field gives the |
270 | object's compile-time type. If the object actually belongs to some | |
271 | class derived from `type', perhaps with other base classes and | |
272 | additional members, then `type' is just a subobject of the real | |
273 | thing, and the full object is probably larger than `type' would | |
274 | suggest. | |
275 | ||
276 | If `type' is a dynamic class (i.e. one with a vtable), then GDB can | |
277 | actually determine the object's run-time type by looking at the | |
278 | run-time type information in the vtable. When this information is | |
279 | available, we may elect to read in the entire object, for several | |
280 | reasons: | |
281 | ||
282 | - When printing the value, the user would probably rather see the | |
283 | full object, not just the limited portion apparent from the | |
284 | compile-time type. | |
285 | ||
286 | - If `type' has virtual base classes, then even printing `type' | |
287 | alone may require reaching outside the `type' portion of the | |
288 | object to wherever the virtual base class has been stored. | |
289 | ||
290 | When we store the entire object, `enclosing_type' is the run-time | |
291 | type -- the complete object -- and `embedded_offset' is the offset | |
efaf1ae0 TT |
292 | of `type' within that larger type, in bytes. The contents() |
293 | method takes `embedded_offset' into account, so most GDB code | |
463b870d TT |
294 | continues to see the `type' portion of the value, just as the |
295 | inferior would. | |
296 | ||
297 | If `type' is a pointer to an object, then `enclosing_type' is a | |
298 | pointer to the object's run-time type, and `pointed_to_offset' is | |
299 | the offset in bytes from the full object to the pointed-to object | |
300 | -- that is, the value `embedded_offset' would have if we followed | |
301 | the pointer and fetched the complete object. (I don't really see | |
302 | the point. Why not just determine the run-time type when you | |
303 | indirect, and avoid the special case? The contents don't matter | |
304 | until you indirect anyway.) | |
305 | ||
306 | If we're not doing anything fancy, `enclosing_type' is equal to | |
307 | `type', and `embedded_offset' is zero, so everything works | |
308 | normally. */ | |
309 | ||
310 | struct type *enclosing_type () const | |
311 | { return m_enclosing_type; } | |
312 | ||
313 | void set_enclosing_type (struct type *new_type); | |
314 | ||
c8580184 TT |
315 | int stack () const |
316 | { return m_stack; } | |
317 | ||
318 | void set_stack (int val) | |
319 | { m_stack = val; } | |
320 | ||
b9f74d54 TT |
321 | /* If this value is lval_computed, return its lval_funcs |
322 | structure. */ | |
323 | const struct lval_funcs *computed_funcs () const; | |
324 | ||
325 | /* If this value is lval_computed, return its closure. The meaning | |
326 | of the returned value depends on the functions this value | |
327 | uses. */ | |
328 | void *computed_closure () const; | |
329 | ||
97044105 TT |
330 | enum lval_type *deprecated_lval_hack () |
331 | { return &m_lval; } | |
332 | ||
333 | enum lval_type lval () const | |
334 | { return m_lval; } | |
335 | ||
8e5b19ad TT |
336 | /* Set or return field indicating whether a variable is initialized or |
337 | not, based on debugging information supplied by the compiler. | |
338 | 1 = initialized; 0 = uninitialized. */ | |
339 | int initialized () const | |
340 | { return m_initialized; } | |
341 | ||
342 | void set_initialized (int value) | |
343 | { m_initialized = value; } | |
344 | ||
9feb2d07 TT |
345 | /* If lval == lval_memory, return the address in the inferior. If |
346 | lval == lval_register, return the byte offset into the registers | |
347 | structure. Otherwise, return 0. The returned address | |
348 | includes the offset, if any. */ | |
349 | CORE_ADDR address () const; | |
350 | ||
351 | /* Like address, except the result does not include value's | |
352 | offset. */ | |
353 | CORE_ADDR raw_address () const; | |
354 | ||
355 | /* Set the address of a value. */ | |
356 | void set_address (CORE_ADDR); | |
357 | ||
f29de665 TT |
358 | struct internalvar **deprecated_internalvar_hack () |
359 | { return &m_location.internalvar; } | |
360 | ||
361 | struct frame_id *deprecated_next_frame_id_hack (); | |
362 | ||
363 | int *deprecated_regnum_hack (); | |
364 | ||
bbe912ba TT |
365 | /* contents() and contents_raw() both return the address of the gdb |
366 | buffer used to hold a copy of the contents of the lval. | |
367 | contents() is used when the contents of the buffer are needed -- | |
368 | it uses fetch_lazy() to load the buffer from the process being | |
369 | debugged if it hasn't already been loaded (contents_writeable() | |
370 | is used when a writeable but fetched buffer is required).. | |
371 | contents_raw() is used when data is being stored into the buffer, | |
372 | or when it is certain that the contents of the buffer are valid. | |
373 | ||
374 | Note: The contents pointer is adjusted by the offset required to | |
375 | get to the real subobject, if the value happens to represent | |
376 | something embedded in a larger run-time object. */ | |
377 | gdb::array_view<gdb_byte> contents_raw (); | |
efaf1ae0 TT |
378 | |
379 | /* Actual contents of the value. For use of this value; setting it | |
380 | uses the stuff above. Not valid if lazy is nonzero. Target | |
381 | byte-order. We force it to be aligned properly for any possible | |
382 | value. Note that a value therefore extends beyond what is | |
383 | declared here. */ | |
384 | gdb::array_view<const gdb_byte> contents (); | |
385 | ||
386 | /* The ALL variants of the above two methods do not adjust the | |
387 | returned pointer by the embedded_offset value. */ | |
388 | gdb::array_view<const gdb_byte> contents_all (); | |
bbe912ba | 389 | gdb::array_view<gdb_byte> contents_all_raw (); |
efaf1ae0 | 390 | |
bbe912ba TT |
391 | gdb::array_view<gdb_byte> contents_writeable (); |
392 | ||
efaf1ae0 TT |
393 | /* Like contents_all, but does not require that the returned bits be |
394 | valid. This should only be used in situations where you plan to | |
395 | check the validity manually. */ | |
396 | gdb::array_view<const gdb_byte> contents_for_printing (); | |
397 | ||
398 | /* Like contents_for_printing, but accepts a constant value pointer. | |
399 | Unlike contents_for_printing however, the pointed value must | |
400 | _not_ be lazy. */ | |
401 | gdb::array_view<const gdb_byte> contents_for_printing () const; | |
402 | ||
78259c36 TT |
403 | /* Load the actual content of a lazy value. Fetch the data from the |
404 | user's process and clear the lazy flag to indicate that the data in | |
405 | the buffer is valid. | |
406 | ||
407 | If the value is zero-length, we avoid calling read_memory, which | |
408 | would abort. We mark the value as fetched anyway -- all 0 bytes of | |
409 | it. */ | |
410 | void fetch_lazy (); | |
411 | ||
02744ba9 TT |
412 | /* Compare LENGTH bytes of this value's contents starting at OFFSET1 |
413 | with LENGTH bytes of VAL2's contents starting at OFFSET2. | |
414 | ||
415 | Note that "contents" refers to the whole value's contents | |
416 | (value_contents_all), without any embedded offset adjustment. For | |
417 | example, to compare a complete object value with itself, including | |
418 | its enclosing type chunk, you'd do: | |
419 | ||
420 | int len = check_typedef (val->enclosing_type ())->length (); | |
421 | val->contents_eq (0, val, 0, len); | |
422 | ||
423 | Returns true iff the set of available/valid contents match. | |
424 | ||
425 | Optimized-out contents are equal to optimized-out contents, and are | |
426 | not equal to non-optimized-out contents. | |
427 | ||
428 | Unavailable contents are equal to unavailable contents, and are not | |
429 | equal to non-unavailable contents. | |
430 | ||
431 | For example, if 'x's represent an unavailable byte, and 'V' and 'Z' | |
432 | represent different available/valid bytes, in a value with length | |
433 | 16: | |
434 | ||
435 | offset: 0 4 8 12 16 | |
436 | contents: xxxxVVVVxxxxVVZZ | |
437 | ||
438 | then: | |
439 | ||
440 | val->contents_eq(0, val, 8, 6) => true | |
441 | val->contents_eq(0, val, 4, 4) => false | |
442 | val->contents_eq(0, val, 8, 8) => false | |
443 | val->contents_eq(4, val, 12, 2) => true | |
444 | val->contents_eq(4, val, 12, 4) => true | |
445 | val->contents_eq(3, val, 4, 4) => true | |
446 | ||
447 | If 'x's represent an unavailable byte, 'o' represents an optimized | |
448 | out byte, in a value with length 8: | |
449 | ||
450 | offset: 0 4 8 | |
451 | contents: xxxxoooo | |
452 | ||
453 | then: | |
454 | ||
455 | val->contents_eq(0, val, 2, 2) => true | |
456 | val->contents_eq(4, val, 6, 2) => true | |
457 | val->contents_eq(0, val, 4, 4) => true | |
458 | ||
459 | We only know whether a value chunk is unavailable or optimized out | |
460 | if we've tried to read it. As this routine is used by printing | |
461 | routines, which may be printing values in the value history, long | |
462 | after the inferior is gone, it works with const values. Therefore, | |
463 | this routine must not be called with lazy values. */ | |
464 | ||
465 | bool contents_eq (LONGEST offset1, const struct value *val2, LONGEST offset2, | |
466 | LONGEST length) const; | |
467 | ||
468 | /* An overload of contents_eq that compares the entirety of both | |
469 | values. */ | |
470 | bool contents_eq (const struct value *val2) const; | |
471 | ||
e989e637 TT |
472 | /* Given a value, determine whether the bits starting at OFFSET and |
473 | extending for LENGTH bits are a synthetic pointer. */ | |
474 | ||
475 | int bits_synthetic_pointer (LONGEST offset, LONGEST length) const; | |
476 | ||
cdf3de17 TT |
477 | /* Increase this value's reference count. */ |
478 | void incref () | |
479 | { ++m_reference_count; } | |
480 | ||
481 | /* Decrease this value's reference count. When the reference count | |
482 | drops to 0, it will be freed. */ | |
483 | void decref (); | |
484 | ||
d00664db TT |
485 | /* Given a value, determine whether the contents bytes starting at |
486 | OFFSET and extending for LENGTH bytes are available. This returns | |
487 | nonzero if all bytes in the given range are available, zero if any | |
488 | byte is unavailable. */ | |
489 | int bytes_available (LONGEST offset, ULONGEST length) const; | |
490 | ||
491 | /* Given a value, determine whether the contents bits starting at | |
492 | OFFSET and extending for LENGTH bits are available. This returns | |
493 | nonzero if all bits in the given range are available, zero if any | |
494 | bit is unavailable. */ | |
495 | int bits_available (LONGEST offset, ULONGEST length) const; | |
496 | ||
497 | /* Like bytes_available, but return false if any byte in the | |
498 | whole object is unavailable. */ | |
499 | int entirely_available (); | |
500 | ||
501 | /* Like entirely_available, but return false if any byte in the | |
502 | whole object is available. */ | |
503 | int entirely_unavailable () | |
504 | { return entirely_covered_by_range_vector (m_unavailable); } | |
505 | ||
506 | /* Mark this value's content bytes starting at OFFSET and extending | |
507 | for LENGTH bytes as unavailable. */ | |
508 | void mark_bytes_unavailable (LONGEST offset, ULONGEST length); | |
509 | ||
510 | /* Mark this value's content bits starting at OFFSET and extending | |
511 | for LENGTH bits as unavailable. */ | |
512 | void mark_bits_unavailable (LONGEST offset, ULONGEST length); | |
513 | ||
514 | /* If nonzero, this is the value of a variable which does not actually | |
515 | exist in the program, at least partially. If the value is lazy, | |
516 | this may fetch it now. */ | |
517 | int optimized_out (); | |
518 | ||
519 | /* Given a value, return true if any of the contents bits starting at | |
520 | OFFSET and extending for LENGTH bits is optimized out, false | |
521 | otherwise. */ | |
522 | int bits_any_optimized_out (int bit_offset, int bit_length) const; | |
523 | ||
524 | /* Like optimized_out, but return true iff the whole value is | |
525 | optimized out. */ | |
526 | int entirely_optimized_out () | |
527 | { | |
528 | return entirely_covered_by_range_vector (m_optimized_out); | |
529 | } | |
530 | ||
531 | /* Mark this value's content bytes starting at OFFSET and extending | |
532 | for LENGTH bytes as optimized out. */ | |
533 | void mark_bytes_optimized_out (int offset, int length); | |
534 | ||
535 | /* Mark this value's content bits starting at OFFSET and extending | |
536 | for LENGTH bits as optimized out. */ | |
537 | void mark_bits_optimized_out (LONGEST offset, LONGEST length); | |
538 | ||
aa9f4538 TT |
539 | /* Return a version of this that is non-lvalue. */ |
540 | struct value *non_lval (); | |
541 | ||
542 | /* Write contents of this value at ADDR and set its lval type to be | |
543 | LVAL_MEMORY. */ | |
544 | void force_lval (CORE_ADDR); | |
545 | ||
8181b7b6 TT |
546 | /* Set this values's location as appropriate for a component of |
547 | WHOLE --- regardless of what kind of lvalue WHOLE is. */ | |
548 | void set_component_location (const struct value *whole); | |
549 | ||
6bd5c754 TT |
550 | /* Build a value wrapping and representing WORKER. The value takes |
551 | ownership of the xmethod_worker object. */ | |
552 | static struct value *from_xmethod (xmethod_worker_up &&worker); | |
553 | ||
554 | /* Return the type of the result of TYPE_CODE_XMETHOD value METHOD. */ | |
555 | struct type *result_type_of_xmethod (gdb::array_view<value *> argv); | |
556 | ||
557 | /* Call the xmethod corresponding to the TYPE_CODE_XMETHOD value | |
558 | METHOD. */ | |
559 | struct value *call_xmethod (gdb::array_view<value *> argv); | |
560 | ||
e3fb3c47 TT |
561 | /* Update this value before discarding OBJFILE. COPIED_TYPES is |
562 | used to prevent cycles / duplicates. */ | |
563 | void preserve (struct objfile *objfile, htab_t copied_types); | |
564 | ||
6c49729e TT |
565 | /* Unpack a bitfield of BITSIZE bits found at BITPOS in the object |
566 | at VALADDR + EMBEDDEDOFFSET that has the type of DEST_VAL and | |
567 | store the contents in DEST_VAL, zero or sign extending if the | |
568 | type of DEST_VAL is wider than BITSIZE. VALADDR points to the | |
569 | contents of this value. If this value's contents required to | |
570 | extract the bitfield from are unavailable/optimized out, DEST_VAL | |
571 | is correspondingly marked unavailable/optimized out. */ | |
572 | void unpack_bitfield (struct value *dest_val, | |
573 | LONGEST bitpos, LONGEST bitsize, | |
574 | const gdb_byte *valaddr, LONGEST embedded_offset) | |
575 | const; | |
576 | ||
577 | /* Copy LENGTH bytes of this value's (all) contents | |
578 | (value_contents_all) starting at SRC_OFFSET byte, into DST | |
579 | value's (all) contents, starting at DST_OFFSET. If unavailable | |
580 | contents are being copied from this value, the corresponding DST | |
581 | contents are marked unavailable accordingly. DST must not be | |
582 | lazy. If this value is lazy, it will be fetched now. | |
583 | ||
584 | It is assumed the contents of DST in the [DST_OFFSET, | |
585 | DST_OFFSET+LENGTH) range are wholly available. */ | |
586 | void contents_copy (struct value *dst, LONGEST dst_offset, | |
587 | LONGEST src_offset, LONGEST length); | |
588 | ||
589 | /* Given a value (offset by OFFSET bytes) | |
590 | of a struct or union type ARG_TYPE, | |
591 | extract and return the value of one of its (non-static) fields. | |
592 | FIELDNO says which field. */ | |
593 | struct value *primitive_field (LONGEST offset, int fieldno, | |
594 | struct type *arg_type); | |
595 | ||
596 | /* Create a new value by extracting it from this value. TYPE is the | |
597 | type of the new value. BIT_OFFSET and BIT_LENGTH describe the | |
598 | offset and field width of the value to extract from this value -- | |
599 | BIT_LENGTH may differ from TYPE's length in the case where this | |
600 | value's type is packed. | |
601 | ||
602 | When the value does come from a non-byte-aligned offset or field | |
603 | width, it will be marked non_lval. */ | |
604 | struct value *from_component_bitsize (struct type *type, | |
605 | LONGEST bit_offset, | |
606 | LONGEST bit_length); | |
607 | ||
0d0f488e TT |
608 | /* Record this value on the value history, and return its location |
609 | in the history. The value is removed from the value chain. */ | |
610 | int record_latest (); | |
d0c97917 | 611 | |
8f413531 TT |
612 | private: |
613 | ||
7cf57bc5 TT |
614 | /* Type of value; either not an lval, or one of the various |
615 | different possible kinds of lval. */ | |
616 | enum lval_type m_lval = not_lval; | |
617 | ||
618 | /* Is it modifiable? Only relevant if lval != not_lval. */ | |
619 | unsigned int m_modifiable : 1; | |
620 | ||
621 | /* If zero, contents of this value are in the contents field. If | |
622 | nonzero, contents are in inferior. If the lval field is lval_memory, | |
623 | the contents are in inferior memory at location.address plus offset. | |
624 | The lval field may also be lval_register. | |
625 | ||
626 | WARNING: This field is used by the code which handles watchpoints | |
627 | (see breakpoint.c) to decide whether a particular value can be | |
628 | watched by hardware watchpoints. If the lazy flag is set for | |
629 | some member of a value chain, it is assumed that this member of | |
630 | the chain doesn't need to be watched as part of watching the | |
631 | value itself. This is how GDB avoids watching the entire struct | |
632 | or array when the user wants to watch a single struct member or | |
633 | array element. If you ever change the way lazy flag is set and | |
634 | reset, be sure to consider this use as well! */ | |
635 | unsigned int m_lazy : 1; | |
636 | ||
637 | /* If value is a variable, is it initialized or not. */ | |
638 | unsigned int m_initialized : 1; | |
639 | ||
640 | /* If value is from the stack. If this is set, read_stack will be | |
641 | used instead of read_memory to enable extra caching. */ | |
642 | unsigned int m_stack : 1; | |
643 | ||
ee7bb294 | 644 | /* True if this is a zero value, created by 'value::zero'; false |
7cf57bc5 TT |
645 | otherwise. */ |
646 | bool m_is_zero : 1; | |
647 | ||
648 | /* True if this a value recorded in value history; false otherwise. */ | |
649 | bool m_in_history : 1; | |
650 | ||
651 | /* Location of value (if lval). */ | |
652 | union | |
653 | { | |
654 | /* If lval == lval_memory, this is the address in the inferior */ | |
655 | CORE_ADDR address; | |
656 | ||
657 | /*If lval == lval_register, the value is from a register. */ | |
658 | struct | |
659 | { | |
660 | /* Register number. */ | |
661 | int regnum; | |
662 | /* Frame ID of "next" frame to which a register value is relative. | |
663 | If the register value is found relative to frame F, then the | |
664 | frame id of F->next will be stored in next_frame_id. */ | |
665 | struct frame_id next_frame_id; | |
666 | } reg; | |
667 | ||
668 | /* Pointer to internal variable. */ | |
669 | struct internalvar *internalvar; | |
670 | ||
671 | /* Pointer to xmethod worker. */ | |
672 | struct xmethod_worker *xm_worker; | |
673 | ||
674 | /* If lval == lval_computed, this is a set of function pointers | |
675 | to use to access and describe the value, and a closure pointer | |
676 | for them to use. */ | |
677 | struct | |
678 | { | |
679 | /* Functions to call. */ | |
680 | const struct lval_funcs *funcs; | |
681 | ||
682 | /* Closure for those functions to use. */ | |
683 | void *closure; | |
684 | } computed; | |
685 | } m_location {}; | |
686 | ||
687 | /* Describes offset of a value within lval of a structure in target | |
688 | addressable memory units. Note also the member embedded_offset | |
689 | below. */ | |
690 | LONGEST m_offset = 0; | |
691 | ||
692 | /* Only used for bitfields; number of bits contained in them. */ | |
693 | LONGEST m_bitsize = 0; | |
694 | ||
695 | /* Only used for bitfields; position of start of field. For | |
696 | little-endian targets, it is the position of the LSB. For | |
697 | big-endian targets, it is the position of the MSB. */ | |
698 | LONGEST m_bitpos = 0; | |
699 | ||
700 | /* The number of references to this value. When a value is created, | |
701 | the value chain holds a reference, so REFERENCE_COUNT is 1. If | |
702 | release_value is called, this value is removed from the chain but | |
703 | the caller of release_value now has a reference to this value. | |
704 | The caller must arrange for a call to value_free later. */ | |
705 | int m_reference_count = 1; | |
706 | ||
707 | /* Only used for bitfields; the containing value. This allows a | |
708 | single read from the target when displaying multiple | |
709 | bitfields. */ | |
710 | value_ref_ptr m_parent; | |
711 | ||
712 | /* Type of the value. */ | |
713 | struct type *m_type; | |
714 | ||
715 | /* If a value represents a C++ object, then the `type' field gives | |
716 | the object's compile-time type. If the object actually belongs | |
717 | to some class derived from `type', perhaps with other base | |
718 | classes and additional members, then `type' is just a subobject | |
719 | of the real thing, and the full object is probably larger than | |
720 | `type' would suggest. | |
721 | ||
722 | If `type' is a dynamic class (i.e. one with a vtable), then GDB | |
723 | can actually determine the object's run-time type by looking at | |
724 | the run-time type information in the vtable. When this | |
725 | information is available, we may elect to read in the entire | |
726 | object, for several reasons: | |
727 | ||
728 | - When printing the value, the user would probably rather see the | |
729 | full object, not just the limited portion apparent from the | |
730 | compile-time type. | |
731 | ||
732 | - If `type' has virtual base classes, then even printing `type' | |
733 | alone may require reaching outside the `type' portion of the | |
734 | object to wherever the virtual base class has been stored. | |
735 | ||
736 | When we store the entire object, `enclosing_type' is the run-time | |
737 | type -- the complete object -- and `embedded_offset' is the | |
738 | offset of `type' within that larger type, in target addressable memory | |
efaf1ae0 | 739 | units. The contents() method takes `embedded_offset' into account, |
7cf57bc5 TT |
740 | so most GDB code continues to see the `type' portion of the value, just |
741 | as the inferior would. | |
742 | ||
743 | If `type' is a pointer to an object, then `enclosing_type' is a | |
744 | pointer to the object's run-time type, and `pointed_to_offset' is | |
745 | the offset in target addressable memory units from the full object | |
746 | to the pointed-to object -- that is, the value `embedded_offset' would | |
747 | have if we followed the pointer and fetched the complete object. | |
748 | (I don't really see the point. Why not just determine the | |
749 | run-time type when you indirect, and avoid the special case? The | |
750 | contents don't matter until you indirect anyway.) | |
751 | ||
752 | If we're not doing anything fancy, `enclosing_type' is equal to | |
753 | `type', and `embedded_offset' is zero, so everything works | |
754 | normally. */ | |
755 | struct type *m_enclosing_type; | |
756 | LONGEST m_embedded_offset = 0; | |
757 | LONGEST m_pointed_to_offset = 0; | |
758 | ||
759 | /* Actual contents of the value. Target byte-order. | |
760 | ||
761 | May be nullptr if the value is lazy or is entirely optimized out. | |
762 | Guaranteed to be non-nullptr otherwise. */ | |
763 | gdb::unique_xmalloc_ptr<gdb_byte> m_contents; | |
764 | ||
765 | /* Unavailable ranges in CONTENTS. We mark unavailable ranges, | |
766 | rather than available, since the common and default case is for a | |
767 | value to be available. This is filled in at value read time. | |
768 | The unavailable ranges are tracked in bits. Note that a contents | |
769 | bit that has been optimized out doesn't really exist in the | |
770 | program, so it can't be marked unavailable either. */ | |
771 | std::vector<range> m_unavailable; | |
772 | ||
773 | /* Likewise, but for optimized out contents (a chunk of the value of | |
774 | a variable that does not actually exist in the program). If LVAL | |
775 | is lval_register, this is a register ($pc, $sp, etc., never a | |
776 | program variable) that has not been saved in the frame. Not | |
777 | saved registers and optimized-out program variables values are | |
778 | treated pretty much the same, except not-saved registers have a | |
779 | different string representation and related error strings. */ | |
780 | std::vector<range> m_optimized_out; | |
781 | ||
782 | /* This is only non-zero for values of TYPE_CODE_ARRAY and if the size of | |
783 | the array in inferior memory is greater than max_value_size. If these | |
784 | conditions are met then, when the value is loaded from the inferior | |
785 | GDB will only load a portion of the array into memory, and | |
786 | limited_length will be set to indicate the length in octets that were | |
787 | loaded from the inferior. */ | |
788 | ULONGEST m_limited_length = 0; | |
317c3ed9 | 789 | |
317c3ed9 TT |
790 | /* Allocate a value and its contents for type TYPE. If CHECK_SIZE |
791 | is true, then apply the usual max-value-size checks. */ | |
792 | static struct value *allocate (struct type *type, bool check_size); | |
78259c36 TT |
793 | |
794 | /* Helper for fetch_lazy when the value is a bitfield. */ | |
795 | void fetch_lazy_bitfield (); | |
796 | ||
797 | /* Helper for fetch_lazy when the value is in memory. */ | |
798 | void fetch_lazy_memory (); | |
799 | ||
800 | /* Helper for fetch_lazy when the value is in a register. */ | |
801 | void fetch_lazy_register (); | |
82ca8f72 TT |
802 | |
803 | /* Try to limit ourselves to only fetching the limited number of | |
804 | elements. However, if this limited number of elements still | |
805 | puts us over max_value_size, then we still refuse it and | |
806 | return failure here, which will ultimately throw an error. */ | |
807 | bool set_limited_array_length (); | |
808 | ||
82ca8f72 TT |
809 | /* Allocate the contents of this value if it has not been allocated |
810 | yet. If CHECK_SIZE is true, then apply the usual max-value-size | |
811 | checks. */ | |
812 | void allocate_contents (bool check_size); | |
02744ba9 | 813 | |
02744ba9 TT |
814 | /* Helper function for value_contents_eq. The only difference is that |
815 | this function is bit rather than byte based. | |
816 | ||
817 | Compare LENGTH bits of this value's contents starting at OFFSET1 | |
818 | bits with LENGTH bits of VAL2's contents starting at OFFSET2 | |
819 | bits. Return true if the available bits match. */ | |
820 | bool contents_bits_eq (int offset1, const struct value *val2, int offset2, | |
821 | int length) const; | |
efaf1ae0 TT |
822 | |
823 | void require_not_optimized_out () const; | |
824 | void require_available () const; | |
d00664db TT |
825 | |
826 | /* Returns true if this value is entirely covered by RANGES. If the | |
827 | value is lazy, it'll be read now. Note that RANGE is a pointer | |
828 | to pointer because reading the value might change *RANGE. */ | |
829 | int entirely_covered_by_range_vector (const std::vector<range> &ranges); | |
6c49729e TT |
830 | |
831 | /* Copy the ranges metadata from this value that overlaps | |
832 | [SRC_BIT_OFFSET, SRC_BIT_OFFSET+BIT_LENGTH) into DST, | |
833 | adjusted. */ | |
834 | void ranges_copy_adjusted (struct value *dst, int dst_bit_offset, | |
835 | int src_bit_offset, int bit_length) const; | |
836 | ||
837 | /* Copy LENGTH target addressable memory units of this value's (all) | |
838 | contents (value_contents_all) starting at SRC_OFFSET, into DST | |
839 | value's (all) contents, starting at DST_OFFSET. If unavailable | |
840 | contents are being copied from this, the corresponding DST | |
841 | contents are marked unavailable accordingly. Neither DST nor | |
842 | this value may be lazy values. | |
843 | ||
844 | It is assumed the contents of DST in the [DST_OFFSET, | |
845 | DST_OFFSET+LENGTH) range are wholly available. */ | |
846 | void contents_copy_raw (struct value *dst, LONGEST dst_offset, | |
847 | LONGEST src_offset, LONGEST length); | |
848 | ||
849 | /* A helper for value_from_component_bitsize that copies bits from | |
850 | this value to DEST. */ | |
851 | void contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, | |
852 | LONGEST src_bit_offset, LONGEST bit_length); | |
7cf57bc5 TT |
853 | }; |
854 | ||
d3824ae1 TT |
855 | inline void |
856 | value_ref_policy::incref (struct value *ptr) | |
857 | { | |
cdf3de17 | 858 | ptr->incref (); |
d3824ae1 TT |
859 | } |
860 | ||
861 | inline void | |
862 | value_ref_policy::decref (struct value *ptr) | |
863 | { | |
cdf3de17 | 864 | ptr->decref (); |
d3824ae1 TT |
865 | } |
866 | ||
8264ba82 AG |
867 | /* Returns value_type or value_enclosing_type depending on |
868 | value_print_options.objectprint. | |
869 | ||
870 | If RESOLVE_SIMPLE_TYPES is 0 the enclosing type will be resolved | |
871 | only for pointers and references, else it will be returned | |
872 | for all the types (e.g. structures). This option is useful | |
873 | to prevent retrieving enclosing type for the base classes fields. | |
874 | ||
875 | REAL_TYPE_FOUND is used to inform whether the real type was found | |
876 | (or just static type was used). The NULL may be passed if it is not | |
877 | necessary. */ | |
878 | ||
879 | extern struct type *value_actual_type (struct value *value, | |
880 | int resolve_simple_types, | |
881 | int *real_type_found); | |
882 | ||
5f5233d4 PA |
883 | /* For lval_computed values, this structure holds functions used to |
884 | retrieve and set the value (or portions of the value). | |
885 | ||
886 | For each function, 'V' is the 'this' pointer: an lval_funcs | |
887 | function F may always assume that the V it receives is an | |
888 | lval_computed value, and has F in the appropriate slot of its | |
889 | lval_funcs structure. */ | |
890 | ||
891 | struct lval_funcs | |
892 | { | |
893 | /* Fill in VALUE's contents. This is used to "un-lazy" values. If | |
894 | a problem arises in obtaining VALUE's bits, this function should | |
ac71a68c JK |
895 | call 'error'. If it is NULL value_fetch_lazy on "un-lazy" |
896 | non-optimized-out value is an internal error. */ | |
5f5233d4 PA |
897 | void (*read) (struct value *v); |
898 | ||
899 | /* Handle an assignment TOVAL = FROMVAL by writing the value of | |
900 | FROMVAL to TOVAL's location. The contents of TOVAL have not yet | |
901 | been updated. If a problem arises in doing so, this function | |
ac71a68c JK |
902 | should call 'error'. If it is NULL such TOVAL assignment is an error as |
903 | TOVAL is not considered as an lvalue. */ | |
5f5233d4 PA |
904 | void (*write) (struct value *toval, struct value *fromval); |
905 | ||
a519e8ff TT |
906 | /* Return true if any part of V is optimized out, false otherwise. |
907 | This will only be called for lazy values -- if the value has been | |
908 | fetched, then the value's optimized-out bits are consulted | |
909 | instead. */ | |
910 | bool (*is_optimized_out) (struct value *v); | |
911 | ||
8cf6f0b1 TT |
912 | /* If non-NULL, this is used to implement pointer indirection for |
913 | this value. This method may return NULL, in which case value_ind | |
914 | will fall back to ordinary indirection. */ | |
915 | struct value *(*indirect) (struct value *value); | |
916 | ||
a471c594 JK |
917 | /* If non-NULL, this is used to implement reference resolving for |
918 | this value. This method may return NULL, in which case coerce_ref | |
919 | will fall back to ordinary references resolving. */ | |
920 | struct value *(*coerce_ref) (const struct value *value); | |
921 | ||
8cf6f0b1 TT |
922 | /* If non-NULL, this is used to determine whether the indicated bits |
923 | of VALUE are a synthetic pointer. */ | |
924 | int (*check_synthetic_pointer) (const struct value *value, | |
6b850546 | 925 | LONGEST offset, int length); |
8cf6f0b1 | 926 | |
5f5233d4 PA |
927 | /* Return a duplicate of VALUE's closure, for use in a new value. |
928 | This may simply return the same closure, if VALUE's is | |
929 | reference-counted or statically allocated. | |
930 | ||
931 | This may be NULL, in which case VALUE's closure is re-used in the | |
932 | new value. */ | |
0e03807e | 933 | void *(*copy_closure) (const struct value *v); |
5f5233d4 PA |
934 | |
935 | /* Drop VALUE's reference to its closure. Maybe this frees the | |
936 | closure; maybe this decrements a reference count; maybe the | |
937 | closure is statically allocated and this does nothing. | |
938 | ||
939 | This may be NULL, in which case no action is taken to free | |
940 | VALUE's closure. */ | |
941 | void (*free_closure) (struct value *v); | |
942 | }; | |
943 | ||
901461f8 PA |
944 | /* Throw an error complaining that the value has been optimized |
945 | out. */ | |
946 | ||
947 | extern void error_value_optimized_out (void); | |
948 | ||
13bb5560 AC |
949 | /* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a |
950 | single value might have multiple LVALs), this hacked interface is | |
951 | limited to just the first PIECE. Expect further change. */ | |
91294c83 AC |
952 | /* Type of value; either not an lval, or one of the various different |
953 | possible kinds of lval. */ | |
97044105 | 954 | #define VALUE_LVAL(val) (*((val)->deprecated_lval_hack ())) |
a471c594 | 955 | |
91294c83 | 956 | /* Pointer to internal variable. */ |
f29de665 | 957 | #define VALUE_INTERNALVAR(val) (*((val)->deprecated_internalvar_hack ())) |
91294c83 | 958 | |
41b56feb KB |
959 | /* Frame ID of "next" frame to which a register value is relative. A |
960 | register value is indicated by VALUE_LVAL being set to lval_register. | |
961 | So, if the register value is found relative to frame F, then the | |
962 | frame id of F->next will be stored in VALUE_NEXT_FRAME_ID. */ | |
f29de665 | 963 | #define VALUE_NEXT_FRAME_ID(val) (*((val)->deprecated_next_frame_id_hack ())) |
41b56feb | 964 | |
91294c83 | 965 | /* Register number if the value is from a register. */ |
f29de665 | 966 | #define VALUE_REGNUM(val) (*((val)->deprecated_regnum_hack ())) |
13bb5560 | 967 | |
a471c594 JK |
968 | /* Return value after lval_funcs->coerce_ref (after check_typedef). Return |
969 | NULL if lval_funcs->coerce_ref is not applicable for whatever reason. */ | |
970 | ||
971 | extern struct value *coerce_ref_if_computed (const struct value *arg); | |
972 | ||
dfcee124 AG |
973 | /* Setup a new value type and enclosing value type for dereferenced value VALUE. |
974 | ENC_TYPE is the new enclosing type that should be set. ORIGINAL_TYPE and | |
e79eb02f AB |
975 | ORIGINAL_VAL are the type and value of the original reference or |
976 | pointer. ORIGINAL_VALUE_ADDRESS is the address within VALUE, that is | |
977 | the address that was dereferenced. | |
dfcee124 AG |
978 | |
979 | Note, that VALUE is modified by this function. | |
980 | ||
981 | It is a common implementation for coerce_ref and value_ind. */ | |
982 | ||
983 | extern struct value * readjust_indirect_value_type (struct value *value, | |
984 | struct type *enc_type, | |
4bf7b526 | 985 | const struct type *original_type, |
e79eb02f AB |
986 | struct value *original_val, |
987 | CORE_ADDR original_value_address); | |
dfcee124 | 988 | |
dea7f9ba | 989 | /* Convert a REF to the object referenced. */ |
c906108c | 990 | |
994b9211 | 991 | extern struct value *coerce_ref (struct value *value); |
c906108c SS |
992 | |
993 | /* If ARG is an array, convert it to a pointer. | |
c906108c SS |
994 | If ARG is a function, convert it to a function pointer. |
995 | ||
996 | References are dereferenced. */ | |
997 | ||
994b9211 | 998 | extern struct value *coerce_array (struct value *value); |
c906108c | 999 | |
3ae385af SM |
1000 | /* Read LENGTH addressable memory units starting at MEMADDR into BUFFER, |
1001 | which is (or will be copied to) VAL's contents buffer offset by | |
23f945bf AA |
1002 | BIT_OFFSET bits. Marks value contents ranges as unavailable if |
1003 | the corresponding memory is likewise unavailable. STACK indicates | |
1004 | whether the memory is known to be stack memory. */ | |
e6ca34fc | 1005 | |
23f945bf | 1006 | extern void read_value_memory (struct value *val, LONGEST bit_offset, |
e6ca34fc PA |
1007 | int stack, CORE_ADDR memaddr, |
1008 | gdb_byte *buffer, size_t length); | |
1009 | ||
8954db33 AB |
1010 | /* Cast SCALAR_VALUE to the element type of VECTOR_TYPE, then replicate |
1011 | into each element of a new vector value with VECTOR_TYPE. */ | |
1012 | ||
1013 | struct value *value_vector_widen (struct value *scalar_value, | |
1014 | struct type *vector_type); | |
1015 | ||
c906108c | 1016 | \f |
c5aa993b | 1017 | |
c906108c SS |
1018 | #include "symtab.h" |
1019 | #include "gdbtypes.h" | |
1020 | #include "expression.h" | |
1021 | ||
bd2b40ac | 1022 | class frame_info_ptr; |
c906108c | 1023 | struct fn_field; |
c906108c | 1024 | |
9cb709b6 TT |
1025 | extern int print_address_demangle (const struct value_print_options *, |
1026 | struct gdbarch *, CORE_ADDR, | |
1027 | struct ui_file *, int); | |
c906108c | 1028 | |
70100014 UW |
1029 | /* Returns true if VAL is of floating-point type. In addition, |
1030 | throws an error if the value is an invalid floating-point value. */ | |
1031 | extern bool is_floating_value (struct value *val); | |
1032 | ||
f23631e4 | 1033 | extern LONGEST value_as_long (struct value *val); |
f23631e4 | 1034 | extern CORE_ADDR value_as_address (struct value *val); |
c906108c | 1035 | |
fc1a4b47 | 1036 | extern LONGEST unpack_long (struct type *type, const gdb_byte *valaddr); |
fc1a4b47 | 1037 | extern CORE_ADDR unpack_pointer (struct type *type, const gdb_byte *valaddr); |
5467c6c8 | 1038 | |
8929e59d | 1039 | extern LONGEST unpack_field_as_long (struct type *type, |
fc1a4b47 | 1040 | const gdb_byte *valaddr, |
a14ed312 | 1041 | int fieldno); |
ef83a141 TT |
1042 | |
1043 | /* Unpack a bitfield of the specified FIELD_TYPE, from the object at | |
1044 | VALADDR, and store the result in *RESULT. | |
1045 | The bitfield starts at BITPOS bits and contains BITSIZE bits; if | |
1046 | BITSIZE is zero, then the length is taken from FIELD_TYPE. | |
1047 | ||
1048 | Extracting bits depends on endianness of the machine. Compute the | |
1049 | number of least significant bits to discard. For big endian machines, | |
1050 | we compute the total number of bits in the anonymous object, subtract | |
1051 | off the bit count from the MSB of the object to the MSB of the | |
1052 | bitfield, then the size of the bitfield, which leaves the LSB discard | |
1053 | count. For little endian machines, the discard count is simply the | |
1054 | number of bits from the LSB of the anonymous object to the LSB of the | |
1055 | bitfield. | |
1056 | ||
1057 | If the field is signed, we also do sign extension. */ | |
1058 | ||
1059 | extern LONGEST unpack_bits_as_long (struct type *field_type, | |
1060 | const gdb_byte *valaddr, | |
1061 | LONGEST bitpos, LONGEST bitsize); | |
1062 | ||
5467c6c8 | 1063 | extern int unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr, |
6b850546 | 1064 | LONGEST embedded_offset, int fieldno, |
5467c6c8 PA |
1065 | const struct value *val, LONGEST *result); |
1066 | ||
1067 | extern struct value *value_field_bitfield (struct type *type, int fieldno, | |
1068 | const gdb_byte *valaddr, | |
6b850546 | 1069 | LONGEST embedded_offset, |
5467c6c8 | 1070 | const struct value *val); |
c906108c | 1071 | |
14d06750 DJ |
1072 | extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num); |
1073 | ||
f23631e4 | 1074 | extern struct value *value_from_longest (struct type *type, LONGEST num); |
595939de | 1075 | extern struct value *value_from_ulongest (struct type *type, ULONGEST num); |
f23631e4 | 1076 | extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr); |
7584bb30 | 1077 | extern struct value *value_from_host_double (struct type *type, double d); |
e799154c | 1078 | extern struct value *value_from_history_ref (const char *, const char **); |
3fff9862 YQ |
1079 | extern struct value *value_from_component (struct value *, struct type *, |
1080 | LONGEST); | |
0f71a2f6 | 1081 | |
e379f652 | 1082 | |
00a4c844 AC |
1083 | extern struct value *value_at (struct type *type, CORE_ADDR addr); |
1084 | extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); | |
c906108c | 1085 | |
7f22044a TT |
1086 | /* Like value_at, but ensures that the result is marked not_lval. |
1087 | This can be important if the memory is "volatile". */ | |
1088 | extern struct value *value_at_non_lval (struct type *type, CORE_ADDR addr); | |
1089 | ||
012370f6 TT |
1090 | extern struct value *value_from_contents_and_address_unresolved |
1091 | (struct type *, const gdb_byte *, CORE_ADDR); | |
8acb6b92 TT |
1092 | extern struct value *value_from_contents_and_address (struct type *, |
1093 | const gdb_byte *, | |
1094 | CORE_ADDR); | |
8a9b8146 | 1095 | extern struct value *value_from_contents (struct type *, const gdb_byte *); |
8acb6b92 | 1096 | |
2ed3c037 UW |
1097 | extern struct value *default_value_from_register (struct gdbarch *gdbarch, |
1098 | struct type *type, | |
9acbedc0 | 1099 | int regnum, |
2ed3c037 | 1100 | struct frame_id frame_id); |
9acbedc0 | 1101 | |
b56d6f31 | 1102 | extern void read_frame_register_value (struct value *value, |
bd2b40ac | 1103 | frame_info_ptr frame); |
b56d6f31 | 1104 | |
f23631e4 | 1105 | extern struct value *value_from_register (struct type *type, int regnum, |
bd2b40ac | 1106 | frame_info_ptr frame); |
c906108c | 1107 | |
2ed3c037 | 1108 | extern CORE_ADDR address_from_register (int regnum, |
bd2b40ac | 1109 | frame_info_ptr frame); |
0b2b0195 | 1110 | |
9df2fbc4 PM |
1111 | extern struct value *value_of_variable (struct symbol *var, |
1112 | const struct block *b); | |
c906108c | 1113 | |
270140bd TT |
1114 | extern struct value *address_of_variable (struct symbol *var, |
1115 | const struct block *b); | |
61212c0f | 1116 | |
bd2b40ac | 1117 | extern struct value *value_of_register (int regnum, frame_info_ptr frame); |
c906108c | 1118 | |
bd2b40ac | 1119 | struct value *value_of_register_lazy (frame_info_ptr frame, int regnum); |
9214ee5f | 1120 | |
0b31a4bc TT |
1121 | /* Return the symbol's reading requirement. */ |
1122 | ||
1123 | extern enum symbol_needs_kind symbol_read_needs (struct symbol *); | |
1124 | ||
1125 | /* Return true if the symbol needs a frame. This is a wrapper for | |
1126 | symbol_read_needs that simply checks for SYMBOL_NEEDS_FRAME. */ | |
1127 | ||
a14ed312 | 1128 | extern int symbol_read_needs_frame (struct symbol *); |
c906108c | 1129 | |
f23631e4 | 1130 | extern struct value *read_var_value (struct symbol *var, |
63e43d3a | 1131 | const struct block *var_block, |
bd2b40ac | 1132 | frame_info_ptr frame); |
c906108c | 1133 | |
f23631e4 | 1134 | extern struct value *allocate_repeat_value (struct type *type, int count); |
c906108c | 1135 | |
f23631e4 | 1136 | extern struct value *value_mark (void); |
c906108c | 1137 | |
4bf7b526 | 1138 | extern void value_free_to_mark (const struct value *mark); |
c906108c | 1139 | |
eb115069 TT |
1140 | /* A helper class that uses value_mark at construction time and calls |
1141 | value_free_to_mark in the destructor. This is used to clear out | |
1142 | temporary values created during the lifetime of this object. */ | |
1143 | class scoped_value_mark | |
1144 | { | |
1145 | public: | |
1146 | ||
1147 | scoped_value_mark () | |
1148 | : m_value (value_mark ()) | |
1149 | { | |
1150 | } | |
1151 | ||
1152 | ~scoped_value_mark () | |
1153 | { | |
0cf08227 TT |
1154 | free_to_mark (); |
1155 | } | |
1156 | ||
54f70bc1 TT |
1157 | scoped_value_mark (scoped_value_mark &&other) = default; |
1158 | ||
1159 | DISABLE_COPY_AND_ASSIGN (scoped_value_mark); | |
1160 | ||
0cf08227 TT |
1161 | /* Free the values currently on the value stack. */ |
1162 | void free_to_mark () | |
1163 | { | |
1164 | if (m_value != NULL) | |
1165 | { | |
1166 | value_free_to_mark (m_value); | |
1167 | m_value = NULL; | |
1168 | } | |
eb115069 TT |
1169 | } |
1170 | ||
1171 | private: | |
1172 | ||
1173 | const struct value *m_value; | |
1174 | }; | |
1175 | ||
e3a3797e | 1176 | extern struct value *value_cstring (const char *ptr, ssize_t len, |
3b7538c0 | 1177 | struct type *char_type); |
7cc3f8e2 | 1178 | extern struct value *value_string (const char *ptr, ssize_t len, |
3b7538c0 | 1179 | struct type *char_type); |
c906108c | 1180 | |
f23631e4 | 1181 | extern struct value *value_array (int lowbound, int highbound, |
89f5065b | 1182 | struct value **elemvec); |
c906108c | 1183 | |
f23631e4 | 1184 | extern struct value *value_concat (struct value *arg1, struct value *arg2); |
c906108c | 1185 | |
f23631e4 AC |
1186 | extern struct value *value_binop (struct value *arg1, struct value *arg2, |
1187 | enum exp_opcode op); | |
c906108c | 1188 | |
2497b498 | 1189 | extern struct value *value_ptradd (struct value *arg1, LONGEST arg2); |
89eef114 UW |
1190 | |
1191 | extern LONGEST value_ptrdiff (struct value *arg1, struct value *arg2); | |
c906108c | 1192 | |
00db9531 SM |
1193 | /* Return true if VAL does not live in target memory, but should in order |
1194 | to operate on it. Otherwise return false. */ | |
1195 | ||
1196 | extern bool value_must_coerce_to_target (struct value *arg1); | |
63092375 DJ |
1197 | |
1198 | extern struct value *value_coerce_to_target (struct value *arg1); | |
1199 | ||
f23631e4 | 1200 | extern struct value *value_coerce_array (struct value *arg1); |
c906108c | 1201 | |
f23631e4 | 1202 | extern struct value *value_coerce_function (struct value *arg1); |
c906108c | 1203 | |
f23631e4 | 1204 | extern struct value *value_ind (struct value *arg1); |
c906108c | 1205 | |
f23631e4 | 1206 | extern struct value *value_addr (struct value *arg1); |
c906108c | 1207 | |
a65cfae5 | 1208 | extern struct value *value_ref (struct value *arg1, enum type_code refcode); |
fb933624 | 1209 | |
89f5065b AC |
1210 | extern struct value *value_assign (struct value *toval, |
1211 | struct value *fromval); | |
c906108c | 1212 | |
36e9969c NS |
1213 | extern struct value *value_pos (struct value *arg1); |
1214 | ||
f23631e4 | 1215 | extern struct value *value_neg (struct value *arg1); |
c906108c | 1216 | |
f23631e4 | 1217 | extern struct value *value_complement (struct value *arg1); |
c906108c | 1218 | |
f23631e4 | 1219 | extern struct value *value_struct_elt (struct value **argp, |
158cc4fe | 1220 | gdb::optional<gdb::array_view <value *>> args, |
714f19d5 TT |
1221 | const char *name, int *static_memfuncp, |
1222 | const char *err); | |
c906108c | 1223 | |
b5b08fb4 SC |
1224 | extern struct value *value_struct_elt_bitpos (struct value **argp, |
1225 | int bitpos, | |
1226 | struct type *field_type, | |
1227 | const char *err); | |
1228 | ||
79c2c32d | 1229 | extern struct value *value_aggregate_elt (struct type *curtype, |
c848d642 | 1230 | const char *name, |
072bba3b | 1231 | struct type *expect_type, |
0d5de010 DJ |
1232 | int want_address, |
1233 | enum noside noside); | |
c906108c | 1234 | |
f23631e4 | 1235 | extern struct value *value_static_field (struct type *type, int fieldno); |
c906108c | 1236 | |
4c3376c8 SW |
1237 | enum oload_search_type { NON_METHOD, METHOD, BOTH }; |
1238 | ||
6b1747cd | 1239 | extern int find_overload_match (gdb::array_view<value *> args, |
4c3376c8 | 1240 | const char *name, |
28c64fc2 | 1241 | enum oload_search_type method, |
7f8c9282 | 1242 | struct value **objp, struct symbol *fsym, |
f23631e4 | 1243 | struct value **valp, struct symbol **symp, |
e66d4446 SC |
1244 | int *staticp, const int no_adl, |
1245 | enum noside noside); | |
c906108c | 1246 | |
f23631e4 | 1247 | extern struct value *value_field (struct value *arg1, int fieldno); |
c906108c | 1248 | |
6b850546 | 1249 | extern struct type *value_rtti_indirect_type (struct value *, int *, LONGEST *, |
dfcee124 | 1250 | int *); |
c906108c | 1251 | |
f23631e4 AC |
1252 | extern struct value *value_full_object (struct value *, struct type *, int, |
1253 | int, int); | |
c906108c | 1254 | |
b1af9e97 | 1255 | extern struct value *value_cast_pointers (struct type *, struct value *, int); |
fb933624 | 1256 | |
f23631e4 | 1257 | extern struct value *value_cast (struct type *type, struct value *arg2); |
c906108c | 1258 | |
4e8f195d TT |
1259 | extern struct value *value_reinterpret_cast (struct type *type, |
1260 | struct value *arg); | |
1261 | ||
1262 | extern struct value *value_dynamic_cast (struct type *type, struct value *arg); | |
1263 | ||
18a46dbe | 1264 | extern struct value *value_one (struct type *type); |
301f0ecf | 1265 | |
f23631e4 | 1266 | extern struct value *value_repeat (struct value *arg1, int count); |
c906108c | 1267 | |
2497b498 | 1268 | extern struct value *value_subscript (struct value *array, LONGEST index); |
c906108c | 1269 | |
afc05acb UW |
1270 | extern struct value *value_bitstring_subscript (struct type *type, |
1271 | struct value *bitstring, | |
2497b498 | 1272 | LONGEST index); |
afc05acb | 1273 | |
5fe830e4 AC |
1274 | extern struct value *register_value_being_returned (struct type *valtype, |
1275 | struct regcache *retbuf); | |
c906108c | 1276 | |
fbb06eb1 | 1277 | extern int value_in (struct value *element, struct value *set); |
c906108c | 1278 | |
fc1a4b47 | 1279 | extern int value_bit_index (struct type *type, const gdb_byte *addr, |
c84141d6 | 1280 | int index); |
c906108c | 1281 | |
bbfdfe1c DM |
1282 | extern enum return_value_convention |
1283 | struct_return_convention (struct gdbarch *gdbarch, struct value *function, | |
1284 | struct type *value_type); | |
1285 | ||
d80b854b | 1286 | extern int using_struct_return (struct gdbarch *gdbarch, |
6a3a010b | 1287 | struct value *function, |
c055b101 | 1288 | struct type *value_type); |
c906108c | 1289 | |
efd7ff14 TT |
1290 | /* Evaluate the expression EXP. If set, EXPECT_TYPE is passed to the |
1291 | outermost operation's evaluation. This is ignored by most | |
1292 | operations, but may be used, e.g., to determine the type of an | |
1293 | otherwise untyped symbol. The caller should not assume that the | |
1294 | returned value has this type. */ | |
1295 | ||
1296 | extern struct value *evaluate_expression (struct expression *exp, | |
1297 | struct type *expect_type = nullptr); | |
c906108c | 1298 | |
f23631e4 | 1299 | extern struct value *evaluate_type (struct expression *exp); |
c906108c | 1300 | |
ced9779b JB |
1301 | extern value *evaluate_var_value (enum noside noside, const block *blk, |
1302 | symbol *var); | |
1303 | ||
1304 | extern value *evaluate_var_msym_value (enum noside noside, | |
1305 | struct objfile *objfile, | |
1306 | minimal_symbol *msymbol); | |
1307 | ||
413403fc | 1308 | namespace expr { class operation; }; |
1eaebe02 | 1309 | extern void fetch_subexp_value (struct expression *exp, |
413403fc | 1310 | expr::operation *op, |
0cf6dd15 | 1311 | struct value **valp, struct value **resultp, |
a6535de1 | 1312 | std::vector<value_ref_ptr> *val_chain, |
2e362716 | 1313 | bool preserve_errors); |
0cf6dd15 | 1314 | |
bbc13ae3 | 1315 | extern struct value *parse_and_eval (const char *exp); |
c906108c | 1316 | |
bbc13ae3 | 1317 | extern struct value *parse_to_comma_and_eval (const char **expp); |
c906108c | 1318 | |
f5756acc | 1319 | extern struct type *parse_and_eval_type (const char *p, int length); |
c906108c | 1320 | |
bbc13ae3 | 1321 | extern CORE_ADDR parse_and_eval_address (const char *exp); |
c906108c | 1322 | |
a1b8c4cc | 1323 | extern LONGEST parse_and_eval_long (const char *exp); |
bb518678 | 1324 | |
4066e646 UW |
1325 | extern void unop_promote (const struct language_defn *language, |
1326 | struct gdbarch *gdbarch, | |
1327 | struct value **arg1); | |
1328 | ||
1329 | extern void binop_promote (const struct language_defn *language, | |
1330 | struct gdbarch *gdbarch, | |
1331 | struct value **arg1, struct value **arg2); | |
1332 | ||
f23631e4 | 1333 | extern struct value *access_value_history (int num); |
c906108c | 1334 | |
30a87e90 AB |
1335 | /* Return the number of items in the value history. */ |
1336 | ||
1337 | extern ULONGEST value_history_count (); | |
1338 | ||
78267919 UW |
1339 | extern struct value *value_of_internalvar (struct gdbarch *gdbarch, |
1340 | struct internalvar *var); | |
c906108c | 1341 | |
4fa62494 UW |
1342 | extern int get_internalvar_integer (struct internalvar *var, LONGEST *l); |
1343 | ||
f23631e4 | 1344 | extern void set_internalvar (struct internalvar *var, struct value *val); |
c906108c | 1345 | |
4fa62494 UW |
1346 | extern void set_internalvar_integer (struct internalvar *var, LONGEST l); |
1347 | ||
78267919 UW |
1348 | extern void set_internalvar_string (struct internalvar *var, |
1349 | const char *string); | |
1350 | ||
4fa62494 UW |
1351 | extern void clear_internalvar (struct internalvar *var); |
1352 | ||
a14ed312 | 1353 | extern void set_internalvar_component (struct internalvar *var, |
6b850546 DT |
1354 | LONGEST offset, |
1355 | LONGEST bitpos, LONGEST bitsize, | |
f23631e4 | 1356 | struct value *newvalue); |
c906108c | 1357 | |
bc3b79fd | 1358 | extern struct internalvar *lookup_only_internalvar (const char *name); |
c4a3d09a | 1359 | |
bc3b79fd | 1360 | extern struct internalvar *create_internalvar (const char *name); |
c4a3d09a | 1361 | |
eb3ff9a5 PA |
1362 | extern void complete_internalvar (completion_tracker &tracker, |
1363 | const char *name); | |
d55637df | 1364 | |
22d2b532 SDJ |
1365 | /* An internalvar can be dynamically computed by supplying a vector of |
1366 | function pointers to perform various operations. */ | |
1367 | ||
1368 | struct internalvar_funcs | |
1369 | { | |
1370 | /* Compute the value of the variable. The DATA argument passed to | |
1371 | the function is the same argument that was passed to | |
1372 | `create_internalvar_type_lazy'. */ | |
1373 | ||
1374 | struct value *(*make_value) (struct gdbarch *arch, | |
1375 | struct internalvar *var, | |
1376 | void *data); | |
1377 | ||
1378 | /* Update the agent expression EXPR with bytecode to compute the | |
1379 | value. VALUE is the agent value we are updating. The DATA | |
1380 | argument passed to this function is the same argument that was | |
1381 | passed to `create_internalvar_type_lazy'. If this pointer is | |
1382 | NULL, then the internalvar cannot be compiled to an agent | |
1383 | expression. */ | |
1384 | ||
1385 | void (*compile_to_ax) (struct internalvar *var, | |
1386 | struct agent_expr *expr, | |
1387 | struct axs_value *value, | |
1388 | void *data); | |
22d2b532 SDJ |
1389 | }; |
1390 | ||
73033f12 SDJ |
1391 | extern struct internalvar *create_internalvar_type_lazy (const char *name, |
1392 | const struct internalvar_funcs *funcs, | |
1393 | void *data); | |
22d2b532 SDJ |
1394 | |
1395 | /* Compile an internal variable to an agent expression. VAR is the | |
1396 | variable to compile; EXPR and VALUE are the agent expression we are | |
1397 | updating. This will return 0 if there is no known way to compile | |
1398 | VAR, and 1 if VAR was successfully compiled. It may also throw an | |
1399 | exception on error. */ | |
1400 | ||
1401 | extern int compile_internalvar_to_ax (struct internalvar *var, | |
1402 | struct agent_expr *expr, | |
1403 | struct axs_value *value); | |
4aa995e1 | 1404 | |
bc3b79fd | 1405 | extern struct internalvar *lookup_internalvar (const char *name); |
c906108c | 1406 | |
f23631e4 | 1407 | extern int value_equal (struct value *arg1, struct value *arg2); |
c906108c | 1408 | |
218d2fc6 TJB |
1409 | extern int value_equal_contents (struct value *arg1, struct value *arg2); |
1410 | ||
f23631e4 | 1411 | extern int value_less (struct value *arg1, struct value *arg2); |
c906108c | 1412 | |
7ebaa5f7 TT |
1413 | /* Simulate the C operator ! -- return true if ARG1 contains zero. */ |
1414 | extern bool value_logical_not (struct value *arg1); | |
1415 | ||
1416 | /* Returns true if the value VAL represents a true value. */ | |
1417 | static inline bool | |
1418 | value_true (struct value *val) | |
1419 | { | |
1420 | return !value_logical_not (val); | |
1421 | } | |
c906108c SS |
1422 | |
1423 | /* C++ */ | |
1424 | ||
85bc8cb7 JK |
1425 | extern struct value *value_of_this (const struct language_defn *lang); |
1426 | ||
1427 | extern struct value *value_of_this_silent (const struct language_defn *lang); | |
c906108c | 1428 | |
f23631e4 AC |
1429 | extern struct value *value_x_binop (struct value *arg1, struct value *arg2, |
1430 | enum exp_opcode op, | |
1431 | enum exp_opcode otherop, | |
1432 | enum noside noside); | |
c906108c | 1433 | |
f23631e4 AC |
1434 | extern struct value *value_x_unop (struct value *arg1, enum exp_opcode op, |
1435 | enum noside noside); | |
c906108c | 1436 | |
89f5065b | 1437 | extern struct value *value_fn_field (struct value **arg1p, struct fn_field *f, |
6b850546 | 1438 | int j, struct type *type, LONGEST offset); |
c906108c | 1439 | |
be636754 PA |
1440 | extern int binop_types_user_defined_p (enum exp_opcode op, |
1441 | struct type *type1, | |
1442 | struct type *type2); | |
1443 | ||
f23631e4 AC |
1444 | extern int binop_user_defined_p (enum exp_opcode op, struct value *arg1, |
1445 | struct value *arg2); | |
c906108c | 1446 | |
f23631e4 | 1447 | extern int unop_user_defined_p (enum exp_opcode op, struct value *arg1); |
c906108c | 1448 | |
d8228535 | 1449 | extern int destructor_name_p (const char *name, struct type *type); |
c906108c | 1450 | |
22bc8444 | 1451 | extern value_ref_ptr release_value (struct value *val); |
e848a8a5 | 1452 | |
50810684 | 1453 | extern void modify_field (struct type *type, gdb_byte *addr, |
6b850546 | 1454 | LONGEST fieldval, LONGEST bitpos, LONGEST bitsize); |
c906108c | 1455 | |
0d5cff50 | 1456 | extern void type_print (struct type *type, const char *varstring, |
89f5065b | 1457 | struct ui_file *stream, int show); |
c906108c | 1458 | |
2f408ecb | 1459 | extern std::string type_to_string (struct type *type); |
ae6a3a4c | 1460 | |
fc1a4b47 AC |
1461 | extern gdb_byte *baseclass_addr (struct type *type, int index, |
1462 | gdb_byte *valaddr, | |
8929e59d | 1463 | struct value **valuep, int *errp); |
c906108c | 1464 | |
89f5065b | 1465 | extern void print_longest (struct ui_file *stream, int format, |
d9fcf2fb | 1466 | int use_local, LONGEST val); |
c906108c | 1467 | |
fc1a4b47 | 1468 | extern void print_floating (const gdb_byte *valaddr, struct type *type, |
89f5065b | 1469 | struct ui_file *stream); |
c906108c | 1470 | |
8e069a98 TT |
1471 | extern void value_print (struct value *val, struct ui_file *stream, |
1472 | const struct value_print_options *options); | |
c906108c | 1473 | |
a6535de1 TT |
1474 | /* Release values from the value chain and return them. Values |
1475 | created after MARK are released. If MARK is nullptr, or if MARK is | |
1476 | not found on the value chain, then all values are released. Values | |
1477 | are returned in reverse order of creation; that is, newest | |
1478 | first. */ | |
1479 | ||
1480 | extern std::vector<value_ref_ptr> value_release_to_mark | |
1481 | (const struct value *mark); | |
c906108c | 1482 | |
a1f5dd1b TT |
1483 | extern void common_val_print (struct value *val, |
1484 | struct ui_file *stream, int recurse, | |
1485 | const struct value_print_options *options, | |
1486 | const struct language_defn *language); | |
806048c6 | 1487 | |
09ca9e2e TT |
1488 | extern int val_print_string (struct type *elttype, const char *encoding, |
1489 | CORE_ADDR addr, int len, | |
79a45b7d TT |
1490 | struct ui_file *stream, |
1491 | const struct value_print_options *options); | |
c906108c | 1492 | |
aad95b57 TT |
1493 | extern void print_variable_and_value (const char *name, |
1494 | struct symbol *var, | |
bd2b40ac | 1495 | frame_info_ptr frame, |
aad95b57 TT |
1496 | struct ui_file *stream, |
1497 | int indent); | |
c906108c | 1498 | |
89f5065b AC |
1499 | extern void typedef_print (struct type *type, struct symbol *news, |
1500 | struct ui_file *stream); | |
c906108c | 1501 | |
baf20f76 | 1502 | extern const char *internalvar_name (const struct internalvar *var); |
c906108c | 1503 | |
ae5a43e0 | 1504 | extern void preserve_values (struct objfile *); |
c906108c SS |
1505 | |
1506 | /* From values.c */ | |
1507 | ||
4c082a81 SC |
1508 | extern struct value *make_cv_value (int, int, struct value *); |
1509 | ||
c906108c SS |
1510 | /* From valops.c */ |
1511 | ||
f23631e4 | 1512 | extern struct value *varying_to_slice (struct value *); |
c906108c | 1513 | |
f23631e4 | 1514 | extern struct value *value_slice (struct value *, int, int); |
c906108c | 1515 | |
6b4a335b TT |
1516 | /* Create a complex number. The type is the complex type; the values |
1517 | are cast to the underlying scalar type before the complex number is | |
1518 | created. */ | |
1519 | ||
f23631e4 AC |
1520 | extern struct value *value_literal_complex (struct value *, struct value *, |
1521 | struct type *); | |
c906108c | 1522 | |
4c99290d TT |
1523 | /* Return the real part of a complex value. */ |
1524 | ||
1525 | extern struct value *value_real_part (struct value *value); | |
1526 | ||
1527 | /* Return the imaginary part of a complex value. */ | |
1528 | ||
1529 | extern struct value *value_imaginary_part (struct value *value); | |
1530 | ||
3e3b026f UW |
1531 | extern struct value *find_function_in_inferior (const char *, |
1532 | struct objfile **); | |
c906108c | 1533 | |
f23631e4 | 1534 | extern struct value *value_allocate_space_in_inferior (int); |
c906108c | 1535 | |
bc3b79fd TJB |
1536 | /* User function handler. */ |
1537 | ||
d452c4bc UW |
1538 | typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch, |
1539 | const struct language_defn *language, | |
1540 | void *cookie, | |
bc3b79fd TJB |
1541 | int argc, |
1542 | struct value **argv); | |
1543 | ||
1a6d41c6 TT |
1544 | /* Add a new internal function. NAME is the name of the function; DOC |
1545 | is a documentation string describing the function. HANDLER is | |
1546 | called when the function is invoked. COOKIE is an arbitrary | |
1547 | pointer which is passed to HANDLER and is intended for "user | |
1548 | data". */ | |
1549 | ||
1550 | extern void add_internal_function (const char *name, const char *doc, | |
1551 | internal_function_fn handler, | |
1552 | void *cookie); | |
1553 | ||
1554 | /* This overload takes an allocated documentation string. */ | |
1555 | ||
3ea16160 | 1556 | extern void add_internal_function (gdb::unique_xmalloc_ptr<char> &&name, |
1a6d41c6 TT |
1557 | gdb::unique_xmalloc_ptr<char> &&doc, |
1558 | internal_function_fn handler, | |
1559 | void *cookie); | |
bc3b79fd | 1560 | |
d452c4bc UW |
1561 | struct value *call_internal_function (struct gdbarch *gdbarch, |
1562 | const struct language_defn *language, | |
1563 | struct value *function, | |
bc3b79fd TJB |
1564 | int argc, struct value **argv); |
1565 | ||
91f87213 | 1566 | const char *value_internal_function_name (struct value *); |
bc3b79fd | 1567 | |
9d1447e0 SDJ |
1568 | /* Destroy the values currently allocated. This is called when GDB is |
1569 | exiting (e.g., on quit_force). */ | |
1570 | extern void finalize_values (); | |
1571 | ||
b49180ac TT |
1572 | /* Convert VALUE to a gdb_mpq. The caller must ensure that VALUE is |
1573 | of floating-point, fixed-point, or integer type. */ | |
1574 | extern gdb_mpq value_to_gdb_mpq (struct value *value); | |
1575 | ||
a0c07915 AB |
1576 | /* While an instance of this class is live, and array values that are |
1577 | created, that are larger than max_value_size, will be restricted in size | |
1578 | to a particular number of elements. */ | |
1579 | ||
1580 | struct scoped_array_length_limiting | |
1581 | { | |
1582 | /* Limit any large array values to only contain ELEMENTS elements. */ | |
1583 | scoped_array_length_limiting (int elements); | |
1584 | ||
1585 | /* Restore the previous array value limit. */ | |
1586 | ~scoped_array_length_limiting (); | |
1587 | ||
1588 | private: | |
1589 | /* Used to hold the previous array value element limit. */ | |
1590 | gdb::optional<int> m_old_value; | |
1591 | }; | |
1592 | ||
c5aa993b | 1593 | #endif /* !defined (VALUE_H) */ |