15796c8dcSSimon Schubert /* Definitions for values of C expressions, for GDB. 25796c8dcSSimon Schubert 3*ef5ccd6cSJohn Marino Copyright (C) 1986-2013 Free Software Foundation, Inc. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GDB. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 105796c8dcSSimon Schubert (at your option) any later version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155796c8dcSSimon Schubert GNU General Public License for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert #if !defined (VALUE_H) 215796c8dcSSimon Schubert #define VALUE_H 1 225796c8dcSSimon Schubert 235796c8dcSSimon Schubert #include "doublest.h" 245796c8dcSSimon Schubert #include "frame.h" /* For struct frame_id. */ 255796c8dcSSimon Schubert 265796c8dcSSimon Schubert struct block; 275796c8dcSSimon Schubert struct expression; 285796c8dcSSimon Schubert struct regcache; 295796c8dcSSimon Schubert struct symbol; 305796c8dcSSimon Schubert struct type; 315796c8dcSSimon Schubert struct ui_file; 325796c8dcSSimon Schubert struct language_defn; 335796c8dcSSimon Schubert struct value_print_options; 345796c8dcSSimon Schubert 355796c8dcSSimon Schubert /* The structure which defines the type of a value. It should never 365796c8dcSSimon Schubert be possible for a program lval value to survive over a call to the 375796c8dcSSimon Schubert inferior (i.e. to be put into the history list or an internal 385796c8dcSSimon Schubert variable). */ 395796c8dcSSimon Schubert 405796c8dcSSimon Schubert struct value; 415796c8dcSSimon Schubert 425796c8dcSSimon Schubert /* Values are stored in a chain, so that they can be deleted easily 435796c8dcSSimon Schubert over calls to the inferior. Values assigned to internal variables, 445796c8dcSSimon Schubert put into the value history or exposed to Python are taken off this 455796c8dcSSimon Schubert list. */ 465796c8dcSSimon Schubert 475796c8dcSSimon Schubert struct value *value_next (struct value *); 485796c8dcSSimon Schubert 495796c8dcSSimon Schubert /* Type of the value. */ 505796c8dcSSimon Schubert 51cf7f2e2dSJohn Marino extern struct type *value_type (const struct value *); 525796c8dcSSimon Schubert 535796c8dcSSimon Schubert /* This is being used to change the type of an existing value, that 545796c8dcSSimon Schubert code should instead be creating a new value with the changed type 555796c8dcSSimon Schubert (but possibly shared content). */ 565796c8dcSSimon Schubert 575796c8dcSSimon Schubert extern void deprecated_set_value_type (struct value *value, 585796c8dcSSimon Schubert struct type *type); 595796c8dcSSimon Schubert 605796c8dcSSimon Schubert /* Only used for bitfields; number of bits contained in them. */ 615796c8dcSSimon Schubert 62cf7f2e2dSJohn Marino extern int value_bitsize (const struct value *); 635796c8dcSSimon Schubert extern void set_value_bitsize (struct value *, int bit); 645796c8dcSSimon Schubert 655796c8dcSSimon Schubert /* Only used for bitfields; position of start of field. For 665796c8dcSSimon Schubert gdbarch_bits_big_endian=0 targets, it is the position of the LSB. For 675796c8dcSSimon Schubert gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */ 685796c8dcSSimon Schubert 69cf7f2e2dSJohn Marino extern int value_bitpos (const struct value *); 705796c8dcSSimon Schubert extern void set_value_bitpos (struct value *, int bit); 715796c8dcSSimon Schubert 725796c8dcSSimon Schubert /* Only used for bitfields; the containing value. This allows a 735796c8dcSSimon Schubert single read from the target when displaying multiple 745796c8dcSSimon Schubert bitfields. */ 755796c8dcSSimon Schubert 765796c8dcSSimon Schubert struct value *value_parent (struct value *); 77*ef5ccd6cSJohn Marino extern void set_value_parent (struct value *value, struct value *parent); 785796c8dcSSimon Schubert 795796c8dcSSimon Schubert /* Describes offset of a value within lval of a structure in bytes. 805796c8dcSSimon Schubert If lval == lval_memory, this is an offset to the address. If lval 815796c8dcSSimon Schubert == lval_register, this is a further offset from location.address 825796c8dcSSimon Schubert within the registers structure. Note also the member 835796c8dcSSimon Schubert embedded_offset below. */ 845796c8dcSSimon Schubert 85cf7f2e2dSJohn Marino extern int value_offset (const struct value *); 865796c8dcSSimon Schubert extern void set_value_offset (struct value *, int offset); 875796c8dcSSimon Schubert 885796c8dcSSimon Schubert /* The comment from "struct value" reads: ``Is it modifiable? Only 895796c8dcSSimon Schubert relevant if lval != not_lval.''. Shouldn't the value instead be 905796c8dcSSimon Schubert not_lval and be done with it? */ 915796c8dcSSimon Schubert 925796c8dcSSimon Schubert extern int deprecated_value_modifiable (struct value *value); 935796c8dcSSimon Schubert 945796c8dcSSimon Schubert /* If a value represents a C++ object, then the `type' field gives the 955796c8dcSSimon Schubert object's compile-time type. If the object actually belongs to some 965796c8dcSSimon Schubert class derived from `type', perhaps with other base classes and 975796c8dcSSimon Schubert additional members, then `type' is just a subobject of the real 985796c8dcSSimon Schubert thing, and the full object is probably larger than `type' would 995796c8dcSSimon Schubert suggest. 1005796c8dcSSimon Schubert 1015796c8dcSSimon Schubert If `type' is a dynamic class (i.e. one with a vtable), then GDB can 1025796c8dcSSimon Schubert actually determine the object's run-time type by looking at the 1035796c8dcSSimon Schubert run-time type information in the vtable. When this information is 1045796c8dcSSimon Schubert available, we may elect to read in the entire object, for several 1055796c8dcSSimon Schubert reasons: 1065796c8dcSSimon Schubert 1075796c8dcSSimon Schubert - When printing the value, the user would probably rather see the 1085796c8dcSSimon Schubert full object, not just the limited portion apparent from the 1095796c8dcSSimon Schubert compile-time type. 1105796c8dcSSimon Schubert 1115796c8dcSSimon Schubert - If `type' has virtual base classes, then even printing `type' 1125796c8dcSSimon Schubert alone may require reaching outside the `type' portion of the 1135796c8dcSSimon Schubert object to wherever the virtual base class has been stored. 1145796c8dcSSimon Schubert 1155796c8dcSSimon Schubert When we store the entire object, `enclosing_type' is the run-time 1165796c8dcSSimon Schubert type -- the complete object -- and `embedded_offset' is the offset 1175796c8dcSSimon Schubert of `type' within that larger type, in bytes. The value_contents() 1185796c8dcSSimon Schubert macro takes `embedded_offset' into account, so most GDB code 1195796c8dcSSimon Schubert continues to see the `type' portion of the value, just as the 1205796c8dcSSimon Schubert inferior would. 1215796c8dcSSimon Schubert 1225796c8dcSSimon Schubert If `type' is a pointer to an object, then `enclosing_type' is a 1235796c8dcSSimon Schubert pointer to the object's run-time type, and `pointed_to_offset' is 1245796c8dcSSimon Schubert the offset in bytes from the full object to the pointed-to object 1255796c8dcSSimon Schubert -- that is, the value `embedded_offset' would have if we followed 1265796c8dcSSimon Schubert the pointer and fetched the complete object. (I don't really see 1275796c8dcSSimon Schubert the point. Why not just determine the run-time type when you 1285796c8dcSSimon Schubert indirect, and avoid the special case? The contents don't matter 1295796c8dcSSimon Schubert until you indirect anyway.) 1305796c8dcSSimon Schubert 1315796c8dcSSimon Schubert If we're not doing anything fancy, `enclosing_type' is equal to 1325796c8dcSSimon Schubert `type', and `embedded_offset' is zero, so everything works 1335796c8dcSSimon Schubert normally. */ 1345796c8dcSSimon Schubert 1355796c8dcSSimon Schubert extern struct type *value_enclosing_type (struct value *); 136c50c785cSJohn Marino extern void set_value_enclosing_type (struct value *val, 1375796c8dcSSimon Schubert struct type *new_type); 138c50c785cSJohn Marino 139*ef5ccd6cSJohn Marino /* Returns value_type or value_enclosing_type depending on 140*ef5ccd6cSJohn Marino value_print_options.objectprint. 141*ef5ccd6cSJohn Marino 142*ef5ccd6cSJohn Marino If RESOLVE_SIMPLE_TYPES is 0 the enclosing type will be resolved 143*ef5ccd6cSJohn Marino only for pointers and references, else it will be returned 144*ef5ccd6cSJohn Marino for all the types (e.g. structures). This option is useful 145*ef5ccd6cSJohn Marino to prevent retrieving enclosing type for the base classes fields. 146*ef5ccd6cSJohn Marino 147*ef5ccd6cSJohn Marino REAL_TYPE_FOUND is used to inform whether the real type was found 148*ef5ccd6cSJohn Marino (or just static type was used). The NULL may be passed if it is not 149*ef5ccd6cSJohn Marino necessary. */ 150*ef5ccd6cSJohn Marino 151*ef5ccd6cSJohn Marino extern struct type *value_actual_type (struct value *value, 152*ef5ccd6cSJohn Marino int resolve_simple_types, 153*ef5ccd6cSJohn Marino int *real_type_found); 154*ef5ccd6cSJohn Marino 1555796c8dcSSimon Schubert extern int value_pointed_to_offset (struct value *value); 1565796c8dcSSimon Schubert extern void set_value_pointed_to_offset (struct value *value, int val); 1575796c8dcSSimon Schubert extern int value_embedded_offset (struct value *value); 1585796c8dcSSimon Schubert extern void set_value_embedded_offset (struct value *value, int val); 1595796c8dcSSimon Schubert 1605796c8dcSSimon Schubert /* For lval_computed values, this structure holds functions used to 1615796c8dcSSimon Schubert retrieve and set the value (or portions of the value). 1625796c8dcSSimon Schubert 1635796c8dcSSimon Schubert For each function, 'V' is the 'this' pointer: an lval_funcs 1645796c8dcSSimon Schubert function F may always assume that the V it receives is an 1655796c8dcSSimon Schubert lval_computed value, and has F in the appropriate slot of its 1665796c8dcSSimon Schubert lval_funcs structure. */ 1675796c8dcSSimon Schubert 1685796c8dcSSimon Schubert struct lval_funcs 1695796c8dcSSimon Schubert { 1705796c8dcSSimon Schubert /* Fill in VALUE's contents. This is used to "un-lazy" values. If 1715796c8dcSSimon Schubert a problem arises in obtaining VALUE's bits, this function should 172a45ae5f8SJohn Marino call 'error'. If it is NULL value_fetch_lazy on "un-lazy" 173a45ae5f8SJohn Marino non-optimized-out value is an internal error. */ 1745796c8dcSSimon Schubert void (*read) (struct value *v); 1755796c8dcSSimon Schubert 1765796c8dcSSimon Schubert /* Handle an assignment TOVAL = FROMVAL by writing the value of 1775796c8dcSSimon Schubert FROMVAL to TOVAL's location. The contents of TOVAL have not yet 1785796c8dcSSimon Schubert been updated. If a problem arises in doing so, this function 179a45ae5f8SJohn Marino should call 'error'. If it is NULL such TOVAL assignment is an error as 180a45ae5f8SJohn Marino TOVAL is not considered as an lvalue. */ 1815796c8dcSSimon Schubert void (*write) (struct value *toval, struct value *fromval); 1825796c8dcSSimon Schubert 183cf7f2e2dSJohn Marino /* Check the validity of some bits in VALUE. This should return 1 184cf7f2e2dSJohn Marino if all the bits starting at OFFSET and extending for LENGTH bits 185cf7f2e2dSJohn Marino are valid, or 0 if any bit is invalid. */ 186cf7f2e2dSJohn Marino int (*check_validity) (const struct value *value, int offset, int length); 187cf7f2e2dSJohn Marino 188cf7f2e2dSJohn Marino /* Return 1 if any bit in VALUE is valid, 0 if they are all invalid. */ 189cf7f2e2dSJohn Marino int (*check_any_valid) (const struct value *value); 190cf7f2e2dSJohn Marino 191c50c785cSJohn Marino /* If non-NULL, this is used to implement pointer indirection for 192c50c785cSJohn Marino this value. This method may return NULL, in which case value_ind 193c50c785cSJohn Marino will fall back to ordinary indirection. */ 194c50c785cSJohn Marino struct value *(*indirect) (struct value *value); 195c50c785cSJohn Marino 196a45ae5f8SJohn Marino /* If non-NULL, this is used to implement reference resolving for 197a45ae5f8SJohn Marino this value. This method may return NULL, in which case coerce_ref 198a45ae5f8SJohn Marino will fall back to ordinary references resolving. */ 199a45ae5f8SJohn Marino struct value *(*coerce_ref) (const struct value *value); 200a45ae5f8SJohn Marino 201c50c785cSJohn Marino /* If non-NULL, this is used to determine whether the indicated bits 202c50c785cSJohn Marino of VALUE are a synthetic pointer. */ 203c50c785cSJohn Marino int (*check_synthetic_pointer) (const struct value *value, 204c50c785cSJohn Marino int offset, int length); 205c50c785cSJohn Marino 2065796c8dcSSimon Schubert /* Return a duplicate of VALUE's closure, for use in a new value. 2075796c8dcSSimon Schubert This may simply return the same closure, if VALUE's is 2085796c8dcSSimon Schubert reference-counted or statically allocated. 2095796c8dcSSimon Schubert 2105796c8dcSSimon Schubert This may be NULL, in which case VALUE's closure is re-used in the 2115796c8dcSSimon Schubert new value. */ 212cf7f2e2dSJohn Marino void *(*copy_closure) (const struct value *v); 2135796c8dcSSimon Schubert 2145796c8dcSSimon Schubert /* Drop VALUE's reference to its closure. Maybe this frees the 2155796c8dcSSimon Schubert closure; maybe this decrements a reference count; maybe the 2165796c8dcSSimon Schubert closure is statically allocated and this does nothing. 2175796c8dcSSimon Schubert 2185796c8dcSSimon Schubert This may be NULL, in which case no action is taken to free 2195796c8dcSSimon Schubert VALUE's closure. */ 2205796c8dcSSimon Schubert void (*free_closure) (struct value *v); 2215796c8dcSSimon Schubert }; 2225796c8dcSSimon Schubert 2235796c8dcSSimon Schubert /* Create a computed lvalue, with type TYPE, function pointers FUNCS, 2245796c8dcSSimon Schubert and closure CLOSURE. */ 2255796c8dcSSimon Schubert 2265796c8dcSSimon Schubert extern struct value *allocate_computed_value (struct type *type, 227a45ae5f8SJohn Marino const struct lval_funcs *funcs, 2285796c8dcSSimon Schubert void *closure); 2295796c8dcSSimon Schubert 230*ef5ccd6cSJohn Marino /* Helper function to check the validity of some bits of a value. 231*ef5ccd6cSJohn Marino 232*ef5ccd6cSJohn Marino If TYPE represents some aggregate type (e.g., a structure), return 1. 233*ef5ccd6cSJohn Marino 234*ef5ccd6cSJohn Marino Otherwise, any of the bytes starting at OFFSET and extending for 235*ef5ccd6cSJohn Marino TYPE_LENGTH(TYPE) bytes are invalid, print a message to STREAM and 236*ef5ccd6cSJohn Marino return 0. The checking is done using FUNCS. 237*ef5ccd6cSJohn Marino 238*ef5ccd6cSJohn Marino Otherwise, return 1. */ 239*ef5ccd6cSJohn Marino 240*ef5ccd6cSJohn Marino extern int valprint_check_validity (struct ui_file *stream, struct type *type, 241*ef5ccd6cSJohn Marino int embedded_offset, 242*ef5ccd6cSJohn Marino const struct value *val); 243*ef5ccd6cSJohn Marino 244a45ae5f8SJohn Marino extern struct value *allocate_optimized_out_value (struct type *type); 245a45ae5f8SJohn Marino 2465796c8dcSSimon Schubert /* If VALUE is lval_computed, return its lval_funcs structure. */ 2475796c8dcSSimon Schubert 248a45ae5f8SJohn Marino extern const struct lval_funcs *value_computed_funcs (const struct value *); 2495796c8dcSSimon Schubert 2505796c8dcSSimon Schubert /* If VALUE is lval_computed, return its closure. The meaning of the 2515796c8dcSSimon Schubert returned value depends on the functions VALUE uses. */ 2525796c8dcSSimon Schubert 253cf7f2e2dSJohn Marino extern void *value_computed_closure (const struct value *value); 2545796c8dcSSimon Schubert 2555796c8dcSSimon Schubert /* If zero, contents of this value are in the contents field. If 2565796c8dcSSimon Schubert nonzero, contents are in inferior. If the lval field is lval_memory, 2575796c8dcSSimon Schubert the contents are in inferior memory at location.address plus offset. 2585796c8dcSSimon Schubert The lval field may also be lval_register. 2595796c8dcSSimon Schubert 2605796c8dcSSimon Schubert WARNING: This field is used by the code which handles watchpoints 2615796c8dcSSimon Schubert (see breakpoint.c) to decide whether a particular value can be 2625796c8dcSSimon Schubert watched by hardware watchpoints. If the lazy flag is set for some 2635796c8dcSSimon Schubert member of a value chain, it is assumed that this member of the 2645796c8dcSSimon Schubert chain doesn't need to be watched as part of watching the value 2655796c8dcSSimon Schubert itself. This is how GDB avoids watching the entire struct or array 2665796c8dcSSimon Schubert when the user wants to watch a single struct member or array 2675796c8dcSSimon Schubert element. If you ever change the way lazy flag is set and reset, be 2685796c8dcSSimon Schubert sure to consider this use as well! */ 2695796c8dcSSimon Schubert 2705796c8dcSSimon Schubert extern int value_lazy (struct value *); 2715796c8dcSSimon Schubert extern void set_value_lazy (struct value *value, int val); 2725796c8dcSSimon Schubert 2735796c8dcSSimon Schubert extern int value_stack (struct value *); 2745796c8dcSSimon Schubert extern void set_value_stack (struct value *value, int val); 2755796c8dcSSimon Schubert 2765796c8dcSSimon Schubert /* value_contents() and value_contents_raw() both return the address 2775796c8dcSSimon Schubert of the gdb buffer used to hold a copy of the contents of the lval. 2785796c8dcSSimon Schubert value_contents() is used when the contents of the buffer are needed 2795796c8dcSSimon Schubert -- it uses value_fetch_lazy() to load the buffer from the process 2805796c8dcSSimon Schubert being debugged if it hasn't already been loaded 2815796c8dcSSimon Schubert (value_contents_writeable() is used when a writeable but fetched 2825796c8dcSSimon Schubert buffer is required).. value_contents_raw() is used when data is 2835796c8dcSSimon Schubert being stored into the buffer, or when it is certain that the 2845796c8dcSSimon Schubert contents of the buffer are valid. 2855796c8dcSSimon Schubert 2865796c8dcSSimon Schubert Note: The contents pointer is adjusted by the offset required to 2875796c8dcSSimon Schubert get to the real subobject, if the value happens to represent 2885796c8dcSSimon Schubert something embedded in a larger run-time object. */ 2895796c8dcSSimon Schubert 2905796c8dcSSimon Schubert extern gdb_byte *value_contents_raw (struct value *); 2915796c8dcSSimon Schubert 2925796c8dcSSimon Schubert /* Actual contents of the value. For use of this value; setting it 2935796c8dcSSimon Schubert uses the stuff above. Not valid if lazy is nonzero. Target 2945796c8dcSSimon Schubert byte-order. We force it to be aligned properly for any possible 2955796c8dcSSimon Schubert value. Note that a value therefore extends beyond what is 2965796c8dcSSimon Schubert declared here. */ 2975796c8dcSSimon Schubert 2985796c8dcSSimon Schubert extern const gdb_byte *value_contents (struct value *); 2995796c8dcSSimon Schubert extern gdb_byte *value_contents_writeable (struct value *); 3005796c8dcSSimon Schubert 3015796c8dcSSimon Schubert /* The ALL variants of the above two macros do not adjust the returned 3025796c8dcSSimon Schubert pointer by the embedded_offset value. */ 3035796c8dcSSimon Schubert 3045796c8dcSSimon Schubert extern gdb_byte *value_contents_all_raw (struct value *); 3055796c8dcSSimon Schubert extern const gdb_byte *value_contents_all (struct value *); 3065796c8dcSSimon Schubert 307cf7f2e2dSJohn Marino /* Like value_contents_all, but does not require that the returned 308cf7f2e2dSJohn Marino bits be valid. This should only be used in situations where you 309cf7f2e2dSJohn Marino plan to check the validity manually. */ 310cf7f2e2dSJohn Marino extern const gdb_byte *value_contents_for_printing (struct value *value); 311cf7f2e2dSJohn Marino 312c50c785cSJohn Marino /* Like value_contents_for_printing, but accepts a constant value 313c50c785cSJohn Marino pointer. Unlike value_contents_for_printing however, the pointed 314c50c785cSJohn Marino value must _not_ be lazy. */ 315c50c785cSJohn Marino extern const gdb_byte * 316c50c785cSJohn Marino value_contents_for_printing_const (const struct value *value); 317c50c785cSJohn Marino 3185796c8dcSSimon Schubert extern int value_fetch_lazy (struct value *val); 3195796c8dcSSimon Schubert extern int value_contents_equal (struct value *val1, struct value *val2); 3205796c8dcSSimon Schubert 3215796c8dcSSimon Schubert /* If nonzero, this is the value of a variable which does not actually 3225796c8dcSSimon Schubert exist in the program. */ 3235796c8dcSSimon Schubert extern int value_optimized_out (struct value *value); 3245796c8dcSSimon Schubert extern void set_value_optimized_out (struct value *value, int val); 3255796c8dcSSimon Schubert 326cf7f2e2dSJohn Marino /* Like value_optimized_out, but return false if any bit in the object 327cf7f2e2dSJohn Marino is valid. */ 328cf7f2e2dSJohn Marino extern int value_entirely_optimized_out (const struct value *value); 329cf7f2e2dSJohn Marino 3305796c8dcSSimon Schubert /* Set or return field indicating whether a variable is initialized or 3315796c8dcSSimon Schubert not, based on debugging information supplied by the compiler. 3325796c8dcSSimon Schubert 1 = initialized; 0 = uninitialized. */ 3335796c8dcSSimon Schubert extern int value_initialized (struct value *); 3345796c8dcSSimon Schubert extern void set_value_initialized (struct value *, int); 3355796c8dcSSimon Schubert 3365796c8dcSSimon Schubert /* Set COMPONENT's location as appropriate for a component of WHOLE 3375796c8dcSSimon Schubert --- regardless of what kind of lvalue WHOLE is. */ 3385796c8dcSSimon Schubert extern void set_value_component_location (struct value *component, 339cf7f2e2dSJohn Marino const struct value *whole); 3405796c8dcSSimon Schubert 3415796c8dcSSimon Schubert /* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a 3425796c8dcSSimon Schubert single value might have multiple LVALs), this hacked interface is 3435796c8dcSSimon Schubert limited to just the first PIECE. Expect further change. */ 3445796c8dcSSimon Schubert /* Type of value; either not an lval, or one of the various different 3455796c8dcSSimon Schubert possible kinds of lval. */ 3465796c8dcSSimon Schubert extern enum lval_type *deprecated_value_lval_hack (struct value *); 3475796c8dcSSimon Schubert #define VALUE_LVAL(val) (*deprecated_value_lval_hack (val)) 3485796c8dcSSimon Schubert 349a45ae5f8SJohn Marino /* Like VALUE_LVAL, except the parameter can be const. */ 350a45ae5f8SJohn Marino extern enum lval_type value_lval_const (const struct value *value); 351a45ae5f8SJohn Marino 3525796c8dcSSimon Schubert /* If lval == lval_memory, return the address in the inferior. If 3535796c8dcSSimon Schubert lval == lval_register, return the byte offset into the registers 3545796c8dcSSimon Schubert structure. Otherwise, return 0. The returned address 3555796c8dcSSimon Schubert includes the offset, if any. */ 356c50c785cSJohn Marino extern CORE_ADDR value_address (const struct value *); 3575796c8dcSSimon Schubert 3585796c8dcSSimon Schubert /* Like value_address, except the result does not include value's 3595796c8dcSSimon Schubert offset. */ 3605796c8dcSSimon Schubert extern CORE_ADDR value_raw_address (struct value *); 3615796c8dcSSimon Schubert 3625796c8dcSSimon Schubert /* Set the address of a value. */ 3635796c8dcSSimon Schubert extern void set_value_address (struct value *, CORE_ADDR); 3645796c8dcSSimon Schubert 3655796c8dcSSimon Schubert /* Pointer to internal variable. */ 3665796c8dcSSimon Schubert extern struct internalvar **deprecated_value_internalvar_hack (struct value *); 3675796c8dcSSimon Schubert #define VALUE_INTERNALVAR(val) (*deprecated_value_internalvar_hack (val)) 3685796c8dcSSimon Schubert 3695796c8dcSSimon Schubert /* Frame register value is relative to. This will be described in the 3705796c8dcSSimon Schubert lval enum above as "lval_register". */ 3715796c8dcSSimon Schubert extern struct frame_id *deprecated_value_frame_id_hack (struct value *); 3725796c8dcSSimon Schubert #define VALUE_FRAME_ID(val) (*deprecated_value_frame_id_hack (val)) 3735796c8dcSSimon Schubert 3745796c8dcSSimon Schubert /* Register number if the value is from a register. */ 3755796c8dcSSimon Schubert extern short *deprecated_value_regnum_hack (struct value *); 3765796c8dcSSimon Schubert #define VALUE_REGNUM(val) (*deprecated_value_regnum_hack (val)) 3775796c8dcSSimon Schubert 378a45ae5f8SJohn Marino /* Return value after lval_funcs->coerce_ref (after check_typedef). Return 379a45ae5f8SJohn Marino NULL if lval_funcs->coerce_ref is not applicable for whatever reason. */ 380a45ae5f8SJohn Marino 381a45ae5f8SJohn Marino extern struct value *coerce_ref_if_computed (const struct value *arg); 382a45ae5f8SJohn Marino 383*ef5ccd6cSJohn Marino /* Setup a new value type and enclosing value type for dereferenced value VALUE. 384*ef5ccd6cSJohn Marino ENC_TYPE is the new enclosing type that should be set. ORIGINAL_TYPE and 385*ef5ccd6cSJohn Marino ORIGINAL_VAL are the type and value of the original reference or pointer. 386*ef5ccd6cSJohn Marino 387*ef5ccd6cSJohn Marino Note, that VALUE is modified by this function. 388*ef5ccd6cSJohn Marino 389*ef5ccd6cSJohn Marino It is a common implementation for coerce_ref and value_ind. */ 390*ef5ccd6cSJohn Marino 391*ef5ccd6cSJohn Marino extern struct value * readjust_indirect_value_type (struct value *value, 392*ef5ccd6cSJohn Marino struct type *enc_type, 393*ef5ccd6cSJohn Marino struct type *original_type, 394*ef5ccd6cSJohn Marino struct value *original_val); 395*ef5ccd6cSJohn Marino 3965796c8dcSSimon Schubert /* Convert a REF to the object referenced. */ 3975796c8dcSSimon Schubert 3985796c8dcSSimon Schubert extern struct value *coerce_ref (struct value *value); 3995796c8dcSSimon Schubert 4005796c8dcSSimon Schubert /* If ARG is an array, convert it to a pointer. 4015796c8dcSSimon Schubert If ARG is a function, convert it to a function pointer. 4025796c8dcSSimon Schubert 4035796c8dcSSimon Schubert References are dereferenced. */ 4045796c8dcSSimon Schubert 4055796c8dcSSimon Schubert extern struct value *coerce_array (struct value *value); 4065796c8dcSSimon Schubert 407cf7f2e2dSJohn Marino /* Given a value, determine whether the bits starting at OFFSET and 408cf7f2e2dSJohn Marino extending for LENGTH bits are valid. This returns nonzero if all 409cf7f2e2dSJohn Marino bits in the given range are valid, zero if any bit is invalid. */ 410cf7f2e2dSJohn Marino 411cf7f2e2dSJohn Marino extern int value_bits_valid (const struct value *value, 412cf7f2e2dSJohn Marino int offset, int length); 413cf7f2e2dSJohn Marino 414c50c785cSJohn Marino /* Given a value, determine whether the bits starting at OFFSET and 415c50c785cSJohn Marino extending for LENGTH bits are a synthetic pointer. */ 416c50c785cSJohn Marino 417c50c785cSJohn Marino extern int value_bits_synthetic_pointer (const struct value *value, 418c50c785cSJohn Marino int offset, int length); 419c50c785cSJohn Marino 420c50c785cSJohn Marino /* Given a value, determine whether the contents bytes starting at 421c50c785cSJohn Marino OFFSET and extending for LENGTH bytes are available. This returns 422c50c785cSJohn Marino nonzero if all bytes in the given range are available, zero if any 423c50c785cSJohn Marino byte is unavailable. */ 424c50c785cSJohn Marino 425c50c785cSJohn Marino extern int value_bytes_available (const struct value *value, 426c50c785cSJohn Marino int offset, int length); 427c50c785cSJohn Marino 428c50c785cSJohn Marino /* Like value_bytes_available, but return false if any byte in the 429c50c785cSJohn Marino whole object is unavailable. */ 430c50c785cSJohn Marino extern int value_entirely_available (struct value *value); 431c50c785cSJohn Marino 432c50c785cSJohn Marino /* Mark VALUE's content bytes starting at OFFSET and extending for 433c50c785cSJohn Marino LENGTH bytes as unavailable. */ 434c50c785cSJohn Marino 435c50c785cSJohn Marino extern void mark_value_bytes_unavailable (struct value *value, 436c50c785cSJohn Marino int offset, int length); 437c50c785cSJohn Marino 438c50c785cSJohn Marino /* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with 439c50c785cSJohn Marino LENGTH bytes of VAL2's contents starting at OFFSET2. 440c50c785cSJohn Marino 441c50c785cSJohn Marino Note that "contents" refers to the whole value's contents 442c50c785cSJohn Marino (value_contents_all), without any embedded offset adjustment. For 443c50c785cSJohn Marino example, to compare a complete object value with itself, including 444c50c785cSJohn Marino its enclosing type chunk, you'd do: 445c50c785cSJohn Marino 446c50c785cSJohn Marino int len = TYPE_LENGTH (check_typedef (value_enclosing_type (val))); 447c50c785cSJohn Marino value_available_contents (val, 0, val, 0, len); 448c50c785cSJohn Marino 449c50c785cSJohn Marino Returns true iff the set of available contents match. Unavailable 450c50c785cSJohn Marino contents compare equal with unavailable contents, and different 451c50c785cSJohn Marino with any available byte. For example, if 'x's represent an 452c50c785cSJohn Marino unavailable byte, and 'V' and 'Z' represent different available 453c50c785cSJohn Marino bytes, in a value with length 16: 454c50c785cSJohn Marino 455c50c785cSJohn Marino offset: 0 4 8 12 16 456c50c785cSJohn Marino contents: xxxxVVVVxxxxVVZZ 457c50c785cSJohn Marino 458c50c785cSJohn Marino then: 459c50c785cSJohn Marino 460c50c785cSJohn Marino value_available_contents_eq(val, 0, val, 8, 6) => 1 461c50c785cSJohn Marino value_available_contents_eq(val, 0, val, 4, 4) => 1 462c50c785cSJohn Marino value_available_contents_eq(val, 0, val, 8, 8) => 0 463c50c785cSJohn Marino value_available_contents_eq(val, 4, val, 12, 2) => 1 464c50c785cSJohn Marino value_available_contents_eq(val, 4, val, 12, 4) => 0 465c50c785cSJohn Marino value_available_contents_eq(val, 3, val, 4, 4) => 0 466*ef5ccd6cSJohn Marino 467*ef5ccd6cSJohn Marino We only know whether a value chunk is available if we've tried to 468*ef5ccd6cSJohn Marino read it. As this routine is used by printing routines, which may 469*ef5ccd6cSJohn Marino be printing values in the value history, long after the inferior is 470*ef5ccd6cSJohn Marino gone, it works with const values. Therefore, this routine must not 471*ef5ccd6cSJohn Marino be called with lazy values. */ 472c50c785cSJohn Marino 473c50c785cSJohn Marino extern int value_available_contents_eq (const struct value *val1, int offset1, 474c50c785cSJohn Marino const struct value *val2, int offset2, 475c50c785cSJohn Marino int length); 476c50c785cSJohn Marino 477c50c785cSJohn Marino /* Read LENGTH bytes of memory starting at MEMADDR into BUFFER, which 478c50c785cSJohn Marino is (or will be copied to) VAL's contents buffer offset by 479c50c785cSJohn Marino EMBEDDED_OFFSET (that is, to &VAL->contents[EMBEDDED_OFFSET]). 480c50c785cSJohn Marino Marks value contents ranges as unavailable if the corresponding 481c50c785cSJohn Marino memory is likewise unavailable. STACK indicates whether the memory 482c50c785cSJohn Marino is known to be stack memory. */ 483c50c785cSJohn Marino 484c50c785cSJohn Marino extern void read_value_memory (struct value *val, int embedded_offset, 485c50c785cSJohn Marino int stack, CORE_ADDR memaddr, 486c50c785cSJohn Marino gdb_byte *buffer, size_t length); 487c50c785cSJohn Marino 488*ef5ccd6cSJohn Marino /* Cast SCALAR_VALUE to the element type of VECTOR_TYPE, then replicate 489*ef5ccd6cSJohn Marino into each element of a new vector value with VECTOR_TYPE. */ 490*ef5ccd6cSJohn Marino 491*ef5ccd6cSJohn Marino struct value *value_vector_widen (struct value *scalar_value, 492*ef5ccd6cSJohn Marino struct type *vector_type); 493*ef5ccd6cSJohn Marino 4945796c8dcSSimon Schubert 4955796c8dcSSimon Schubert 4965796c8dcSSimon Schubert #include "symtab.h" 4975796c8dcSSimon Schubert #include "gdbtypes.h" 4985796c8dcSSimon Schubert #include "expression.h" 4995796c8dcSSimon Schubert 5005796c8dcSSimon Schubert struct frame_info; 5015796c8dcSSimon Schubert struct fn_field; 5025796c8dcSSimon Schubert 503*ef5ccd6cSJohn Marino extern int print_address_demangle (const struct value_print_options *, 504*ef5ccd6cSJohn Marino struct gdbarch *, CORE_ADDR, 5055796c8dcSSimon Schubert struct ui_file *, int); 5065796c8dcSSimon Schubert 5075796c8dcSSimon Schubert extern LONGEST value_as_long (struct value *val); 5085796c8dcSSimon Schubert extern DOUBLEST value_as_double (struct value *val); 5095796c8dcSSimon Schubert extern CORE_ADDR value_as_address (struct value *val); 5105796c8dcSSimon Schubert 5115796c8dcSSimon Schubert extern LONGEST unpack_long (struct type *type, const gdb_byte *valaddr); 5125796c8dcSSimon Schubert extern DOUBLEST unpack_double (struct type *type, const gdb_byte *valaddr, 5135796c8dcSSimon Schubert int *invp); 5145796c8dcSSimon Schubert extern CORE_ADDR unpack_pointer (struct type *type, const gdb_byte *valaddr); 515c50c785cSJohn Marino 516c50c785cSJohn Marino extern int unpack_value_bits_as_long (struct type *field_type, 517c50c785cSJohn Marino const gdb_byte *valaddr, 518c50c785cSJohn Marino int embedded_offset, int bitpos, 519c50c785cSJohn Marino int bitsize, 520c50c785cSJohn Marino const struct value *original_value, 521c50c785cSJohn Marino LONGEST *result); 522c50c785cSJohn Marino 5235796c8dcSSimon Schubert extern LONGEST unpack_field_as_long (struct type *type, 5245796c8dcSSimon Schubert const gdb_byte *valaddr, 5255796c8dcSSimon Schubert int fieldno); 526c50c785cSJohn Marino extern int unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr, 527c50c785cSJohn Marino int embedded_offset, int fieldno, 528c50c785cSJohn Marino const struct value *val, LONGEST *result); 529c50c785cSJohn Marino 530c50c785cSJohn Marino extern struct value *value_field_bitfield (struct type *type, int fieldno, 531c50c785cSJohn Marino const gdb_byte *valaddr, 532c50c785cSJohn Marino int embedded_offset, 533c50c785cSJohn Marino const struct value *val); 5345796c8dcSSimon Schubert 5355796c8dcSSimon Schubert extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num); 5365796c8dcSSimon Schubert 5375796c8dcSSimon Schubert extern struct value *value_from_longest (struct type *type, LONGEST num); 538cf7f2e2dSJohn Marino extern struct value *value_from_ulongest (struct type *type, ULONGEST num); 5395796c8dcSSimon Schubert extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr); 5405796c8dcSSimon Schubert extern struct value *value_from_double (struct type *type, DOUBLEST num); 5415796c8dcSSimon Schubert extern struct value *value_from_decfloat (struct type *type, 5425796c8dcSSimon Schubert const gdb_byte *decbytes); 543c50c785cSJohn Marino extern struct value *value_from_history_ref (char *, char **); 5445796c8dcSSimon Schubert 5455796c8dcSSimon Schubert extern struct value *value_at (struct type *type, CORE_ADDR addr); 5465796c8dcSSimon Schubert extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); 5475796c8dcSSimon Schubert 5485796c8dcSSimon Schubert extern struct value *value_from_contents_and_address (struct type *, 5495796c8dcSSimon Schubert const gdb_byte *, 5505796c8dcSSimon Schubert CORE_ADDR); 551a45ae5f8SJohn Marino extern struct value *value_from_contents (struct type *, const gdb_byte *); 5525796c8dcSSimon Schubert 5535796c8dcSSimon Schubert extern struct value *default_value_from_register (struct type *type, 5545796c8dcSSimon Schubert int regnum, 5555796c8dcSSimon Schubert struct frame_info *frame); 5565796c8dcSSimon Schubert 557a45ae5f8SJohn Marino extern void read_frame_register_value (struct value *value, 558a45ae5f8SJohn Marino struct frame_info *frame); 559a45ae5f8SJohn Marino 5605796c8dcSSimon Schubert extern struct value *value_from_register (struct type *type, int regnum, 5615796c8dcSSimon Schubert struct frame_info *frame); 5625796c8dcSSimon Schubert 5635796c8dcSSimon Schubert extern CORE_ADDR address_from_register (struct type *type, int regnum, 5645796c8dcSSimon Schubert struct frame_info *frame); 5655796c8dcSSimon Schubert 566a45ae5f8SJohn Marino extern struct value *value_of_variable (struct symbol *var, 567a45ae5f8SJohn Marino const struct block *b); 5685796c8dcSSimon Schubert 569*ef5ccd6cSJohn Marino extern struct value *address_of_variable (struct symbol *var, 570*ef5ccd6cSJohn Marino const struct block *b); 5715796c8dcSSimon Schubert 5725796c8dcSSimon Schubert extern struct value *value_of_register (int regnum, struct frame_info *frame); 5735796c8dcSSimon Schubert 5745796c8dcSSimon Schubert struct value *value_of_register_lazy (struct frame_info *frame, int regnum); 5755796c8dcSSimon Schubert 5765796c8dcSSimon Schubert extern int symbol_read_needs_frame (struct symbol *); 5775796c8dcSSimon Schubert 5785796c8dcSSimon Schubert extern struct value *read_var_value (struct symbol *var, 5795796c8dcSSimon Schubert struct frame_info *frame); 5805796c8dcSSimon Schubert 581*ef5ccd6cSJohn Marino extern struct value *default_read_var_value (struct symbol *var, 582*ef5ccd6cSJohn Marino struct frame_info *frame); 583*ef5ccd6cSJohn Marino 5845796c8dcSSimon Schubert extern struct value *allocate_value (struct type *type); 5855796c8dcSSimon Schubert extern struct value *allocate_value_lazy (struct type *type); 5865796c8dcSSimon Schubert extern void allocate_value_contents (struct value *value); 587c50c785cSJohn Marino extern void value_contents_copy (struct value *dst, int dst_offset, 588c50c785cSJohn Marino struct value *src, int src_offset, 589c50c785cSJohn Marino int length); 590c50c785cSJohn Marino extern void value_contents_copy_raw (struct value *dst, int dst_offset, 591c50c785cSJohn Marino struct value *src, int src_offset, 592c50c785cSJohn Marino int length); 5935796c8dcSSimon Schubert 5945796c8dcSSimon Schubert extern struct value *allocate_repeat_value (struct type *type, int count); 5955796c8dcSSimon Schubert 5965796c8dcSSimon Schubert extern struct value *value_mark (void); 5975796c8dcSSimon Schubert 5985796c8dcSSimon Schubert extern void value_free_to_mark (struct value *mark); 5995796c8dcSSimon Schubert 600*ef5ccd6cSJohn Marino extern struct value *value_cstring (char *ptr, ssize_t len, 6015796c8dcSSimon Schubert struct type *char_type); 602*ef5ccd6cSJohn Marino extern struct value *value_string (char *ptr, ssize_t len, 6035796c8dcSSimon Schubert struct type *char_type); 6045796c8dcSSimon Schubert 6055796c8dcSSimon Schubert extern struct value *value_array (int lowbound, int highbound, 6065796c8dcSSimon Schubert struct value **elemvec); 6075796c8dcSSimon Schubert 6085796c8dcSSimon Schubert extern struct value *value_concat (struct value *arg1, struct value *arg2); 6095796c8dcSSimon Schubert 6105796c8dcSSimon Schubert extern struct value *value_binop (struct value *arg1, struct value *arg2, 6115796c8dcSSimon Schubert enum exp_opcode op); 6125796c8dcSSimon Schubert 6135796c8dcSSimon Schubert extern struct value *value_ptradd (struct value *arg1, LONGEST arg2); 6145796c8dcSSimon Schubert 6155796c8dcSSimon Schubert extern LONGEST value_ptrdiff (struct value *arg1, struct value *arg2); 6165796c8dcSSimon Schubert 6175796c8dcSSimon Schubert extern int value_must_coerce_to_target (struct value *arg1); 6185796c8dcSSimon Schubert 6195796c8dcSSimon Schubert extern struct value *value_coerce_to_target (struct value *arg1); 6205796c8dcSSimon Schubert 6215796c8dcSSimon Schubert extern struct value *value_coerce_array (struct value *arg1); 6225796c8dcSSimon Schubert 6235796c8dcSSimon Schubert extern struct value *value_coerce_function (struct value *arg1); 6245796c8dcSSimon Schubert 6255796c8dcSSimon Schubert extern struct value *value_ind (struct value *arg1); 6265796c8dcSSimon Schubert 6275796c8dcSSimon Schubert extern struct value *value_addr (struct value *arg1); 6285796c8dcSSimon Schubert 6295796c8dcSSimon Schubert extern struct value *value_ref (struct value *arg1); 6305796c8dcSSimon Schubert 6315796c8dcSSimon Schubert extern struct value *value_assign (struct value *toval, 6325796c8dcSSimon Schubert struct value *fromval); 6335796c8dcSSimon Schubert 6345796c8dcSSimon Schubert extern struct value *value_pos (struct value *arg1); 6355796c8dcSSimon Schubert 6365796c8dcSSimon Schubert extern struct value *value_neg (struct value *arg1); 6375796c8dcSSimon Schubert 6385796c8dcSSimon Schubert extern struct value *value_complement (struct value *arg1); 6395796c8dcSSimon Schubert 6405796c8dcSSimon Schubert extern struct value *value_struct_elt (struct value **argp, 6415796c8dcSSimon Schubert struct value **args, 642cf7f2e2dSJohn Marino const char *name, int *static_memfuncp, 643cf7f2e2dSJohn Marino const char *err); 6445796c8dcSSimon Schubert 6455796c8dcSSimon Schubert extern struct value *value_aggregate_elt (struct type *curtype, 6465796c8dcSSimon Schubert char *name, 647cf7f2e2dSJohn Marino struct type *expect_type, 6485796c8dcSSimon Schubert int want_address, 6495796c8dcSSimon Schubert enum noside noside); 6505796c8dcSSimon Schubert 6515796c8dcSSimon Schubert extern struct value *value_static_field (struct type *type, int fieldno); 6525796c8dcSSimon Schubert 653cf7f2e2dSJohn Marino enum oload_search_type { NON_METHOD, METHOD, BOTH }; 654cf7f2e2dSJohn Marino 655a45ae5f8SJohn Marino extern int find_overload_match (struct value **args, int nargs, 656cf7f2e2dSJohn Marino const char *name, 657*ef5ccd6cSJohn Marino enum oload_search_type method, 6585796c8dcSSimon Schubert struct value **objp, struct symbol *fsym, 6595796c8dcSSimon Schubert struct value **valp, struct symbol **symp, 660cf7f2e2dSJohn Marino int *staticp, const int no_adl); 6615796c8dcSSimon Schubert 6625796c8dcSSimon Schubert extern struct value *value_field (struct value *arg1, int fieldno); 6635796c8dcSSimon Schubert 6645796c8dcSSimon Schubert extern struct value *value_primitive_field (struct value *arg1, int offset, 6655796c8dcSSimon Schubert int fieldno, 6665796c8dcSSimon Schubert struct type *arg_type); 6675796c8dcSSimon Schubert 6685796c8dcSSimon Schubert 669*ef5ccd6cSJohn Marino extern struct type *value_rtti_indirect_type (struct value *, int *, int *, 6705796c8dcSSimon Schubert int *); 6715796c8dcSSimon Schubert 6725796c8dcSSimon Schubert extern struct value *value_full_object (struct value *, struct type *, int, 6735796c8dcSSimon Schubert int, int); 6745796c8dcSSimon Schubert 675*ef5ccd6cSJohn Marino extern struct value *value_cast_pointers (struct type *, struct value *, int); 6765796c8dcSSimon Schubert 6775796c8dcSSimon Schubert extern struct value *value_cast (struct type *type, struct value *arg2); 6785796c8dcSSimon Schubert 679cf7f2e2dSJohn Marino extern struct value *value_reinterpret_cast (struct type *type, 680cf7f2e2dSJohn Marino struct value *arg); 681cf7f2e2dSJohn Marino 682cf7f2e2dSJohn Marino extern struct value *value_dynamic_cast (struct type *type, struct value *arg); 683cf7f2e2dSJohn Marino 6845796c8dcSSimon Schubert extern struct value *value_zero (struct type *type, enum lval_type lv); 6855796c8dcSSimon Schubert 686a45ae5f8SJohn Marino extern struct value *value_one (struct type *type); 6875796c8dcSSimon Schubert 6885796c8dcSSimon Schubert extern struct value *value_repeat (struct value *arg1, int count); 6895796c8dcSSimon Schubert 6905796c8dcSSimon Schubert extern struct value *value_subscript (struct value *array, LONGEST index); 6915796c8dcSSimon Schubert 6925796c8dcSSimon Schubert extern struct value *value_bitstring_subscript (struct type *type, 6935796c8dcSSimon Schubert struct value *bitstring, 6945796c8dcSSimon Schubert LONGEST index); 6955796c8dcSSimon Schubert 6965796c8dcSSimon Schubert extern struct value *register_value_being_returned (struct type *valtype, 6975796c8dcSSimon Schubert struct regcache *retbuf); 6985796c8dcSSimon Schubert 6995796c8dcSSimon Schubert extern int value_in (struct value *element, struct value *set); 7005796c8dcSSimon Schubert 7015796c8dcSSimon Schubert extern int value_bit_index (struct type *type, const gdb_byte *addr, 7025796c8dcSSimon Schubert int index); 7035796c8dcSSimon Schubert 704*ef5ccd6cSJohn Marino extern enum return_value_convention 705*ef5ccd6cSJohn Marino struct_return_convention (struct gdbarch *gdbarch, struct value *function, 706*ef5ccd6cSJohn Marino struct type *value_type); 707*ef5ccd6cSJohn Marino 7085796c8dcSSimon Schubert extern int using_struct_return (struct gdbarch *gdbarch, 709*ef5ccd6cSJohn Marino struct value *function, 7105796c8dcSSimon Schubert struct type *value_type); 7115796c8dcSSimon Schubert 7125796c8dcSSimon Schubert extern struct value *evaluate_expression (struct expression *exp); 7135796c8dcSSimon Schubert 7145796c8dcSSimon Schubert extern struct value *evaluate_type (struct expression *exp); 7155796c8dcSSimon Schubert 7165796c8dcSSimon Schubert extern struct value *evaluate_subexp (struct type *expect_type, 7175796c8dcSSimon Schubert struct expression *exp, 7185796c8dcSSimon Schubert int *pos, enum noside noside); 7195796c8dcSSimon Schubert 7205796c8dcSSimon Schubert extern struct value *evaluate_subexpression_type (struct expression *exp, 7215796c8dcSSimon Schubert int subexp); 7225796c8dcSSimon Schubert 723cf7f2e2dSJohn Marino extern void fetch_subexp_value (struct expression *exp, int *pc, 724cf7f2e2dSJohn Marino struct value **valp, struct value **resultp, 725cf7f2e2dSJohn Marino struct value **val_chain); 726cf7f2e2dSJohn Marino 7275796c8dcSSimon Schubert extern char *extract_field_op (struct expression *exp, int *subexp); 7285796c8dcSSimon Schubert 7295796c8dcSSimon Schubert extern struct value *evaluate_subexp_with_coercion (struct expression *, 7305796c8dcSSimon Schubert int *, enum noside); 7315796c8dcSSimon Schubert 732*ef5ccd6cSJohn Marino extern struct value *parse_and_eval (const char *exp); 7335796c8dcSSimon Schubert 734*ef5ccd6cSJohn Marino extern struct value *parse_to_comma_and_eval (const char **expp); 7355796c8dcSSimon Schubert 7365796c8dcSSimon Schubert extern struct type *parse_and_eval_type (char *p, int length); 7375796c8dcSSimon Schubert 738*ef5ccd6cSJohn Marino extern CORE_ADDR parse_and_eval_address (const char *exp); 7395796c8dcSSimon Schubert 7405796c8dcSSimon Schubert extern LONGEST parse_and_eval_long (char *exp); 7415796c8dcSSimon Schubert 7425796c8dcSSimon Schubert extern void unop_promote (const struct language_defn *language, 7435796c8dcSSimon Schubert struct gdbarch *gdbarch, 7445796c8dcSSimon Schubert struct value **arg1); 7455796c8dcSSimon Schubert 7465796c8dcSSimon Schubert extern void binop_promote (const struct language_defn *language, 7475796c8dcSSimon Schubert struct gdbarch *gdbarch, 7485796c8dcSSimon Schubert struct value **arg1, struct value **arg2); 7495796c8dcSSimon Schubert 7505796c8dcSSimon Schubert extern struct value *access_value_history (int num); 7515796c8dcSSimon Schubert 7525796c8dcSSimon Schubert extern struct value *value_of_internalvar (struct gdbarch *gdbarch, 7535796c8dcSSimon Schubert struct internalvar *var); 7545796c8dcSSimon Schubert 7555796c8dcSSimon Schubert extern int get_internalvar_integer (struct internalvar *var, LONGEST *l); 7565796c8dcSSimon Schubert 7575796c8dcSSimon Schubert extern void set_internalvar (struct internalvar *var, struct value *val); 7585796c8dcSSimon Schubert 7595796c8dcSSimon Schubert extern void set_internalvar_integer (struct internalvar *var, LONGEST l); 7605796c8dcSSimon Schubert 7615796c8dcSSimon Schubert extern void set_internalvar_string (struct internalvar *var, 7625796c8dcSSimon Schubert const char *string); 7635796c8dcSSimon Schubert 7645796c8dcSSimon Schubert extern void clear_internalvar (struct internalvar *var); 7655796c8dcSSimon Schubert 7665796c8dcSSimon Schubert extern void set_internalvar_component (struct internalvar *var, 7675796c8dcSSimon Schubert int offset, 7685796c8dcSSimon Schubert int bitpos, int bitsize, 7695796c8dcSSimon Schubert struct value *newvalue); 7705796c8dcSSimon Schubert 7715796c8dcSSimon Schubert extern struct internalvar *lookup_only_internalvar (const char *name); 7725796c8dcSSimon Schubert 7735796c8dcSSimon Schubert extern struct internalvar *create_internalvar (const char *name); 7745796c8dcSSimon Schubert 775*ef5ccd6cSJohn Marino extern VEC (char_ptr) *complete_internalvar (const char *name); 776*ef5ccd6cSJohn Marino 777*ef5ccd6cSJohn Marino /* An internalvar can be dynamically computed by supplying a vector of 778*ef5ccd6cSJohn Marino function pointers to perform various operations. */ 779*ef5ccd6cSJohn Marino 780*ef5ccd6cSJohn Marino struct internalvar_funcs 781*ef5ccd6cSJohn Marino { 782*ef5ccd6cSJohn Marino /* Compute the value of the variable. The DATA argument passed to 783*ef5ccd6cSJohn Marino the function is the same argument that was passed to 784*ef5ccd6cSJohn Marino `create_internalvar_type_lazy'. */ 785*ef5ccd6cSJohn Marino 786*ef5ccd6cSJohn Marino struct value *(*make_value) (struct gdbarch *arch, 787*ef5ccd6cSJohn Marino struct internalvar *var, 788*ef5ccd6cSJohn Marino void *data); 789*ef5ccd6cSJohn Marino 790*ef5ccd6cSJohn Marino /* Update the agent expression EXPR with bytecode to compute the 791*ef5ccd6cSJohn Marino value. VALUE is the agent value we are updating. The DATA 792*ef5ccd6cSJohn Marino argument passed to this function is the same argument that was 793*ef5ccd6cSJohn Marino passed to `create_internalvar_type_lazy'. If this pointer is 794*ef5ccd6cSJohn Marino NULL, then the internalvar cannot be compiled to an agent 795*ef5ccd6cSJohn Marino expression. */ 796*ef5ccd6cSJohn Marino 797*ef5ccd6cSJohn Marino void (*compile_to_ax) (struct internalvar *var, 798*ef5ccd6cSJohn Marino struct agent_expr *expr, 799*ef5ccd6cSJohn Marino struct axs_value *value, 800*ef5ccd6cSJohn Marino void *data); 801*ef5ccd6cSJohn Marino 802*ef5ccd6cSJohn Marino /* If non-NULL, this is called to destroy DATA. The DATA argument 803*ef5ccd6cSJohn Marino passed to this function is the same argument that was passed to 804*ef5ccd6cSJohn Marino `create_internalvar_type_lazy'. */ 805*ef5ccd6cSJohn Marino 806*ef5ccd6cSJohn Marino void (*destroy) (void *data); 807*ef5ccd6cSJohn Marino }; 808*ef5ccd6cSJohn Marino 8095796c8dcSSimon Schubert extern struct internalvar * 810*ef5ccd6cSJohn Marino create_internalvar_type_lazy (const char *name, 811*ef5ccd6cSJohn Marino const struct internalvar_funcs *funcs, 812*ef5ccd6cSJohn Marino void *data); 813*ef5ccd6cSJohn Marino 814*ef5ccd6cSJohn Marino /* Compile an internal variable to an agent expression. VAR is the 815*ef5ccd6cSJohn Marino variable to compile; EXPR and VALUE are the agent expression we are 816*ef5ccd6cSJohn Marino updating. This will return 0 if there is no known way to compile 817*ef5ccd6cSJohn Marino VAR, and 1 if VAR was successfully compiled. It may also throw an 818*ef5ccd6cSJohn Marino exception on error. */ 819*ef5ccd6cSJohn Marino 820*ef5ccd6cSJohn Marino extern int compile_internalvar_to_ax (struct internalvar *var, 821*ef5ccd6cSJohn Marino struct agent_expr *expr, 822*ef5ccd6cSJohn Marino struct axs_value *value); 8235796c8dcSSimon Schubert 8245796c8dcSSimon Schubert extern struct internalvar *lookup_internalvar (const char *name); 8255796c8dcSSimon Schubert 8265796c8dcSSimon Schubert extern int value_equal (struct value *arg1, struct value *arg2); 8275796c8dcSSimon Schubert 828cf7f2e2dSJohn Marino extern int value_equal_contents (struct value *arg1, struct value *arg2); 829cf7f2e2dSJohn Marino 8305796c8dcSSimon Schubert extern int value_less (struct value *arg1, struct value *arg2); 8315796c8dcSSimon Schubert 8325796c8dcSSimon Schubert extern int value_logical_not (struct value *arg1); 8335796c8dcSSimon Schubert 8345796c8dcSSimon Schubert /* C++ */ 8355796c8dcSSimon Schubert 836a45ae5f8SJohn Marino extern struct value *value_of_this (const struct language_defn *lang); 837a45ae5f8SJohn Marino 838a45ae5f8SJohn Marino extern struct value *value_of_this_silent (const struct language_defn *lang); 8395796c8dcSSimon Schubert 8405796c8dcSSimon Schubert extern struct value *value_x_binop (struct value *arg1, struct value *arg2, 8415796c8dcSSimon Schubert enum exp_opcode op, 8425796c8dcSSimon Schubert enum exp_opcode otherop, 8435796c8dcSSimon Schubert enum noside noside); 8445796c8dcSSimon Schubert 8455796c8dcSSimon Schubert extern struct value *value_x_unop (struct value *arg1, enum exp_opcode op, 8465796c8dcSSimon Schubert enum noside noside); 8475796c8dcSSimon Schubert 8485796c8dcSSimon Schubert extern struct value *value_fn_field (struct value **arg1p, struct fn_field *f, 8495796c8dcSSimon Schubert int j, struct type *type, int offset); 8505796c8dcSSimon Schubert 851cf7f2e2dSJohn Marino extern int binop_types_user_defined_p (enum exp_opcode op, 852cf7f2e2dSJohn Marino struct type *type1, 853cf7f2e2dSJohn Marino struct type *type2); 854cf7f2e2dSJohn Marino 8555796c8dcSSimon Schubert extern int binop_user_defined_p (enum exp_opcode op, struct value *arg1, 8565796c8dcSSimon Schubert struct value *arg2); 8575796c8dcSSimon Schubert 8585796c8dcSSimon Schubert extern int unop_user_defined_p (enum exp_opcode op, struct value *arg1); 8595796c8dcSSimon Schubert 860a45ae5f8SJohn Marino extern int destructor_name_p (const char *name, struct type *type); 8615796c8dcSSimon Schubert 8625796c8dcSSimon Schubert extern void value_incref (struct value *val); 8635796c8dcSSimon Schubert 8645796c8dcSSimon Schubert extern void value_free (struct value *val); 8655796c8dcSSimon Schubert 8665796c8dcSSimon Schubert extern void free_all_values (void); 8675796c8dcSSimon Schubert 868cf7f2e2dSJohn Marino extern void free_value_chain (struct value *v); 869cf7f2e2dSJohn Marino 8705796c8dcSSimon Schubert extern void release_value (struct value *val); 8715796c8dcSSimon Schubert 872*ef5ccd6cSJohn Marino extern void release_value_or_incref (struct value *val); 873*ef5ccd6cSJohn Marino 8745796c8dcSSimon Schubert extern int record_latest_value (struct value *val); 8755796c8dcSSimon Schubert 8765796c8dcSSimon Schubert extern void modify_field (struct type *type, gdb_byte *addr, 8775796c8dcSSimon Schubert LONGEST fieldval, int bitpos, int bitsize); 8785796c8dcSSimon Schubert 879*ef5ccd6cSJohn Marino extern void type_print (struct type *type, const char *varstring, 8805796c8dcSSimon Schubert struct ui_file *stream, int show); 8815796c8dcSSimon Schubert 8825796c8dcSSimon Schubert extern char *type_to_string (struct type *type); 8835796c8dcSSimon Schubert 8845796c8dcSSimon Schubert extern gdb_byte *baseclass_addr (struct type *type, int index, 8855796c8dcSSimon Schubert gdb_byte *valaddr, 8865796c8dcSSimon Schubert struct value **valuep, int *errp); 8875796c8dcSSimon Schubert 8885796c8dcSSimon Schubert extern void print_longest (struct ui_file *stream, int format, 8895796c8dcSSimon Schubert int use_local, LONGEST val); 8905796c8dcSSimon Schubert 8915796c8dcSSimon Schubert extern void print_floating (const gdb_byte *valaddr, struct type *type, 8925796c8dcSSimon Schubert struct ui_file *stream); 8935796c8dcSSimon Schubert 8945796c8dcSSimon Schubert extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type, 8955796c8dcSSimon Schubert struct ui_file *stream); 8965796c8dcSSimon Schubert 897*ef5ccd6cSJohn Marino extern void value_print (struct value *val, struct ui_file *stream, 8985796c8dcSSimon Schubert const struct value_print_options *options); 8995796c8dcSSimon Schubert 9005796c8dcSSimon Schubert extern void value_print_array_elements (struct value *val, 9015796c8dcSSimon Schubert struct ui_file *stream, int format, 9025796c8dcSSimon Schubert enum val_prettyprint pretty); 9035796c8dcSSimon Schubert 9045796c8dcSSimon Schubert extern struct value *value_release_to_mark (struct value *mark); 9055796c8dcSSimon Schubert 906*ef5ccd6cSJohn Marino extern void val_print (struct type *type, const gdb_byte *valaddr, 9075796c8dcSSimon Schubert int embedded_offset, CORE_ADDR address, 9085796c8dcSSimon Schubert struct ui_file *stream, int recurse, 909cf7f2e2dSJohn Marino const struct value *val, 9105796c8dcSSimon Schubert const struct value_print_options *options, 9115796c8dcSSimon Schubert const struct language_defn *language); 9125796c8dcSSimon Schubert 913*ef5ccd6cSJohn Marino extern void common_val_print (struct value *val, 9145796c8dcSSimon Schubert struct ui_file *stream, int recurse, 9155796c8dcSSimon Schubert const struct value_print_options *options, 9165796c8dcSSimon Schubert const struct language_defn *language); 9175796c8dcSSimon Schubert 918c50c785cSJohn Marino extern int val_print_string (struct type *elttype, const char *encoding, 919c50c785cSJohn Marino CORE_ADDR addr, int len, 9205796c8dcSSimon Schubert struct ui_file *stream, 9215796c8dcSSimon Schubert const struct value_print_options *options); 9225796c8dcSSimon Schubert 9235796c8dcSSimon Schubert extern void print_variable_and_value (const char *name, 9245796c8dcSSimon Schubert struct symbol *var, 9255796c8dcSSimon Schubert struct frame_info *frame, 9265796c8dcSSimon Schubert struct ui_file *stream, 9275796c8dcSSimon Schubert int indent); 9285796c8dcSSimon Schubert 9295796c8dcSSimon Schubert extern void typedef_print (struct type *type, struct symbol *news, 9305796c8dcSSimon Schubert struct ui_file *stream); 9315796c8dcSSimon Schubert 9325796c8dcSSimon Schubert extern char *internalvar_name (struct internalvar *var); 9335796c8dcSSimon Schubert 9345796c8dcSSimon Schubert extern void preserve_values (struct objfile *); 9355796c8dcSSimon Schubert 9365796c8dcSSimon Schubert /* From values.c */ 9375796c8dcSSimon Schubert 9385796c8dcSSimon Schubert extern struct value *value_copy (struct value *); 9395796c8dcSSimon Schubert 940c50c785cSJohn Marino extern struct value *value_non_lval (struct value *); 941c50c785cSJohn Marino 9425796c8dcSSimon Schubert extern void preserve_one_value (struct value *, struct objfile *, htab_t); 9435796c8dcSSimon Schubert 9445796c8dcSSimon Schubert /* From valops.c */ 9455796c8dcSSimon Schubert 9465796c8dcSSimon Schubert extern struct value *varying_to_slice (struct value *); 9475796c8dcSSimon Schubert 9485796c8dcSSimon Schubert extern struct value *value_slice (struct value *, int, int); 9495796c8dcSSimon Schubert 9505796c8dcSSimon Schubert extern struct value *value_literal_complex (struct value *, struct value *, 9515796c8dcSSimon Schubert struct type *); 9525796c8dcSSimon Schubert 9535796c8dcSSimon Schubert extern struct value *find_function_in_inferior (const char *, 9545796c8dcSSimon Schubert struct objfile **); 9555796c8dcSSimon Schubert 9565796c8dcSSimon Schubert extern struct value *value_allocate_space_in_inferior (int); 9575796c8dcSSimon Schubert 9585796c8dcSSimon Schubert extern struct value *value_subscripted_rvalue (struct value *array, 9595796c8dcSSimon Schubert LONGEST index, int lowerbound); 9605796c8dcSSimon Schubert 9615796c8dcSSimon Schubert /* User function handler. */ 9625796c8dcSSimon Schubert 9635796c8dcSSimon Schubert typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch, 9645796c8dcSSimon Schubert const struct language_defn *language, 9655796c8dcSSimon Schubert void *cookie, 9665796c8dcSSimon Schubert int argc, 9675796c8dcSSimon Schubert struct value **argv); 9685796c8dcSSimon Schubert 9695796c8dcSSimon Schubert void add_internal_function (const char *name, const char *doc, 9705796c8dcSSimon Schubert internal_function_fn handler, 9715796c8dcSSimon Schubert void *cookie); 9725796c8dcSSimon Schubert 9735796c8dcSSimon Schubert struct value *call_internal_function (struct gdbarch *gdbarch, 9745796c8dcSSimon Schubert const struct language_defn *language, 9755796c8dcSSimon Schubert struct value *function, 9765796c8dcSSimon Schubert int argc, struct value **argv); 9775796c8dcSSimon Schubert 9785796c8dcSSimon Schubert char *value_internal_function_name (struct value *); 9795796c8dcSSimon Schubert 9805796c8dcSSimon Schubert #endif /* !defined (VALUE_H) */ 981