Move struct value to value.h
[binutils-gdb.git] / gdb / value.h
1 /* Definitions for values of C expressions, for GDB.
2
3 Copyright (C) 1986-2023 Free Software Foundation, Inc.
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
9 the Free Software Foundation; either version 3 of the License, or
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
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #if !defined (VALUE_H)
21 #define VALUE_H 1
22
23 #include "frame.h" /* For struct frame_id. */
24 #include "extension.h"
25 #include "gdbsupport/gdb_ref_ptr.h"
26 #include "gmp-utils.h"
27
28 struct block;
29 struct expression;
30 struct regcache;
31 struct symbol;
32 struct type;
33 struct ui_file;
34 struct language_defn;
35 struct value_print_options;
36
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
85 extern bool overload_resolution;
86
87 /* Defines an [OFFSET, OFFSET + LENGTH) range. */
88
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 };
113
114 /* Increase VAL's reference count. */
115
116 extern void value_incref (struct value *val);
117
118 /* Decrease VAL's reference count. When the reference count drops to
119 0, VAL will be freed. */
120
121 extern void value_decref (struct value *val);
122
123 /* A policy class to interface gdb::ref_ptr with struct value. */
124
125 struct value_ref_policy
126 {
127 static void incref (struct value *ptr)
128 {
129 value_incref (ptr);
130 }
131
132 static void decref (struct value *ptr)
133 {
134 value_decref (ptr);
135 }
136 };
137
138 /* A gdb:;ref_ptr pointer to a struct value. */
139
140 typedef gdb::ref_ptr<struct value, value_ref_policy> value_ref_ptr;
141
142 /* Note that the fields in this structure are arranged to save a bit
143 of memory. */
144
145 struct value
146 {
147 explicit value (struct type *type_)
148 : m_modifiable (1),
149 m_lazy (1),
150 m_initialized (1),
151 m_stack (0),
152 m_is_zero (false),
153 m_in_history (false),
154 m_type (type_),
155 m_enclosing_type (type_)
156 {
157 }
158
159 ~value ();
160
161 DISABLE_COPY_AND_ASSIGN (value);
162
163 /* Type of value; either not an lval, or one of the various
164 different possible kinds of lval. */
165 enum lval_type m_lval = not_lval;
166
167 /* Is it modifiable? Only relevant if lval != not_lval. */
168 unsigned int m_modifiable : 1;
169
170 /* If zero, contents of this value are in the contents field. If
171 nonzero, contents are in inferior. If the lval field is lval_memory,
172 the contents are in inferior memory at location.address plus offset.
173 The lval field may also be lval_register.
174
175 WARNING: This field is used by the code which handles watchpoints
176 (see breakpoint.c) to decide whether a particular value can be
177 watched by hardware watchpoints. If the lazy flag is set for
178 some member of a value chain, it is assumed that this member of
179 the chain doesn't need to be watched as part of watching the
180 value itself. This is how GDB avoids watching the entire struct
181 or array when the user wants to watch a single struct member or
182 array element. If you ever change the way lazy flag is set and
183 reset, be sure to consider this use as well! */
184 unsigned int m_lazy : 1;
185
186 /* If value is a variable, is it initialized or not. */
187 unsigned int m_initialized : 1;
188
189 /* If value is from the stack. If this is set, read_stack will be
190 used instead of read_memory to enable extra caching. */
191 unsigned int m_stack : 1;
192
193 /* True if this is a zero value, created by 'value_zero'; false
194 otherwise. */
195 bool m_is_zero : 1;
196
197 /* True if this a value recorded in value history; false otherwise. */
198 bool m_in_history : 1;
199
200 /* Location of value (if lval). */
201 union
202 {
203 /* If lval == lval_memory, this is the address in the inferior */
204 CORE_ADDR address;
205
206 /*If lval == lval_register, the value is from a register. */
207 struct
208 {
209 /* Register number. */
210 int regnum;
211 /* Frame ID of "next" frame to which a register value is relative.
212 If the register value is found relative to frame F, then the
213 frame id of F->next will be stored in next_frame_id. */
214 struct frame_id next_frame_id;
215 } reg;
216
217 /* Pointer to internal variable. */
218 struct internalvar *internalvar;
219
220 /* Pointer to xmethod worker. */
221 struct xmethod_worker *xm_worker;
222
223 /* If lval == lval_computed, this is a set of function pointers
224 to use to access and describe the value, and a closure pointer
225 for them to use. */
226 struct
227 {
228 /* Functions to call. */
229 const struct lval_funcs *funcs;
230
231 /* Closure for those functions to use. */
232 void *closure;
233 } computed;
234 } m_location {};
235
236 /* Describes offset of a value within lval of a structure in target
237 addressable memory units. Note also the member embedded_offset
238 below. */
239 LONGEST m_offset = 0;
240
241 /* Only used for bitfields; number of bits contained in them. */
242 LONGEST m_bitsize = 0;
243
244 /* Only used for bitfields; position of start of field. For
245 little-endian targets, it is the position of the LSB. For
246 big-endian targets, it is the position of the MSB. */
247 LONGEST m_bitpos = 0;
248
249 /* The number of references to this value. When a value is created,
250 the value chain holds a reference, so REFERENCE_COUNT is 1. If
251 release_value is called, this value is removed from the chain but
252 the caller of release_value now has a reference to this value.
253 The caller must arrange for a call to value_free later. */
254 int m_reference_count = 1;
255
256 /* Only used for bitfields; the containing value. This allows a
257 single read from the target when displaying multiple
258 bitfields. */
259 value_ref_ptr m_parent;
260
261 /* Type of the value. */
262 struct type *m_type;
263
264 /* If a value represents a C++ object, then the `type' field gives
265 the object's compile-time type. If the object actually belongs
266 to some class derived from `type', perhaps with other base
267 classes and additional members, then `type' is just a subobject
268 of the real thing, and the full object is probably larger than
269 `type' would suggest.
270
271 If `type' is a dynamic class (i.e. one with a vtable), then GDB
272 can actually determine the object's run-time type by looking at
273 the run-time type information in the vtable. When this
274 information is available, we may elect to read in the entire
275 object, for several reasons:
276
277 - When printing the value, the user would probably rather see the
278 full object, not just the limited portion apparent from the
279 compile-time type.
280
281 - If `type' has virtual base classes, then even printing `type'
282 alone may require reaching outside the `type' portion of the
283 object to wherever the virtual base class has been stored.
284
285 When we store the entire object, `enclosing_type' is the run-time
286 type -- the complete object -- and `embedded_offset' is the
287 offset of `type' within that larger type, in target addressable memory
288 units. The value_contents() macro takes `embedded_offset' into account,
289 so most GDB code continues to see the `type' portion of the value, just
290 as the inferior would.
291
292 If `type' is a pointer to an object, then `enclosing_type' is a
293 pointer to the object's run-time type, and `pointed_to_offset' is
294 the offset in target addressable memory units from the full object
295 to the pointed-to object -- that is, the value `embedded_offset' would
296 have if we followed the pointer and fetched the complete object.
297 (I don't really see the point. Why not just determine the
298 run-time type when you indirect, and avoid the special case? The
299 contents don't matter until you indirect anyway.)
300
301 If we're not doing anything fancy, `enclosing_type' is equal to
302 `type', and `embedded_offset' is zero, so everything works
303 normally. */
304 struct type *m_enclosing_type;
305 LONGEST m_embedded_offset = 0;
306 LONGEST m_pointed_to_offset = 0;
307
308 /* Actual contents of the value. Target byte-order.
309
310 May be nullptr if the value is lazy or is entirely optimized out.
311 Guaranteed to be non-nullptr otherwise. */
312 gdb::unique_xmalloc_ptr<gdb_byte> m_contents;
313
314 /* Unavailable ranges in CONTENTS. We mark unavailable ranges,
315 rather than available, since the common and default case is for a
316 value to be available. This is filled in at value read time.
317 The unavailable ranges are tracked in bits. Note that a contents
318 bit that has been optimized out doesn't really exist in the
319 program, so it can't be marked unavailable either. */
320 std::vector<range> m_unavailable;
321
322 /* Likewise, but for optimized out contents (a chunk of the value of
323 a variable that does not actually exist in the program). If LVAL
324 is lval_register, this is a register ($pc, $sp, etc., never a
325 program variable) that has not been saved in the frame. Not
326 saved registers and optimized-out program variables values are
327 treated pretty much the same, except not-saved registers have a
328 different string representation and related error strings. */
329 std::vector<range> m_optimized_out;
330
331 /* This is only non-zero for values of TYPE_CODE_ARRAY and if the size of
332 the array in inferior memory is greater than max_value_size. If these
333 conditions are met then, when the value is loaded from the inferior
334 GDB will only load a portion of the array into memory, and
335 limited_length will be set to indicate the length in octets that were
336 loaded from the inferior. */
337 ULONGEST m_limited_length = 0;
338 };
339
340 /* Type of the value. */
341
342 extern struct type *value_type (const struct value *);
343
344 /* Return the gdbarch associated with the value. */
345
346 extern struct gdbarch *get_value_arch (const struct value *value);
347
348 /* This is being used to change the type of an existing value, that
349 code should instead be creating a new value with the changed type
350 (but possibly shared content). */
351
352 extern void deprecated_set_value_type (struct value *value,
353 struct type *type);
354
355 /* Only used for bitfields; number of bits contained in them. */
356
357 extern LONGEST value_bitsize (const struct value *);
358 extern void set_value_bitsize (struct value *, LONGEST bit);
359
360 /* Only used for bitfields; position of start of field. For
361 little-endian targets, it is the position of the LSB. For
362 big-endian targets, it is the position of the MSB. */
363
364 extern LONGEST value_bitpos (const struct value *);
365 extern void set_value_bitpos (struct value *, LONGEST bit);
366
367 /* Only used for bitfields; the containing value. This allows a
368 single read from the target when displaying multiple
369 bitfields. */
370
371 struct value *value_parent (const struct value *);
372 extern void set_value_parent (struct value *value, struct value *parent);
373
374 /* Describes offset of a value within lval of a structure in bytes.
375 If lval == lval_memory, this is an offset to the address. If lval
376 == lval_register, this is a further offset from location.address
377 within the registers structure. Note also the member
378 embedded_offset below. */
379
380 extern LONGEST value_offset (const struct value *);
381 extern void set_value_offset (struct value *, LONGEST offset);
382
383 /* The comment from "struct value" reads: ``Is it modifiable? Only
384 relevant if lval != not_lval.''. Shouldn't the value instead be
385 not_lval and be done with it? */
386
387 extern int deprecated_value_modifiable (const struct value *value);
388
389 /* If a value represents a C++ object, then the `type' field gives the
390 object's compile-time type. If the object actually belongs to some
391 class derived from `type', perhaps with other base classes and
392 additional members, then `type' is just a subobject of the real
393 thing, and the full object is probably larger than `type' would
394 suggest.
395
396 If `type' is a dynamic class (i.e. one with a vtable), then GDB can
397 actually determine the object's run-time type by looking at the
398 run-time type information in the vtable. When this information is
399 available, we may elect to read in the entire object, for several
400 reasons:
401
402 - When printing the value, the user would probably rather see the
403 full object, not just the limited portion apparent from the
404 compile-time type.
405
406 - If `type' has virtual base classes, then even printing `type'
407 alone may require reaching outside the `type' portion of the
408 object to wherever the virtual base class has been stored.
409
410 When we store the entire object, `enclosing_type' is the run-time
411 type -- the complete object -- and `embedded_offset' is the offset
412 of `type' within that larger type, in bytes. The value_contents()
413 macro takes `embedded_offset' into account, so most GDB code
414 continues to see the `type' portion of the value, just as the
415 inferior would.
416
417 If `type' is a pointer to an object, then `enclosing_type' is a
418 pointer to the object's run-time type, and `pointed_to_offset' is
419 the offset in bytes from the full object to the pointed-to object
420 -- that is, the value `embedded_offset' would have if we followed
421 the pointer and fetched the complete object. (I don't really see
422 the point. Why not just determine the run-time type when you
423 indirect, and avoid the special case? The contents don't matter
424 until you indirect anyway.)
425
426 If we're not doing anything fancy, `enclosing_type' is equal to
427 `type', and `embedded_offset' is zero, so everything works
428 normally. */
429
430 extern struct type *value_enclosing_type (const struct value *);
431 extern void set_value_enclosing_type (struct value *val,
432 struct type *new_type);
433
434 /* Returns value_type or value_enclosing_type depending on
435 value_print_options.objectprint.
436
437 If RESOLVE_SIMPLE_TYPES is 0 the enclosing type will be resolved
438 only for pointers and references, else it will be returned
439 for all the types (e.g. structures). This option is useful
440 to prevent retrieving enclosing type for the base classes fields.
441
442 REAL_TYPE_FOUND is used to inform whether the real type was found
443 (or just static type was used). The NULL may be passed if it is not
444 necessary. */
445
446 extern struct type *value_actual_type (struct value *value,
447 int resolve_simple_types,
448 int *real_type_found);
449
450 extern LONGEST value_pointed_to_offset (const struct value *value);
451 extern void set_value_pointed_to_offset (struct value *value, LONGEST val);
452 extern LONGEST value_embedded_offset (const struct value *value);
453 extern void set_value_embedded_offset (struct value *value, LONGEST val);
454
455 /* For lval_computed values, this structure holds functions used to
456 retrieve and set the value (or portions of the value).
457
458 For each function, 'V' is the 'this' pointer: an lval_funcs
459 function F may always assume that the V it receives is an
460 lval_computed value, and has F in the appropriate slot of its
461 lval_funcs structure. */
462
463 struct lval_funcs
464 {
465 /* Fill in VALUE's contents. This is used to "un-lazy" values. If
466 a problem arises in obtaining VALUE's bits, this function should
467 call 'error'. If it is NULL value_fetch_lazy on "un-lazy"
468 non-optimized-out value is an internal error. */
469 void (*read) (struct value *v);
470
471 /* Handle an assignment TOVAL = FROMVAL by writing the value of
472 FROMVAL to TOVAL's location. The contents of TOVAL have not yet
473 been updated. If a problem arises in doing so, this function
474 should call 'error'. If it is NULL such TOVAL assignment is an error as
475 TOVAL is not considered as an lvalue. */
476 void (*write) (struct value *toval, struct value *fromval);
477
478 /* Return true if any part of V is optimized out, false otherwise.
479 This will only be called for lazy values -- if the value has been
480 fetched, then the value's optimized-out bits are consulted
481 instead. */
482 bool (*is_optimized_out) (struct value *v);
483
484 /* If non-NULL, this is used to implement pointer indirection for
485 this value. This method may return NULL, in which case value_ind
486 will fall back to ordinary indirection. */
487 struct value *(*indirect) (struct value *value);
488
489 /* If non-NULL, this is used to implement reference resolving for
490 this value. This method may return NULL, in which case coerce_ref
491 will fall back to ordinary references resolving. */
492 struct value *(*coerce_ref) (const struct value *value);
493
494 /* If non-NULL, this is used to determine whether the indicated bits
495 of VALUE are a synthetic pointer. */
496 int (*check_synthetic_pointer) (const struct value *value,
497 LONGEST offset, int length);
498
499 /* Return a duplicate of VALUE's closure, for use in a new value.
500 This may simply return the same closure, if VALUE's is
501 reference-counted or statically allocated.
502
503 This may be NULL, in which case VALUE's closure is re-used in the
504 new value. */
505 void *(*copy_closure) (const struct value *v);
506
507 /* Drop VALUE's reference to its closure. Maybe this frees the
508 closure; maybe this decrements a reference count; maybe the
509 closure is statically allocated and this does nothing.
510
511 This may be NULL, in which case no action is taken to free
512 VALUE's closure. */
513 void (*free_closure) (struct value *v);
514 };
515
516 /* Create a computed lvalue, with type TYPE, function pointers FUNCS,
517 and closure CLOSURE. */
518
519 extern struct value *allocate_computed_value (struct type *type,
520 const struct lval_funcs *funcs,
521 void *closure);
522
523 extern struct value *allocate_optimized_out_value (struct type *type);
524
525 /* If VALUE is lval_computed, return its lval_funcs structure. */
526
527 extern const struct lval_funcs *value_computed_funcs (const struct value *);
528
529 /* If VALUE is lval_computed, return its closure. The meaning of the
530 returned value depends on the functions VALUE uses. */
531
532 extern void *value_computed_closure (const struct value *value);
533
534 /* If zero, contents of this value are in the contents field. If
535 nonzero, contents are in inferior. If the lval field is lval_memory,
536 the contents are in inferior memory at location.address plus offset.
537 The lval field may also be lval_register.
538
539 WARNING: This field is used by the code which handles watchpoints
540 (see breakpoint.c) to decide whether a particular value can be
541 watched by hardware watchpoints. If the lazy flag is set for some
542 member of a value chain, it is assumed that this member of the
543 chain doesn't need to be watched as part of watching the value
544 itself. This is how GDB avoids watching the entire struct or array
545 when the user wants to watch a single struct member or array
546 element. If you ever change the way lazy flag is set and reset, be
547 sure to consider this use as well! */
548
549 extern int value_lazy (const struct value *);
550 extern void set_value_lazy (struct value *value, int val);
551
552 extern int value_stack (const struct value *);
553 extern void set_value_stack (struct value *value, int val);
554
555 /* Throw an error complaining that the value has been optimized
556 out. */
557
558 extern void error_value_optimized_out (void);
559
560 /* value_contents() and value_contents_raw() both return the address
561 of the gdb buffer used to hold a copy of the contents of the lval.
562 value_contents() is used when the contents of the buffer are needed
563 -- it uses value_fetch_lazy() to load the buffer from the process
564 being debugged if it hasn't already been loaded
565 (value_contents_writeable() is used when a writeable but fetched
566 buffer is required).. value_contents_raw() is used when data is
567 being stored into the buffer, or when it is certain that the
568 contents of the buffer are valid.
569
570 Note: The contents pointer is adjusted by the offset required to
571 get to the real subobject, if the value happens to represent
572 something embedded in a larger run-time object. */
573
574 extern gdb::array_view<gdb_byte> value_contents_raw (struct value *);
575
576 /* Actual contents of the value. For use of this value; setting it
577 uses the stuff above. Not valid if lazy is nonzero. Target
578 byte-order. We force it to be aligned properly for any possible
579 value. Note that a value therefore extends beyond what is
580 declared here. */
581
582 extern gdb::array_view<const gdb_byte> value_contents (struct value *);
583 extern gdb::array_view<gdb_byte> value_contents_writeable (struct value *);
584
585 /* The ALL variants of the above two macros do not adjust the returned
586 pointer by the embedded_offset value. */
587
588 extern gdb::array_view<gdb_byte> value_contents_all_raw (struct value *);
589 extern gdb::array_view<const gdb_byte> value_contents_all (struct value *);
590
591 /* Like value_contents_all, but does not require that the returned
592 bits be valid. This should only be used in situations where you
593 plan to check the validity manually. */
594 extern gdb::array_view<const gdb_byte> value_contents_for_printing (struct value *value);
595
596 /* Like value_contents_for_printing, but accepts a constant value
597 pointer. Unlike value_contents_for_printing however, the pointed
598 value must _not_ be lazy. */
599 extern gdb::array_view<const gdb_byte>
600 value_contents_for_printing_const (const struct value *value);
601
602 extern void value_fetch_lazy (struct value *val);
603
604 /* If nonzero, this is the value of a variable which does not actually
605 exist in the program, at least partially. If the value is lazy,
606 this may fetch it now. */
607 extern int value_optimized_out (struct value *value);
608
609 /* Given a value, return true if any of the contents bits starting at
610 OFFSET and extending for LENGTH bits is optimized out, false
611 otherwise. */
612
613 extern int value_bits_any_optimized_out (const struct value *value,
614 int bit_offset, int bit_length);
615
616 /* Like value_optimized_out, but return true iff the whole value is
617 optimized out. */
618 extern int value_entirely_optimized_out (struct value *value);
619
620 /* Mark VALUE's content bytes starting at OFFSET and extending for
621 LENGTH bytes as optimized out. */
622
623 extern void mark_value_bytes_optimized_out (struct value *value,
624 int offset, int length);
625
626 /* Mark VALUE's content bits starting at OFFSET and extending for
627 LENGTH bits as optimized out. */
628
629 extern void mark_value_bits_optimized_out (struct value *value,
630 LONGEST offset, LONGEST length);
631
632 /* Set or return field indicating whether a variable is initialized or
633 not, based on debugging information supplied by the compiler.
634 1 = initialized; 0 = uninitialized. */
635 extern int value_initialized (const struct value *);
636 extern void set_value_initialized (struct value *, int);
637
638 /* Set COMPONENT's location as appropriate for a component of WHOLE
639 --- regardless of what kind of lvalue WHOLE is. */
640 extern void set_value_component_location (struct value *component,
641 const struct value *whole);
642
643 /* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a
644 single value might have multiple LVALs), this hacked interface is
645 limited to just the first PIECE. Expect further change. */
646 /* Type of value; either not an lval, or one of the various different
647 possible kinds of lval. */
648 extern enum lval_type *deprecated_value_lval_hack (struct value *);
649 #define VALUE_LVAL(val) (*deprecated_value_lval_hack (val))
650
651 /* Like VALUE_LVAL, except the parameter can be const. */
652 extern enum lval_type value_lval_const (const struct value *value);
653
654 /* If lval == lval_memory, return the address in the inferior. If
655 lval == lval_register, return the byte offset into the registers
656 structure. Otherwise, return 0. The returned address
657 includes the offset, if any. */
658 extern CORE_ADDR value_address (const struct value *);
659
660 /* Like value_address, except the result does not include value's
661 offset. */
662 extern CORE_ADDR value_raw_address (const struct value *);
663
664 /* Set the address of a value. */
665 extern void set_value_address (struct value *, CORE_ADDR);
666
667 /* Pointer to internal variable. */
668 extern struct internalvar **deprecated_value_internalvar_hack (struct value *);
669 #define VALUE_INTERNALVAR(val) (*deprecated_value_internalvar_hack (val))
670
671 /* Frame ID of "next" frame to which a register value is relative. A
672 register value is indicated by VALUE_LVAL being set to lval_register.
673 So, if the register value is found relative to frame F, then the
674 frame id of F->next will be stored in VALUE_NEXT_FRAME_ID. */
675 extern struct frame_id *deprecated_value_next_frame_id_hack (struct value *);
676 #define VALUE_NEXT_FRAME_ID(val) (*deprecated_value_next_frame_id_hack (val))
677
678 /* Register number if the value is from a register. */
679 extern int *deprecated_value_regnum_hack (struct value *);
680 #define VALUE_REGNUM(val) (*deprecated_value_regnum_hack (val))
681
682 /* Return value after lval_funcs->coerce_ref (after check_typedef). Return
683 NULL if lval_funcs->coerce_ref is not applicable for whatever reason. */
684
685 extern struct value *coerce_ref_if_computed (const struct value *arg);
686
687 /* Setup a new value type and enclosing value type for dereferenced value VALUE.
688 ENC_TYPE is the new enclosing type that should be set. ORIGINAL_TYPE and
689 ORIGINAL_VAL are the type and value of the original reference or
690 pointer. ORIGINAL_VALUE_ADDRESS is the address within VALUE, that is
691 the address that was dereferenced.
692
693 Note, that VALUE is modified by this function.
694
695 It is a common implementation for coerce_ref and value_ind. */
696
697 extern struct value * readjust_indirect_value_type (struct value *value,
698 struct type *enc_type,
699 const struct type *original_type,
700 struct value *original_val,
701 CORE_ADDR original_value_address);
702
703 /* Convert a REF to the object referenced. */
704
705 extern struct value *coerce_ref (struct value *value);
706
707 /* If ARG is an array, convert it to a pointer.
708 If ARG is a function, convert it to a function pointer.
709
710 References are dereferenced. */
711
712 extern struct value *coerce_array (struct value *value);
713
714 /* Given a value, determine whether the bits starting at OFFSET and
715 extending for LENGTH bits are a synthetic pointer. */
716
717 extern int value_bits_synthetic_pointer (const struct value *value,
718 LONGEST offset, LONGEST length);
719
720 /* Given a value, determine whether the contents bytes starting at
721 OFFSET and extending for LENGTH bytes are available. This returns
722 nonzero if all bytes in the given range are available, zero if any
723 byte is unavailable. */
724
725 extern int value_bytes_available (const struct value *value,
726 LONGEST offset, ULONGEST length);
727
728 /* Given a value, determine whether the contents bits starting at
729 OFFSET and extending for LENGTH bits are available. This returns
730 nonzero if all bits in the given range are available, zero if any
731 bit is unavailable. */
732
733 extern int value_bits_available (const struct value *value,
734 LONGEST offset, ULONGEST length);
735
736 /* Like value_bytes_available, but return false if any byte in the
737 whole object is unavailable. */
738 extern int value_entirely_available (struct value *value);
739
740 /* Like value_entirely_available, but return false if any byte in the
741 whole object is available. */
742 extern int value_entirely_unavailable (struct value *value);
743
744 /* Mark VALUE's content bytes starting at OFFSET and extending for
745 LENGTH bytes as unavailable. */
746
747 extern void mark_value_bytes_unavailable (struct value *value,
748 LONGEST offset, ULONGEST length);
749
750 /* Mark VALUE's content bits starting at OFFSET and extending for
751 LENGTH bits as unavailable. */
752
753 extern void mark_value_bits_unavailable (struct value *value,
754 LONGEST offset, ULONGEST length);
755
756 /* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with
757 LENGTH bytes of VAL2's contents starting at OFFSET2.
758
759 Note that "contents" refers to the whole value's contents
760 (value_contents_all), without any embedded offset adjustment. For
761 example, to compare a complete object value with itself, including
762 its enclosing type chunk, you'd do:
763
764 int len = check_typedef (value_enclosing_type (val))->length ();
765 value_contents_eq (val, 0, val, 0, len);
766
767 Returns true iff the set of available/valid contents match.
768
769 Optimized-out contents are equal to optimized-out contents, and are
770 not equal to non-optimized-out contents.
771
772 Unavailable contents are equal to unavailable contents, and are not
773 equal to non-unavailable contents.
774
775 For example, if 'x's represent an unavailable byte, and 'V' and 'Z'
776 represent different available/valid bytes, in a value with length
777 16:
778
779 offset: 0 4 8 12 16
780 contents: xxxxVVVVxxxxVVZZ
781
782 then:
783
784 value_contents_eq(val, 0, val, 8, 6) => true
785 value_contents_eq(val, 0, val, 4, 4) => false
786 value_contents_eq(val, 0, val, 8, 8) => false
787 value_contents_eq(val, 4, val, 12, 2) => true
788 value_contents_eq(val, 4, val, 12, 4) => true
789 value_contents_eq(val, 3, val, 4, 4) => true
790
791 If 'x's represent an unavailable byte, 'o' represents an optimized
792 out byte, in a value with length 8:
793
794 offset: 0 4 8
795 contents: xxxxoooo
796
797 then:
798
799 value_contents_eq(val, 0, val, 2, 2) => true
800 value_contents_eq(val, 4, val, 6, 2) => true
801 value_contents_eq(val, 0, val, 4, 4) => true
802
803 We only know whether a value chunk is unavailable or optimized out
804 if we've tried to read it. As this routine is used by printing
805 routines, which may be printing values in the value history, long
806 after the inferior is gone, it works with const values. Therefore,
807 this routine must not be called with lazy values. */
808
809 extern bool value_contents_eq (const struct value *val1, LONGEST offset1,
810 const struct value *val2, LONGEST offset2,
811 LONGEST length);
812
813 /* An overload of value_contents_eq that compares the entirety of both
814 values. */
815
816 extern bool value_contents_eq (const struct value *val1,
817 const struct value *val2);
818
819 /* Read LENGTH addressable memory units starting at MEMADDR into BUFFER,
820 which is (or will be copied to) VAL's contents buffer offset by
821 BIT_OFFSET bits. Marks value contents ranges as unavailable if
822 the corresponding memory is likewise unavailable. STACK indicates
823 whether the memory is known to be stack memory. */
824
825 extern void read_value_memory (struct value *val, LONGEST bit_offset,
826 int stack, CORE_ADDR memaddr,
827 gdb_byte *buffer, size_t length);
828
829 /* Cast SCALAR_VALUE to the element type of VECTOR_TYPE, then replicate
830 into each element of a new vector value with VECTOR_TYPE. */
831
832 struct value *value_vector_widen (struct value *scalar_value,
833 struct type *vector_type);
834
835 \f
836
837 #include "symtab.h"
838 #include "gdbtypes.h"
839 #include "expression.h"
840
841 class frame_info_ptr;
842 struct fn_field;
843
844 extern int print_address_demangle (const struct value_print_options *,
845 struct gdbarch *, CORE_ADDR,
846 struct ui_file *, int);
847
848 /* Returns true if VAL is of floating-point type. In addition,
849 throws an error if the value is an invalid floating-point value. */
850 extern bool is_floating_value (struct value *val);
851
852 extern LONGEST value_as_long (struct value *val);
853 extern CORE_ADDR value_as_address (struct value *val);
854
855 extern LONGEST unpack_long (struct type *type, const gdb_byte *valaddr);
856 extern CORE_ADDR unpack_pointer (struct type *type, const gdb_byte *valaddr);
857
858 extern LONGEST unpack_field_as_long (struct type *type,
859 const gdb_byte *valaddr,
860 int fieldno);
861
862 /* Unpack a bitfield of the specified FIELD_TYPE, from the object at
863 VALADDR, and store the result in *RESULT.
864 The bitfield starts at BITPOS bits and contains BITSIZE bits; if
865 BITSIZE is zero, then the length is taken from FIELD_TYPE.
866
867 Extracting bits depends on endianness of the machine. Compute the
868 number of least significant bits to discard. For big endian machines,
869 we compute the total number of bits in the anonymous object, subtract
870 off the bit count from the MSB of the object to the MSB of the
871 bitfield, then the size of the bitfield, which leaves the LSB discard
872 count. For little endian machines, the discard count is simply the
873 number of bits from the LSB of the anonymous object to the LSB of the
874 bitfield.
875
876 If the field is signed, we also do sign extension. */
877
878 extern LONGEST unpack_bits_as_long (struct type *field_type,
879 const gdb_byte *valaddr,
880 LONGEST bitpos, LONGEST bitsize);
881
882 extern int unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
883 LONGEST embedded_offset, int fieldno,
884 const struct value *val, LONGEST *result);
885
886 extern void unpack_value_bitfield (struct value *dest_val,
887 LONGEST bitpos, LONGEST bitsize,
888 const gdb_byte *valaddr,
889 LONGEST embedded_offset,
890 const struct value *val);
891
892 extern struct value *value_field_bitfield (struct type *type, int fieldno,
893 const gdb_byte *valaddr,
894 LONGEST embedded_offset,
895 const struct value *val);
896
897 extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num);
898
899 extern struct value *value_from_longest (struct type *type, LONGEST num);
900 extern struct value *value_from_ulongest (struct type *type, ULONGEST num);
901 extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
902 extern struct value *value_from_host_double (struct type *type, double d);
903 extern struct value *value_from_history_ref (const char *, const char **);
904 extern struct value *value_from_component (struct value *, struct type *,
905 LONGEST);
906
907
908 /* Create a new value by extracting it from WHOLE. TYPE is the type
909 of the new value. BIT_OFFSET and BIT_LENGTH describe the offset
910 and field width of the value to extract from WHOLE -- BIT_LENGTH
911 may differ from TYPE's length in the case where WHOLE's type is
912 packed.
913
914 When the value does come from a non-byte-aligned offset or field
915 width, it will be marked non_lval. */
916
917 extern struct value *value_from_component_bitsize (struct value *whole,
918 struct type *type,
919 LONGEST bit_offset,
920 LONGEST bit_length);
921
922 extern struct value *value_at (struct type *type, CORE_ADDR addr);
923 extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
924
925 /* Like value_at, but ensures that the result is marked not_lval.
926 This can be important if the memory is "volatile". */
927 extern struct value *value_at_non_lval (struct type *type, CORE_ADDR addr);
928
929 extern struct value *value_from_contents_and_address_unresolved
930 (struct type *, const gdb_byte *, CORE_ADDR);
931 extern struct value *value_from_contents_and_address (struct type *,
932 const gdb_byte *,
933 CORE_ADDR);
934 extern struct value *value_from_contents (struct type *, const gdb_byte *);
935
936 extern struct value *default_value_from_register (struct gdbarch *gdbarch,
937 struct type *type,
938 int regnum,
939 struct frame_id frame_id);
940
941 extern void read_frame_register_value (struct value *value,
942 frame_info_ptr frame);
943
944 extern struct value *value_from_register (struct type *type, int regnum,
945 frame_info_ptr frame);
946
947 extern CORE_ADDR address_from_register (int regnum,
948 frame_info_ptr frame);
949
950 extern struct value *value_of_variable (struct symbol *var,
951 const struct block *b);
952
953 extern struct value *address_of_variable (struct symbol *var,
954 const struct block *b);
955
956 extern struct value *value_of_register (int regnum, frame_info_ptr frame);
957
958 struct value *value_of_register_lazy (frame_info_ptr frame, int regnum);
959
960 /* Return the symbol's reading requirement. */
961
962 extern enum symbol_needs_kind symbol_read_needs (struct symbol *);
963
964 /* Return true if the symbol needs a frame. This is a wrapper for
965 symbol_read_needs that simply checks for SYMBOL_NEEDS_FRAME. */
966
967 extern int symbol_read_needs_frame (struct symbol *);
968
969 extern struct value *read_var_value (struct symbol *var,
970 const struct block *var_block,
971 frame_info_ptr frame);
972
973 extern struct value *allocate_value (struct type *type);
974 extern struct value *allocate_value_lazy (struct type *type);
975 extern void value_contents_copy (struct value *dst, LONGEST dst_offset,
976 struct value *src, LONGEST src_offset,
977 LONGEST length);
978
979 extern struct value *allocate_repeat_value (struct type *type, int count);
980
981 extern struct value *value_mark (void);
982
983 extern void value_free_to_mark (const struct value *mark);
984
985 /* A helper class that uses value_mark at construction time and calls
986 value_free_to_mark in the destructor. This is used to clear out
987 temporary values created during the lifetime of this object. */
988 class scoped_value_mark
989 {
990 public:
991
992 scoped_value_mark ()
993 : m_value (value_mark ())
994 {
995 }
996
997 ~scoped_value_mark ()
998 {
999 free_to_mark ();
1000 }
1001
1002 scoped_value_mark (scoped_value_mark &&other) = default;
1003
1004 DISABLE_COPY_AND_ASSIGN (scoped_value_mark);
1005
1006 /* Free the values currently on the value stack. */
1007 void free_to_mark ()
1008 {
1009 if (m_value != NULL)
1010 {
1011 value_free_to_mark (m_value);
1012 m_value = NULL;
1013 }
1014 }
1015
1016 private:
1017
1018 const struct value *m_value;
1019 };
1020
1021 extern struct value *value_cstring (const char *ptr, ssize_t len,
1022 struct type *char_type);
1023 extern struct value *value_string (const char *ptr, ssize_t len,
1024 struct type *char_type);
1025
1026 extern struct value *value_array (int lowbound, int highbound,
1027 struct value **elemvec);
1028
1029 extern struct value *value_concat (struct value *arg1, struct value *arg2);
1030
1031 extern struct value *value_binop (struct value *arg1, struct value *arg2,
1032 enum exp_opcode op);
1033
1034 extern struct value *value_ptradd (struct value *arg1, LONGEST arg2);
1035
1036 extern LONGEST value_ptrdiff (struct value *arg1, struct value *arg2);
1037
1038 /* Return true if VAL does not live in target memory, but should in order
1039 to operate on it. Otherwise return false. */
1040
1041 extern bool value_must_coerce_to_target (struct value *arg1);
1042
1043 extern struct value *value_coerce_to_target (struct value *arg1);
1044
1045 extern struct value *value_coerce_array (struct value *arg1);
1046
1047 extern struct value *value_coerce_function (struct value *arg1);
1048
1049 extern struct value *value_ind (struct value *arg1);
1050
1051 extern struct value *value_addr (struct value *arg1);
1052
1053 extern struct value *value_ref (struct value *arg1, enum type_code refcode);
1054
1055 extern struct value *value_assign (struct value *toval,
1056 struct value *fromval);
1057
1058 extern struct value *value_pos (struct value *arg1);
1059
1060 extern struct value *value_neg (struct value *arg1);
1061
1062 extern struct value *value_complement (struct value *arg1);
1063
1064 extern struct value *value_struct_elt (struct value **argp,
1065 gdb::optional<gdb::array_view <value *>> args,
1066 const char *name, int *static_memfuncp,
1067 const char *err);
1068
1069 extern struct value *value_struct_elt_bitpos (struct value **argp,
1070 int bitpos,
1071 struct type *field_type,
1072 const char *err);
1073
1074 extern struct value *value_aggregate_elt (struct type *curtype,
1075 const char *name,
1076 struct type *expect_type,
1077 int want_address,
1078 enum noside noside);
1079
1080 extern struct value *value_static_field (struct type *type, int fieldno);
1081
1082 enum oload_search_type { NON_METHOD, METHOD, BOTH };
1083
1084 extern int find_overload_match (gdb::array_view<value *> args,
1085 const char *name,
1086 enum oload_search_type method,
1087 struct value **objp, struct symbol *fsym,
1088 struct value **valp, struct symbol **symp,
1089 int *staticp, const int no_adl,
1090 enum noside noside);
1091
1092 extern struct value *value_field (struct value *arg1, int fieldno);
1093
1094 extern struct value *value_primitive_field (struct value *arg1, LONGEST offset,
1095 int fieldno,
1096 struct type *arg_type);
1097
1098
1099 extern struct type *value_rtti_indirect_type (struct value *, int *, LONGEST *,
1100 int *);
1101
1102 extern struct value *value_full_object (struct value *, struct type *, int,
1103 int, int);
1104
1105 extern struct value *value_cast_pointers (struct type *, struct value *, int);
1106
1107 extern struct value *value_cast (struct type *type, struct value *arg2);
1108
1109 extern struct value *value_reinterpret_cast (struct type *type,
1110 struct value *arg);
1111
1112 extern struct value *value_dynamic_cast (struct type *type, struct value *arg);
1113
1114 extern struct value *value_zero (struct type *type, enum lval_type lv);
1115
1116 extern struct value *value_one (struct type *type);
1117
1118 extern struct value *value_repeat (struct value *arg1, int count);
1119
1120 extern struct value *value_subscript (struct value *array, LONGEST index);
1121
1122 extern struct value *value_bitstring_subscript (struct type *type,
1123 struct value *bitstring,
1124 LONGEST index);
1125
1126 extern struct value *register_value_being_returned (struct type *valtype,
1127 struct regcache *retbuf);
1128
1129 extern int value_in (struct value *element, struct value *set);
1130
1131 extern int value_bit_index (struct type *type, const gdb_byte *addr,
1132 int index);
1133
1134 extern enum return_value_convention
1135 struct_return_convention (struct gdbarch *gdbarch, struct value *function,
1136 struct type *value_type);
1137
1138 extern int using_struct_return (struct gdbarch *gdbarch,
1139 struct value *function,
1140 struct type *value_type);
1141
1142 /* Evaluate the expression EXP. If set, EXPECT_TYPE is passed to the
1143 outermost operation's evaluation. This is ignored by most
1144 operations, but may be used, e.g., to determine the type of an
1145 otherwise untyped symbol. The caller should not assume that the
1146 returned value has this type. */
1147
1148 extern struct value *evaluate_expression (struct expression *exp,
1149 struct type *expect_type = nullptr);
1150
1151 extern struct value *evaluate_type (struct expression *exp);
1152
1153 extern value *evaluate_var_value (enum noside noside, const block *blk,
1154 symbol *var);
1155
1156 extern value *evaluate_var_msym_value (enum noside noside,
1157 struct objfile *objfile,
1158 minimal_symbol *msymbol);
1159
1160 namespace expr { class operation; };
1161 extern void fetch_subexp_value (struct expression *exp,
1162 expr::operation *op,
1163 struct value **valp, struct value **resultp,
1164 std::vector<value_ref_ptr> *val_chain,
1165 bool preserve_errors);
1166
1167 extern struct value *parse_and_eval (const char *exp);
1168
1169 extern struct value *parse_to_comma_and_eval (const char **expp);
1170
1171 extern struct type *parse_and_eval_type (const char *p, int length);
1172
1173 extern CORE_ADDR parse_and_eval_address (const char *exp);
1174
1175 extern LONGEST parse_and_eval_long (const char *exp);
1176
1177 extern void unop_promote (const struct language_defn *language,
1178 struct gdbarch *gdbarch,
1179 struct value **arg1);
1180
1181 extern void binop_promote (const struct language_defn *language,
1182 struct gdbarch *gdbarch,
1183 struct value **arg1, struct value **arg2);
1184
1185 extern struct value *access_value_history (int num);
1186
1187 /* Return the number of items in the value history. */
1188
1189 extern ULONGEST value_history_count ();
1190
1191 extern struct value *value_of_internalvar (struct gdbarch *gdbarch,
1192 struct internalvar *var);
1193
1194 extern int get_internalvar_integer (struct internalvar *var, LONGEST *l);
1195
1196 extern void set_internalvar (struct internalvar *var, struct value *val);
1197
1198 extern void set_internalvar_integer (struct internalvar *var, LONGEST l);
1199
1200 extern void set_internalvar_string (struct internalvar *var,
1201 const char *string);
1202
1203 extern void clear_internalvar (struct internalvar *var);
1204
1205 extern void set_internalvar_component (struct internalvar *var,
1206 LONGEST offset,
1207 LONGEST bitpos, LONGEST bitsize,
1208 struct value *newvalue);
1209
1210 extern struct internalvar *lookup_only_internalvar (const char *name);
1211
1212 extern struct internalvar *create_internalvar (const char *name);
1213
1214 extern void complete_internalvar (completion_tracker &tracker,
1215 const char *name);
1216
1217 /* An internalvar can be dynamically computed by supplying a vector of
1218 function pointers to perform various operations. */
1219
1220 struct internalvar_funcs
1221 {
1222 /* Compute the value of the variable. The DATA argument passed to
1223 the function is the same argument that was passed to
1224 `create_internalvar_type_lazy'. */
1225
1226 struct value *(*make_value) (struct gdbarch *arch,
1227 struct internalvar *var,
1228 void *data);
1229
1230 /* Update the agent expression EXPR with bytecode to compute the
1231 value. VALUE is the agent value we are updating. The DATA
1232 argument passed to this function is the same argument that was
1233 passed to `create_internalvar_type_lazy'. If this pointer is
1234 NULL, then the internalvar cannot be compiled to an agent
1235 expression. */
1236
1237 void (*compile_to_ax) (struct internalvar *var,
1238 struct agent_expr *expr,
1239 struct axs_value *value,
1240 void *data);
1241 };
1242
1243 extern struct internalvar *create_internalvar_type_lazy (const char *name,
1244 const struct internalvar_funcs *funcs,
1245 void *data);
1246
1247 /* Compile an internal variable to an agent expression. VAR is the
1248 variable to compile; EXPR and VALUE are the agent expression we are
1249 updating. This will return 0 if there is no known way to compile
1250 VAR, and 1 if VAR was successfully compiled. It may also throw an
1251 exception on error. */
1252
1253 extern int compile_internalvar_to_ax (struct internalvar *var,
1254 struct agent_expr *expr,
1255 struct axs_value *value);
1256
1257 extern struct internalvar *lookup_internalvar (const char *name);
1258
1259 extern int value_equal (struct value *arg1, struct value *arg2);
1260
1261 extern int value_equal_contents (struct value *arg1, struct value *arg2);
1262
1263 extern int value_less (struct value *arg1, struct value *arg2);
1264
1265 /* Simulate the C operator ! -- return true if ARG1 contains zero. */
1266 extern bool value_logical_not (struct value *arg1);
1267
1268 /* Returns true if the value VAL represents a true value. */
1269 static inline bool
1270 value_true (struct value *val)
1271 {
1272 return !value_logical_not (val);
1273 }
1274
1275 /* C++ */
1276
1277 extern struct value *value_of_this (const struct language_defn *lang);
1278
1279 extern struct value *value_of_this_silent (const struct language_defn *lang);
1280
1281 extern struct value *value_x_binop (struct value *arg1, struct value *arg2,
1282 enum exp_opcode op,
1283 enum exp_opcode otherop,
1284 enum noside noside);
1285
1286 extern struct value *value_x_unop (struct value *arg1, enum exp_opcode op,
1287 enum noside noside);
1288
1289 extern struct value *value_fn_field (struct value **arg1p, struct fn_field *f,
1290 int j, struct type *type, LONGEST offset);
1291
1292 extern int binop_types_user_defined_p (enum exp_opcode op,
1293 struct type *type1,
1294 struct type *type2);
1295
1296 extern int binop_user_defined_p (enum exp_opcode op, struct value *arg1,
1297 struct value *arg2);
1298
1299 extern int unop_user_defined_p (enum exp_opcode op, struct value *arg1);
1300
1301 extern int destructor_name_p (const char *name, struct type *type);
1302
1303 extern value_ref_ptr release_value (struct value *val);
1304
1305 extern int record_latest_value (struct value *val);
1306
1307 extern void modify_field (struct type *type, gdb_byte *addr,
1308 LONGEST fieldval, LONGEST bitpos, LONGEST bitsize);
1309
1310 extern void type_print (struct type *type, const char *varstring,
1311 struct ui_file *stream, int show);
1312
1313 extern std::string type_to_string (struct type *type);
1314
1315 extern gdb_byte *baseclass_addr (struct type *type, int index,
1316 gdb_byte *valaddr,
1317 struct value **valuep, int *errp);
1318
1319 extern void print_longest (struct ui_file *stream, int format,
1320 int use_local, LONGEST val);
1321
1322 extern void print_floating (const gdb_byte *valaddr, struct type *type,
1323 struct ui_file *stream);
1324
1325 extern void value_print (struct value *val, struct ui_file *stream,
1326 const struct value_print_options *options);
1327
1328 /* Release values from the value chain and return them. Values
1329 created after MARK are released. If MARK is nullptr, or if MARK is
1330 not found on the value chain, then all values are released. Values
1331 are returned in reverse order of creation; that is, newest
1332 first. */
1333
1334 extern std::vector<value_ref_ptr> value_release_to_mark
1335 (const struct value *mark);
1336
1337 extern void common_val_print (struct value *val,
1338 struct ui_file *stream, int recurse,
1339 const struct value_print_options *options,
1340 const struct language_defn *language);
1341
1342 extern int val_print_string (struct type *elttype, const char *encoding,
1343 CORE_ADDR addr, int len,
1344 struct ui_file *stream,
1345 const struct value_print_options *options);
1346
1347 extern void print_variable_and_value (const char *name,
1348 struct symbol *var,
1349 frame_info_ptr frame,
1350 struct ui_file *stream,
1351 int indent);
1352
1353 extern void typedef_print (struct type *type, struct symbol *news,
1354 struct ui_file *stream);
1355
1356 extern const char *internalvar_name (const struct internalvar *var);
1357
1358 extern void preserve_values (struct objfile *);
1359
1360 /* From values.c */
1361
1362 extern struct value *value_copy (const value *);
1363
1364 extern struct value *value_non_lval (struct value *);
1365
1366 extern void value_force_lval (struct value *, CORE_ADDR);
1367
1368 extern struct value *make_cv_value (int, int, struct value *);
1369
1370 extern void preserve_one_value (struct value *, struct objfile *, htab_t);
1371
1372 /* From valops.c */
1373
1374 extern struct value *varying_to_slice (struct value *);
1375
1376 extern struct value *value_slice (struct value *, int, int);
1377
1378 /* Create a complex number. The type is the complex type; the values
1379 are cast to the underlying scalar type before the complex number is
1380 created. */
1381
1382 extern struct value *value_literal_complex (struct value *, struct value *,
1383 struct type *);
1384
1385 /* Return the real part of a complex value. */
1386
1387 extern struct value *value_real_part (struct value *value);
1388
1389 /* Return the imaginary part of a complex value. */
1390
1391 extern struct value *value_imaginary_part (struct value *value);
1392
1393 extern struct value *find_function_in_inferior (const char *,
1394 struct objfile **);
1395
1396 extern struct value *value_allocate_space_in_inferior (int);
1397
1398 /* User function handler. */
1399
1400 typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch,
1401 const struct language_defn *language,
1402 void *cookie,
1403 int argc,
1404 struct value **argv);
1405
1406 /* Add a new internal function. NAME is the name of the function; DOC
1407 is a documentation string describing the function. HANDLER is
1408 called when the function is invoked. COOKIE is an arbitrary
1409 pointer which is passed to HANDLER and is intended for "user
1410 data". */
1411
1412 extern void add_internal_function (const char *name, const char *doc,
1413 internal_function_fn handler,
1414 void *cookie);
1415
1416 /* This overload takes an allocated documentation string. */
1417
1418 extern void add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
1419 gdb::unique_xmalloc_ptr<char> &&doc,
1420 internal_function_fn handler,
1421 void *cookie);
1422
1423 struct value *call_internal_function (struct gdbarch *gdbarch,
1424 const struct language_defn *language,
1425 struct value *function,
1426 int argc, struct value **argv);
1427
1428 const char *value_internal_function_name (struct value *);
1429
1430 /* Build a value wrapping and representing WORKER. The value takes ownership
1431 of the xmethod_worker object. */
1432
1433 extern struct value *value_from_xmethod (xmethod_worker_up &&worker);
1434
1435 extern struct type *result_type_of_xmethod (struct value *method,
1436 gdb::array_view<value *> argv);
1437
1438 extern struct value *call_xmethod (struct value *method,
1439 gdb::array_view<value *> argv);
1440
1441 /* Destroy the values currently allocated. This is called when GDB is
1442 exiting (e.g., on quit_force). */
1443 extern void finalize_values ();
1444
1445 /* Convert VALUE to a gdb_mpq. The caller must ensure that VALUE is
1446 of floating-point, fixed-point, or integer type. */
1447 extern gdb_mpq value_to_gdb_mpq (struct value *value);
1448
1449 /* While an instance of this class is live, and array values that are
1450 created, that are larger than max_value_size, will be restricted in size
1451 to a particular number of elements. */
1452
1453 struct scoped_array_length_limiting
1454 {
1455 /* Limit any large array values to only contain ELEMENTS elements. */
1456 scoped_array_length_limiting (int elements);
1457
1458 /* Restore the previous array value limit. */
1459 ~scoped_array_length_limiting ();
1460
1461 private:
1462 /* Used to hold the previous array value element limit. */
1463 gdb::optional<int> m_old_value;
1464 };
1465
1466 #endif /* !defined (VALUE_H) */