GDB (API)
/home/stan/gdb/src/gdb/value.h
Go to the documentation of this file.
00001 /* Definitions for values of C expressions, for GDB.
00002 
00003    Copyright (C) 1986-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #if !defined (VALUE_H)
00021 #define VALUE_H 1
00022 
00023 #include "doublest.h"
00024 #include "frame.h"              /* For struct frame_id.  */
00025 
00026 struct block;
00027 struct expression;
00028 struct regcache;
00029 struct symbol;
00030 struct type;
00031 struct ui_file;
00032 struct language_defn;
00033 struct value_print_options;
00034 
00035 /* The structure which defines the type of a value.  It should never
00036    be possible for a program lval value to survive over a call to the
00037    inferior (i.e. to be put into the history list or an internal
00038    variable).  */
00039 
00040 struct value;
00041 
00042 /* Values are stored in a chain, so that they can be deleted easily
00043    over calls to the inferior.  Values assigned to internal variables,
00044    put into the value history or exposed to Python are taken off this
00045    list.  */
00046 
00047 struct value *value_next (struct value *);
00048 
00049 /* Type of the value.  */
00050 
00051 extern struct type *value_type (const struct value *);
00052 
00053 /* This is being used to change the type of an existing value, that
00054    code should instead be creating a new value with the changed type
00055    (but possibly shared content).  */
00056 
00057 extern void deprecated_set_value_type (struct value *value,
00058                                        struct type *type);
00059 
00060 /* Only used for bitfields; number of bits contained in them.  */
00061 
00062 extern int value_bitsize (const struct value *);
00063 extern void set_value_bitsize (struct value *, int bit);
00064 
00065 /* Only used for bitfields; position of start of field.  For
00066    gdbarch_bits_big_endian=0 targets, it is the position of the LSB.  For
00067    gdbarch_bits_big_endian=1 targets, it is the position of the MSB.  */
00068 
00069 extern int value_bitpos (const struct value *);
00070 extern void set_value_bitpos (struct value *, int bit);
00071 
00072 /* Only used for bitfields; the containing value.  This allows a
00073    single read from the target when displaying multiple
00074    bitfields.  */
00075 
00076 struct value *value_parent (struct value *);
00077 extern void set_value_parent (struct value *value, struct value *parent);
00078 
00079 /* Describes offset of a value within lval of a structure in bytes.
00080    If lval == lval_memory, this is an offset to the address.  If lval
00081    == lval_register, this is a further offset from location.address
00082    within the registers structure.  Note also the member
00083    embedded_offset below.  */
00084 
00085 extern int value_offset (const struct value *);
00086 extern void set_value_offset (struct value *, int offset);
00087 
00088 /* The comment from "struct value" reads: ``Is it modifiable?  Only
00089    relevant if lval != not_lval.''.  Shouldn't the value instead be
00090    not_lval and be done with it?  */
00091 
00092 extern int deprecated_value_modifiable (struct value *value);
00093 
00094 /* If a value represents a C++ object, then the `type' field gives the
00095    object's compile-time type.  If the object actually belongs to some
00096    class derived from `type', perhaps with other base classes and
00097    additional members, then `type' is just a subobject of the real
00098    thing, and the full object is probably larger than `type' would
00099    suggest.
00100 
00101    If `type' is a dynamic class (i.e. one with a vtable), then GDB can
00102    actually determine the object's run-time type by looking at the
00103    run-time type information in the vtable.  When this information is
00104    available, we may elect to read in the entire object, for several
00105    reasons:
00106 
00107    - When printing the value, the user would probably rather see the
00108      full object, not just the limited portion apparent from the
00109      compile-time type.
00110 
00111    - If `type' has virtual base classes, then even printing `type'
00112      alone may require reaching outside the `type' portion of the
00113      object to wherever the virtual base class has been stored.
00114 
00115    When we store the entire object, `enclosing_type' is the run-time
00116    type -- the complete object -- and `embedded_offset' is the offset
00117    of `type' within that larger type, in bytes.  The value_contents()
00118    macro takes `embedded_offset' into account, so most GDB code
00119    continues to see the `type' portion of the value, just as the
00120    inferior would.
00121 
00122    If `type' is a pointer to an object, then `enclosing_type' is a
00123    pointer to the object's run-time type, and `pointed_to_offset' is
00124    the offset in bytes from the full object to the pointed-to object
00125    -- that is, the value `embedded_offset' would have if we followed
00126    the pointer and fetched the complete object.  (I don't really see
00127    the point.  Why not just determine the run-time type when you
00128    indirect, and avoid the special case?  The contents don't matter
00129    until you indirect anyway.)
00130 
00131    If we're not doing anything fancy, `enclosing_type' is equal to
00132    `type', and `embedded_offset' is zero, so everything works
00133    normally.  */
00134 
00135 extern struct type *value_enclosing_type (struct value *);
00136 extern void set_value_enclosing_type (struct value *val,
00137                                       struct type *new_type);
00138 
00139 /* Returns value_type or value_enclosing_type depending on
00140    value_print_options.objectprint.
00141 
00142    If RESOLVE_SIMPLE_TYPES is 0 the enclosing type will be resolved
00143    only for pointers and references, else it will be returned
00144    for all the types (e.g. structures).  This option is useful
00145    to prevent retrieving enclosing type for the base classes fields.
00146 
00147    REAL_TYPE_FOUND is used to inform whether the real type was found
00148    (or just static type was used).  The NULL may be passed if it is not
00149    necessary. */
00150 
00151 extern struct type *value_actual_type (struct value *value,
00152                                        int resolve_simple_types,
00153                                        int *real_type_found);
00154 
00155 extern int value_pointed_to_offset (struct value *value);
00156 extern void set_value_pointed_to_offset (struct value *value, int val);
00157 extern int value_embedded_offset (struct value *value);
00158 extern void set_value_embedded_offset (struct value *value, int val);
00159 
00160 /* For lval_computed values, this structure holds functions used to
00161    retrieve and set the value (or portions of the value).
00162 
00163    For each function, 'V' is the 'this' pointer: an lval_funcs
00164    function F may always assume that the V it receives is an
00165    lval_computed value, and has F in the appropriate slot of its
00166    lval_funcs structure.  */
00167 
00168 struct lval_funcs
00169 {
00170   /* Fill in VALUE's contents.  This is used to "un-lazy" values.  If
00171      a problem arises in obtaining VALUE's bits, this function should
00172      call 'error'.  If it is NULL value_fetch_lazy on "un-lazy"
00173      non-optimized-out value is an internal error.  */
00174   void (*read) (struct value *v);
00175 
00176   /* Handle an assignment TOVAL = FROMVAL by writing the value of
00177      FROMVAL to TOVAL's location.  The contents of TOVAL have not yet
00178      been updated.  If a problem arises in doing so, this function
00179      should call 'error'.  If it is NULL such TOVAL assignment is an error as
00180      TOVAL is not considered as an lvalue.  */
00181   void (*write) (struct value *toval, struct value *fromval);
00182 
00183   /* Check the validity of some bits in VALUE.  This should return 1
00184      if all the bits starting at OFFSET and extending for LENGTH bits
00185      are valid, or 0 if any bit is invalid.  */
00186   int (*check_validity) (const struct value *value, int offset, int length);
00187 
00188   /* Return 1 if any bit in VALUE is valid, 0 if they are all invalid.  */
00189   int (*check_any_valid) (const struct value *value);
00190 
00191   /* If non-NULL, this is used to implement pointer indirection for
00192      this value.  This method may return NULL, in which case value_ind
00193      will fall back to ordinary indirection.  */
00194   struct value *(*indirect) (struct value *value);
00195 
00196   /* If non-NULL, this is used to implement reference resolving for
00197      this value.  This method may return NULL, in which case coerce_ref
00198      will fall back to ordinary references resolving.  */
00199   struct value *(*coerce_ref) (const struct value *value);
00200 
00201   /* If non-NULL, this is used to determine whether the indicated bits
00202      of VALUE are a synthetic pointer.  */
00203   int (*check_synthetic_pointer) (const struct value *value,
00204                                   int offset, int length);
00205 
00206   /* Return a duplicate of VALUE's closure, for use in a new value.
00207      This may simply return the same closure, if VALUE's is
00208      reference-counted or statically allocated.
00209 
00210      This may be NULL, in which case VALUE's closure is re-used in the
00211      new value.  */
00212   void *(*copy_closure) (const struct value *v);
00213 
00214   /* Drop VALUE's reference to its closure.  Maybe this frees the
00215      closure; maybe this decrements a reference count; maybe the
00216      closure is statically allocated and this does nothing.
00217 
00218      This may be NULL, in which case no action is taken to free
00219      VALUE's closure.  */
00220   void (*free_closure) (struct value *v);
00221 };
00222 
00223 /* Create a computed lvalue, with type TYPE, function pointers FUNCS,
00224    and closure CLOSURE.  */
00225 
00226 extern struct value *allocate_computed_value (struct type *type,
00227                                               const struct lval_funcs *funcs,
00228                                               void *closure);
00229 
00230 /* Helper function to check the validity of some bits of a value.
00231 
00232    If TYPE represents some aggregate type (e.g., a structure), return 1.
00233    
00234    Otherwise, any of the bytes starting at OFFSET and extending for
00235    TYPE_LENGTH(TYPE) bytes are invalid, print a message to STREAM and
00236    return 0.  The checking is done using FUNCS.
00237    
00238    Otherwise, return 1.  */
00239 
00240 extern int valprint_check_validity (struct ui_file *stream, struct type *type,
00241                                     int embedded_offset,
00242                                     const struct value *val);
00243 
00244 extern struct value *allocate_optimized_out_value (struct type *type);
00245 
00246 /* If VALUE is lval_computed, return its lval_funcs structure.  */
00247 
00248 extern const struct lval_funcs *value_computed_funcs (const struct value *);
00249 
00250 /* If VALUE is lval_computed, return its closure.  The meaning of the
00251    returned value depends on the functions VALUE uses.  */
00252 
00253 extern void *value_computed_closure (const struct value *value);
00254 
00255 /* If zero, contents of this value are in the contents field.  If
00256    nonzero, contents are in inferior.  If the lval field is lval_memory,
00257    the contents are in inferior memory at location.address plus offset.
00258    The lval field may also be lval_register.
00259 
00260    WARNING: This field is used by the code which handles watchpoints
00261    (see breakpoint.c) to decide whether a particular value can be
00262    watched by hardware watchpoints.  If the lazy flag is set for some
00263    member of a value chain, it is assumed that this member of the
00264    chain doesn't need to be watched as part of watching the value
00265    itself.  This is how GDB avoids watching the entire struct or array
00266    when the user wants to watch a single struct member or array
00267    element.  If you ever change the way lazy flag is set and reset, be
00268    sure to consider this use as well!  */
00269 
00270 extern int value_lazy (struct value *);
00271 extern void set_value_lazy (struct value *value, int val);
00272 
00273 extern int value_stack (struct value *);
00274 extern void set_value_stack (struct value *value, int val);
00275 
00276 /* Throw an error complaining that the value has been optimized
00277    out.  */
00278 
00279 extern void error_value_optimized_out (void);
00280 
00281 /* value_contents() and value_contents_raw() both return the address
00282    of the gdb buffer used to hold a copy of the contents of the lval.
00283    value_contents() is used when the contents of the buffer are needed
00284    -- it uses value_fetch_lazy() to load the buffer from the process
00285    being debugged if it hasn't already been loaded
00286    (value_contents_writeable() is used when a writeable but fetched
00287    buffer is required)..  value_contents_raw() is used when data is
00288    being stored into the buffer, or when it is certain that the
00289    contents of the buffer are valid.
00290 
00291    Note: The contents pointer is adjusted by the offset required to
00292    get to the real subobject, if the value happens to represent
00293    something embedded in a larger run-time object.  */
00294 
00295 extern gdb_byte *value_contents_raw (struct value *);
00296 
00297 /* Actual contents of the value.  For use of this value; setting it
00298    uses the stuff above.  Not valid if lazy is nonzero.  Target
00299    byte-order.  We force it to be aligned properly for any possible
00300    value.  Note that a value therefore extends beyond what is
00301    declared here.  */
00302 
00303 extern const gdb_byte *value_contents (struct value *);
00304 extern gdb_byte *value_contents_writeable (struct value *);
00305 
00306 /* The ALL variants of the above two macros do not adjust the returned
00307    pointer by the embedded_offset value.  */
00308 
00309 extern gdb_byte *value_contents_all_raw (struct value *);
00310 extern const gdb_byte *value_contents_all (struct value *);
00311 
00312 /* Like value_contents_all, but does not require that the returned
00313    bits be valid.  This should only be used in situations where you
00314    plan to check the validity manually.  */
00315 extern const gdb_byte *value_contents_for_printing (struct value *value);
00316 
00317 /* Like value_contents_for_printing, but accepts a constant value
00318    pointer.  Unlike value_contents_for_printing however, the pointed
00319    value must _not_ be lazy.  */
00320 extern const gdb_byte *
00321   value_contents_for_printing_const (const struct value *value);
00322 
00323 extern int value_fetch_lazy (struct value *val);
00324 extern int value_contents_equal (struct value *val1, struct value *val2);
00325 
00326 /* If nonzero, this is the value of a variable which does not actually
00327    exist in the program, at least partially.  If the value is lazy,
00328    this may fetch it now.  */
00329 extern int value_optimized_out (struct value *value);
00330 extern void set_value_optimized_out (struct value *value, int val);
00331 
00332 /* Like value_optimized_out, but don't fetch the value even if it is
00333    lazy.  Mainly useful for constructing other values using VALUE as
00334    template.  */
00335 extern int value_optimized_out_const (const struct value *value);
00336 
00337 /* Like value_optimized_out, but return false if any bit in the object
00338    is valid.  */
00339 extern int value_entirely_optimized_out (const struct value *value);
00340 
00341 /* Set or return field indicating whether a variable is initialized or
00342    not, based on debugging information supplied by the compiler.
00343    1 = initialized; 0 = uninitialized.  */
00344 extern int value_initialized (struct value *);
00345 extern void set_value_initialized (struct value *, int);
00346 
00347 /* Set COMPONENT's location as appropriate for a component of WHOLE
00348    --- regardless of what kind of lvalue WHOLE is.  */
00349 extern void set_value_component_location (struct value *component,
00350                                           const struct value *whole);
00351 
00352 /* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a
00353    single value might have multiple LVALs), this hacked interface is
00354    limited to just the first PIECE.  Expect further change.  */
00355 /* Type of value; either not an lval, or one of the various different
00356    possible kinds of lval.  */
00357 extern enum lval_type *deprecated_value_lval_hack (struct value *);
00358 #define VALUE_LVAL(val) (*deprecated_value_lval_hack (val))
00359 
00360 /* Like VALUE_LVAL, except the parameter can be const.  */
00361 extern enum lval_type value_lval_const (const struct value *value);
00362 
00363 /* If lval == lval_memory, return the address in the inferior.  If
00364    lval == lval_register, return the byte offset into the registers
00365    structure.  Otherwise, return 0.  The returned address
00366    includes the offset, if any.  */
00367 extern CORE_ADDR value_address (const struct value *);
00368 
00369 /* Like value_address, except the result does not include value's
00370    offset.  */
00371 extern CORE_ADDR value_raw_address (struct value *);
00372 
00373 /* Set the address of a value.  */
00374 extern void set_value_address (struct value *, CORE_ADDR);
00375 
00376 /* Pointer to internal variable.  */
00377 extern struct internalvar **deprecated_value_internalvar_hack (struct value *);
00378 #define VALUE_INTERNALVAR(val) (*deprecated_value_internalvar_hack (val))
00379 
00380 /* Frame register value is relative to.  This will be described in the
00381    lval enum above as "lval_register".  */
00382 extern struct frame_id *deprecated_value_frame_id_hack (struct value *);
00383 #define VALUE_FRAME_ID(val) (*deprecated_value_frame_id_hack (val))
00384 
00385 /* Register number if the value is from a register.  */
00386 extern short *deprecated_value_regnum_hack (struct value *);
00387 #define VALUE_REGNUM(val) (*deprecated_value_regnum_hack (val))
00388 
00389 /* Return value after lval_funcs->coerce_ref (after check_typedef).  Return
00390    NULL if lval_funcs->coerce_ref is not applicable for whatever reason.  */
00391 
00392 extern struct value *coerce_ref_if_computed (const struct value *arg);
00393 
00394 /* Setup a new value type and enclosing value type for dereferenced value VALUE.
00395    ENC_TYPE is the new enclosing type that should be set.  ORIGINAL_TYPE and
00396    ORIGINAL_VAL are the type and value of the original reference or pointer.
00397 
00398    Note, that VALUE is modified by this function.
00399 
00400    It is a common implementation for coerce_ref and value_ind.  */
00401 
00402 extern struct value * readjust_indirect_value_type (struct value *value,
00403                                                     struct type *enc_type,
00404                                                     struct type *original_type,
00405                                                     struct value *original_val);
00406 
00407 /* Convert a REF to the object referenced.  */
00408 
00409 extern struct value *coerce_ref (struct value *value);
00410 
00411 /* If ARG is an array, convert it to a pointer.
00412    If ARG is a function, convert it to a function pointer.
00413 
00414    References are dereferenced.  */
00415 
00416 extern struct value *coerce_array (struct value *value);
00417 
00418 /* Given a value, determine whether the bits starting at OFFSET and
00419    extending for LENGTH bits are valid.  This returns nonzero if all
00420    bits in the given range are valid, zero if any bit is invalid.  */
00421 
00422 extern int value_bits_valid (const struct value *value,
00423                              int offset, int length);
00424 
00425 /* Given a value, determine whether the bits starting at OFFSET and
00426    extending for LENGTH bits are a synthetic pointer.  */
00427 
00428 extern int value_bits_synthetic_pointer (const struct value *value,
00429                                          int offset, int length);
00430 
00431 /* Given a value, determine whether the contents bytes starting at
00432    OFFSET and extending for LENGTH bytes are available.  This returns
00433    nonzero if all bytes in the given range are available, zero if any
00434    byte is unavailable.  */
00435 
00436 extern int value_bytes_available (const struct value *value,
00437                                   int offset, int length);
00438 
00439 /* Like value_bytes_available, but return false if any byte in the
00440    whole object is unavailable.  */
00441 extern int value_entirely_available (struct value *value);
00442 
00443 /* Like value_entirely_available, but return false if any byte in the
00444    whole object is available.  */
00445 extern int value_entirely_unavailable (struct value *value);
00446 
00447 /* Mark VALUE's content bytes starting at OFFSET and extending for
00448    LENGTH bytes as unavailable.  */
00449 
00450 extern void mark_value_bytes_unavailable (struct value *value,
00451                                           int offset, int length);
00452 
00453 /* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with
00454    LENGTH bytes of VAL2's contents starting at OFFSET2.
00455 
00456    Note that "contents" refers to the whole value's contents
00457    (value_contents_all), without any embedded offset adjustment.  For
00458    example, to compare a complete object value with itself, including
00459    its enclosing type chunk, you'd do:
00460 
00461      int len = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
00462      value_available_contents (val, 0, val, 0, len);
00463 
00464    Returns true iff the set of available contents match.  Unavailable
00465    contents compare equal with unavailable contents, and different
00466    with any available byte.  For example, if 'x's represent an
00467    unavailable byte, and 'V' and 'Z' represent different available
00468    bytes, in a value with length 16:
00469 
00470    offset:   0   4   8   12  16
00471    contents: xxxxVVVVxxxxVVZZ
00472 
00473    then:
00474 
00475    value_available_contents_eq(val, 0, val, 8, 6) => 1
00476    value_available_contents_eq(val, 0, val, 4, 4) => 1
00477    value_available_contents_eq(val, 0, val, 8, 8) => 0
00478    value_available_contents_eq(val, 4, val, 12, 2) => 1
00479    value_available_contents_eq(val, 4, val, 12, 4) => 0
00480    value_available_contents_eq(val, 3, val, 4, 4) => 0
00481 
00482    We only know whether a value chunk is available if we've tried to
00483    read it.  As this routine is used by printing routines, which may
00484    be printing values in the value history, long after the inferior is
00485    gone, it works with const values.  Therefore, this routine must not
00486    be called with lazy values.  */
00487 
00488 extern int value_available_contents_eq (const struct value *val1, int offset1,
00489                                         const struct value *val2, int offset2,
00490                                         int length);
00491 
00492 /* Read LENGTH bytes of memory starting at MEMADDR into BUFFER, which
00493    is (or will be copied to) VAL's contents buffer offset by
00494    EMBEDDED_OFFSET (that is, to &VAL->contents[EMBEDDED_OFFSET]).
00495    Marks value contents ranges as unavailable if the corresponding
00496    memory is likewise unavailable.  STACK indicates whether the memory
00497    is known to be stack memory.  */
00498 
00499 extern void read_value_memory (struct value *val, int embedded_offset,
00500                                int stack, CORE_ADDR memaddr,
00501                                gdb_byte *buffer, size_t length);
00502 
00503 /* Cast SCALAR_VALUE to the element type of VECTOR_TYPE, then replicate
00504    into each element of a new vector value with VECTOR_TYPE.  */
00505 
00506 struct value *value_vector_widen (struct value *scalar_value,
00507                                   struct type *vector_type);
00508 
00509 
00510 
00511 #include "symtab.h"
00512 #include "gdbtypes.h"
00513 #include "expression.h"
00514 
00515 struct frame_info;
00516 struct fn_field;
00517 
00518 extern int print_address_demangle (const struct value_print_options *,
00519                                    struct gdbarch *, CORE_ADDR,
00520                                    struct ui_file *, int);
00521 
00522 extern LONGEST value_as_long (struct value *val);
00523 extern DOUBLEST value_as_double (struct value *val);
00524 extern CORE_ADDR value_as_address (struct value *val);
00525 
00526 extern LONGEST unpack_long (struct type *type, const gdb_byte *valaddr);
00527 extern DOUBLEST unpack_double (struct type *type, const gdb_byte *valaddr,
00528                                int *invp);
00529 extern CORE_ADDR unpack_pointer (struct type *type, const gdb_byte *valaddr);
00530 
00531 extern int unpack_value_bits_as_long (struct type *field_type,
00532                                       const gdb_byte *valaddr,
00533                                       int embedded_offset, int bitpos,
00534                                       int bitsize,
00535                                       const struct value *original_value,
00536                                       LONGEST *result);
00537 
00538 extern LONGEST unpack_field_as_long (struct type *type,
00539                                      const gdb_byte *valaddr,
00540                                      int fieldno);
00541 extern int unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
00542                                 int embedded_offset, int fieldno,
00543                                 const struct value *val, LONGEST *result);
00544 
00545 extern struct value *value_field_bitfield (struct type *type, int fieldno,
00546                                            const gdb_byte *valaddr,
00547                                            int embedded_offset,
00548                                            const struct value *val);
00549 
00550 extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num);
00551 
00552 extern struct value *value_from_longest (struct type *type, LONGEST num);
00553 extern struct value *value_from_ulongest (struct type *type, ULONGEST num);
00554 extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
00555 extern struct value *value_from_double (struct type *type, DOUBLEST num);
00556 extern struct value *value_from_decfloat (struct type *type,
00557                                           const gdb_byte *decbytes);
00558 extern struct value *value_from_history_ref (char *, char **);
00559 
00560 extern struct value *value_at (struct type *type, CORE_ADDR addr);
00561 extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
00562 
00563 extern struct value *value_from_contents_and_address (struct type *,
00564                                                       const gdb_byte *,
00565                                                       CORE_ADDR);
00566 extern struct value *value_from_contents (struct type *, const gdb_byte *);
00567 
00568 extern struct value *default_value_from_register (struct type *type,
00569                                                   int regnum,
00570                                                   struct frame_info *frame);
00571 
00572 extern void read_frame_register_value (struct value *value,
00573                                        struct frame_info *frame);
00574 
00575 extern struct value *value_from_register (struct type *type, int regnum,
00576                                           struct frame_info *frame);
00577 
00578 extern CORE_ADDR address_from_register (struct type *type, int regnum,
00579                                         struct frame_info *frame);
00580 
00581 extern struct value *value_of_variable (struct symbol *var,
00582                                         const struct block *b);
00583 
00584 extern struct value *address_of_variable (struct symbol *var,
00585                                           const struct block *b);
00586 
00587 extern struct value *value_of_register (int regnum, struct frame_info *frame);
00588 
00589 struct value *value_of_register_lazy (struct frame_info *frame, int regnum);
00590 
00591 extern int symbol_read_needs_frame (struct symbol *);
00592 
00593 extern struct value *read_var_value (struct symbol *var,
00594                                      struct frame_info *frame);
00595 
00596 extern struct value *default_read_var_value (struct symbol *var,
00597                                              struct frame_info *frame);
00598 
00599 extern struct value *allocate_value (struct type *type);
00600 extern struct value *allocate_value_lazy (struct type *type);
00601 extern void value_contents_copy (struct value *dst, int dst_offset,
00602                                  struct value *src, int src_offset,
00603                                  int length);
00604 extern void value_contents_copy_raw (struct value *dst, int dst_offset,
00605                                      struct value *src, int src_offset,
00606                                      int length);
00607 
00608 extern struct value *allocate_repeat_value (struct type *type, int count);
00609 
00610 extern struct value *value_mark (void);
00611 
00612 extern void value_free_to_mark (struct value *mark);
00613 
00614 extern struct value *value_cstring (char *ptr, ssize_t len,
00615                                     struct type *char_type);
00616 extern struct value *value_string (char *ptr, ssize_t len,
00617                                    struct type *char_type);
00618 
00619 extern struct value *value_array (int lowbound, int highbound,
00620                                   struct value **elemvec);
00621 
00622 extern struct value *value_concat (struct value *arg1, struct value *arg2);
00623 
00624 extern struct value *value_binop (struct value *arg1, struct value *arg2,
00625                                   enum exp_opcode op);
00626 
00627 extern struct value *value_ptradd (struct value *arg1, LONGEST arg2);
00628 
00629 extern LONGEST value_ptrdiff (struct value *arg1, struct value *arg2);
00630 
00631 extern int value_must_coerce_to_target (struct value *arg1);
00632 
00633 extern struct value *value_coerce_to_target (struct value *arg1);
00634 
00635 extern struct value *value_coerce_array (struct value *arg1);
00636 
00637 extern struct value *value_coerce_function (struct value *arg1);
00638 
00639 extern struct value *value_ind (struct value *arg1);
00640 
00641 extern struct value *value_addr (struct value *arg1);
00642 
00643 extern struct value *value_ref (struct value *arg1);
00644 
00645 extern struct value *value_assign (struct value *toval,
00646                                    struct value *fromval);
00647 
00648 extern struct value *value_pos (struct value *arg1);
00649 
00650 extern struct value *value_neg (struct value *arg1);
00651 
00652 extern struct value *value_complement (struct value *arg1);
00653 
00654 extern struct value *value_struct_elt (struct value **argp,
00655                                        struct value **args,
00656                                        const char *name, int *static_memfuncp,
00657                                        const char *err);
00658 
00659 extern struct value *value_aggregate_elt (struct type *curtype,
00660                                           char *name,
00661                                           struct type *expect_type,
00662                                           int want_address,
00663                                           enum noside noside);
00664 
00665 extern struct value *value_static_field (struct type *type, int fieldno);
00666 
00667 enum oload_search_type { NON_METHOD, METHOD, BOTH };
00668 
00669 extern int find_overload_match (struct value **args, int nargs,
00670                                 const char *name,
00671                                 enum oload_search_type method,
00672                                 struct value **objp, struct symbol *fsym,
00673                                 struct value **valp, struct symbol **symp,
00674                                 int *staticp, const int no_adl);
00675 
00676 extern struct value *value_field (struct value *arg1, int fieldno);
00677 
00678 extern struct value *value_primitive_field (struct value *arg1, int offset,
00679                                             int fieldno,
00680                                             struct type *arg_type);
00681 
00682 
00683 extern struct type *value_rtti_indirect_type (struct value *, int *, int *,
00684                                               int *);
00685 
00686 extern struct value *value_full_object (struct value *, struct type *, int,
00687                                         int, int);
00688 
00689 extern struct value *value_cast_pointers (struct type *, struct value *, int);
00690 
00691 extern struct value *value_cast (struct type *type, struct value *arg2);
00692 
00693 extern struct value *value_reinterpret_cast (struct type *type,
00694                                              struct value *arg);
00695 
00696 extern struct value *value_dynamic_cast (struct type *type, struct value *arg);
00697 
00698 extern struct value *value_zero (struct type *type, enum lval_type lv);
00699 
00700 extern struct value *value_one (struct type *type);
00701 
00702 extern struct value *value_repeat (struct value *arg1, int count);
00703 
00704 extern struct value *value_subscript (struct value *array, LONGEST index);
00705 
00706 extern struct value *value_bitstring_subscript (struct type *type,
00707                                                 struct value *bitstring,
00708                                                 LONGEST index);
00709 
00710 extern struct value *register_value_being_returned (struct type *valtype,
00711                                                     struct regcache *retbuf);
00712 
00713 extern int value_in (struct value *element, struct value *set);
00714 
00715 extern int value_bit_index (struct type *type, const gdb_byte *addr,
00716                             int index);
00717 
00718 extern enum return_value_convention
00719 struct_return_convention (struct gdbarch *gdbarch, struct value *function,
00720                           struct type *value_type);
00721 
00722 extern int using_struct_return (struct gdbarch *gdbarch,
00723                                 struct value *function,
00724                                 struct type *value_type);
00725 
00726 extern struct value *evaluate_expression (struct expression *exp);
00727 
00728 extern struct value *evaluate_type (struct expression *exp);
00729 
00730 extern struct value *evaluate_subexp (struct type *expect_type,
00731                                       struct expression *exp,
00732                                       int *pos, enum noside noside);
00733 
00734 extern struct value *evaluate_subexpression_type (struct expression *exp,
00735                                                   int subexp);
00736 
00737 extern void fetch_subexp_value (struct expression *exp, int *pc,
00738                                 struct value **valp, struct value **resultp,
00739                                 struct value **val_chain,
00740                                 int preserve_errors);
00741 
00742 extern char *extract_field_op (struct expression *exp, int *subexp);
00743 
00744 extern struct value *evaluate_subexp_with_coercion (struct expression *,
00745                                                     int *, enum noside);
00746 
00747 extern struct value *parse_and_eval (const char *exp);
00748 
00749 extern struct value *parse_to_comma_and_eval (const char **expp);
00750 
00751 extern struct type *parse_and_eval_type (char *p, int length);
00752 
00753 extern CORE_ADDR parse_and_eval_address (const char *exp);
00754 
00755 extern LONGEST parse_and_eval_long (const char *exp);
00756 
00757 extern void unop_promote (const struct language_defn *language,
00758                           struct gdbarch *gdbarch,
00759                           struct value **arg1);
00760 
00761 extern void binop_promote (const struct language_defn *language,
00762                            struct gdbarch *gdbarch,
00763                            struct value **arg1, struct value **arg2);
00764 
00765 extern struct value *access_value_history (int num);
00766 
00767 extern struct value *value_of_internalvar (struct gdbarch *gdbarch,
00768                                            struct internalvar *var);
00769 
00770 extern int get_internalvar_integer (struct internalvar *var, LONGEST *l);
00771 
00772 extern void set_internalvar (struct internalvar *var, struct value *val);
00773 
00774 extern void set_internalvar_integer (struct internalvar *var, LONGEST l);
00775 
00776 extern void set_internalvar_string (struct internalvar *var,
00777                                     const char *string);
00778 
00779 extern void clear_internalvar (struct internalvar *var);
00780 
00781 extern void set_internalvar_component (struct internalvar *var,
00782                                        int offset,
00783                                        int bitpos, int bitsize,
00784                                        struct value *newvalue);
00785 
00786 extern struct internalvar *lookup_only_internalvar (const char *name);
00787 
00788 extern struct internalvar *create_internalvar (const char *name);
00789 
00790 extern VEC (char_ptr) *complete_internalvar (const char *name);
00791 
00792 /* An internalvar can be dynamically computed by supplying a vector of
00793    function pointers to perform various operations.  */
00794 
00795 struct internalvar_funcs
00796 {
00797   /* Compute the value of the variable.  The DATA argument passed to
00798      the function is the same argument that was passed to
00799      `create_internalvar_type_lazy'.  */
00800 
00801   struct value *(*make_value) (struct gdbarch *arch,
00802                                struct internalvar *var,
00803                                void *data);
00804 
00805   /* Update the agent expression EXPR with bytecode to compute the
00806      value.  VALUE is the agent value we are updating.  The DATA
00807      argument passed to this function is the same argument that was
00808      passed to `create_internalvar_type_lazy'.  If this pointer is
00809      NULL, then the internalvar cannot be compiled to an agent
00810      expression.  */
00811 
00812   void (*compile_to_ax) (struct internalvar *var,
00813                          struct agent_expr *expr,
00814                          struct axs_value *value,
00815                          void *data);
00816 
00817   /* If non-NULL, this is called to destroy DATA.  The DATA argument
00818      passed to this function is the same argument that was passed to
00819      `create_internalvar_type_lazy'.  */
00820 
00821   void (*destroy) (void *data);
00822 };
00823 
00824 extern struct internalvar *create_internalvar_type_lazy (const char *name,
00825                                 const struct internalvar_funcs *funcs,
00826                                 void *data);
00827 
00828 /* Compile an internal variable to an agent expression.  VAR is the
00829    variable to compile; EXPR and VALUE are the agent expression we are
00830    updating.  This will return 0 if there is no known way to compile
00831    VAR, and 1 if VAR was successfully compiled.  It may also throw an
00832    exception on error.  */
00833 
00834 extern int compile_internalvar_to_ax (struct internalvar *var,
00835                                       struct agent_expr *expr,
00836                                       struct axs_value *value);
00837 
00838 extern struct internalvar *lookup_internalvar (const char *name);
00839 
00840 extern int value_equal (struct value *arg1, struct value *arg2);
00841 
00842 extern int value_equal_contents (struct value *arg1, struct value *arg2);
00843 
00844 extern int value_less (struct value *arg1, struct value *arg2);
00845 
00846 extern int value_logical_not (struct value *arg1);
00847 
00848 /* C++ */
00849 
00850 extern struct value *value_of_this (const struct language_defn *lang);
00851 
00852 extern struct value *value_of_this_silent (const struct language_defn *lang);
00853 
00854 extern struct value *value_x_binop (struct value *arg1, struct value *arg2,
00855                                     enum exp_opcode op,
00856                                     enum exp_opcode otherop,
00857                                     enum noside noside);
00858 
00859 extern struct value *value_x_unop (struct value *arg1, enum exp_opcode op,
00860                                    enum noside noside);
00861 
00862 extern struct value *value_fn_field (struct value **arg1p, struct fn_field *f,
00863                                      int j, struct type *type, int offset);
00864 
00865 extern int binop_types_user_defined_p (enum exp_opcode op,
00866                                        struct type *type1,
00867                                        struct type *type2);
00868 
00869 extern int binop_user_defined_p (enum exp_opcode op, struct value *arg1,
00870                                  struct value *arg2);
00871 
00872 extern int unop_user_defined_p (enum exp_opcode op, struct value *arg1);
00873 
00874 extern int destructor_name_p (const char *name, struct type *type);
00875 
00876 extern void value_incref (struct value *val);
00877 
00878 extern void value_free (struct value *val);
00879 
00880 extern void free_all_values (void);
00881 
00882 extern void free_value_chain (struct value *v);
00883 
00884 extern void release_value (struct value *val);
00885 
00886 extern void release_value_or_incref (struct value *val);
00887 
00888 extern int record_latest_value (struct value *val);
00889 
00890 extern void modify_field (struct type *type, gdb_byte *addr,
00891                           LONGEST fieldval, int bitpos, int bitsize);
00892 
00893 extern void type_print (struct type *type, const char *varstring,
00894                         struct ui_file *stream, int show);
00895 
00896 extern char *type_to_string (struct type *type);
00897 
00898 extern gdb_byte *baseclass_addr (struct type *type, int index,
00899                                  gdb_byte *valaddr,
00900                                  struct value **valuep, int *errp);
00901 
00902 extern void print_longest (struct ui_file *stream, int format,
00903                            int use_local, LONGEST val);
00904 
00905 extern void print_floating (const gdb_byte *valaddr, struct type *type,
00906                             struct ui_file *stream);
00907 
00908 extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
00909                                     struct ui_file *stream);
00910 
00911 extern void value_print (struct value *val, struct ui_file *stream,
00912                          const struct value_print_options *options);
00913 
00914 extern void value_print_array_elements (struct value *val,
00915                                         struct ui_file *stream, int format,
00916                                         enum val_prettyformat pretty);
00917 
00918 extern struct value *value_release_to_mark (struct value *mark);
00919 
00920 extern void val_print (struct type *type, const gdb_byte *valaddr,
00921                        int embedded_offset, CORE_ADDR address,
00922                        struct ui_file *stream, int recurse,
00923                        const struct value *val,
00924                        const struct value_print_options *options,
00925                        const struct language_defn *language);
00926 
00927 extern void common_val_print (struct value *val,
00928                               struct ui_file *stream, int recurse,
00929                               const struct value_print_options *options,
00930                               const struct language_defn *language);
00931 
00932 extern int val_print_string (struct type *elttype, const char *encoding,
00933                              CORE_ADDR addr, int len,
00934                              struct ui_file *stream,
00935                              const struct value_print_options *options);
00936 
00937 extern void print_variable_and_value (const char *name,
00938                                       struct symbol *var,
00939                                       struct frame_info *frame,
00940                                       struct ui_file *stream,
00941                                       int indent);
00942 
00943 extern void typedef_print (struct type *type, struct symbol *news,
00944                            struct ui_file *stream);
00945 
00946 extern char *internalvar_name (struct internalvar *var);
00947 
00948 extern void preserve_values (struct objfile *);
00949 
00950 /* From values.c */
00951 
00952 extern struct value *value_copy (struct value *);
00953 
00954 extern struct value *value_non_lval (struct value *);
00955 
00956 extern void preserve_one_value (struct value *, struct objfile *, htab_t);
00957 
00958 /* From valops.c */
00959 
00960 extern struct value *varying_to_slice (struct value *);
00961 
00962 extern struct value *value_slice (struct value *, int, int);
00963 
00964 extern struct value *value_literal_complex (struct value *, struct value *,
00965                                             struct type *);
00966 
00967 extern struct value *find_function_in_inferior (const char *,
00968                                                 struct objfile **);
00969 
00970 extern struct value *value_allocate_space_in_inferior (int);
00971 
00972 extern struct value *value_subscripted_rvalue (struct value *array,
00973                                                LONGEST index, int lowerbound);
00974 
00975 /* User function handler.  */
00976 
00977 typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch,
00978                                                const struct language_defn *language,
00979                                                void *cookie,
00980                                                int argc,
00981                                                struct value **argv);
00982 
00983 void add_internal_function (const char *name, const char *doc,
00984                             internal_function_fn handler,
00985                             void *cookie);
00986 
00987 struct value *call_internal_function (struct gdbarch *gdbarch,
00988                                       const struct language_defn *language,
00989                                       struct value *function,
00990                                       int argc, struct value **argv);
00991 
00992 char *value_internal_function_name (struct value *);
00993 
00994 #endif /* !defined (VALUE_H) */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines