gdb/value.h - gdb

Data types defined

Macros defined

Source code

  1. /* Definitions for values of C expressions, for GDB.

  2.    Copyright (C) 1986-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #if !defined (VALUE_H)
  15. #define VALUE_H 1

  16. #include "doublest.h"
  17. #include "frame.h"                /* For struct frame_id.  */

  18. struct block;
  19. struct expression;
  20. struct regcache;
  21. struct symbol;
  22. struct type;
  23. struct ui_file;
  24. struct language_defn;
  25. struct value_print_options;
  26. struct xmethod_worker;

  27. /* Values can be partially 'optimized out' and/or 'unavailable'.
  28.    These are distinct states and have different string representations
  29.    and related error strings.

  30.    'unavailable' has a specific meaning in this context.  It means the
  31.    value exists in the program (at the machine level), but GDB has no
  32.    means to get to it.  Such a value is normally printed as
  33.    <unavailable>.  Examples of how to end up with an unavailable value
  34.    would be:

  35.     - We're inspecting a traceframe, and the memory or registers the
  36.       debug information says the value lives on haven't been collected.

  37.     - We're inspecting a core dump, the memory or registers the debug
  38.       information says the value lives aren't present in the dump
  39.       (that is, we have a partial/trimmed core dump, or we don't fully
  40.       understand/handle the core dump's format).

  41.     - We're doing live debugging, but the debug API has no means to
  42.       get at where the value lives in the machine, like e.g., ptrace
  43.       not having access to some register or register set.

  44.     - Any other similar scenario.

  45.   OTOH, "optimized out" is about what the compiler decided to generate
  46.   (or not generate).  A chunk of a value that was optimized out does
  47.   not actually exist in the program.  There's no way to get at it
  48.   short of compiling the program differently.

  49.   A register that has not been saved in a frame is likewise considered
  50.   optimized out, except not-saved registers have a different string
  51.   representation and related error strings.  E.g., we'll print them as
  52.   <not-saved> instead of <optimized out>, as in:

  53.     (gdb) p/x $rax
  54.     $1 = <not saved>
  55.     (gdb) info registers rax
  56.     rax            <not saved>

  57.   If the debug info describes a variable as being in such a register,
  58.   we'll still print the variable as <optimized out>.  IOW, <not saved>
  59.   is reserved for inspecting registers at the machine level.

  60.   When comparing value contents, optimized out chunks, unavailable
  61.   chunks, and valid contents data are all considered different.  See
  62.   value_contents_eq for more info.
  63. */

  64. /* The structure which defines the type of a value.  It should never
  65.    be possible for a program lval value to survive over a call to the
  66.    inferior (i.e. to be put into the history list or an internal
  67.    variable).  */

  68. struct value;

  69. /* Values are stored in a chain, so that they can be deleted easily
  70.    over calls to the inferior.  Values assigned to internal variables,
  71.    put into the value history or exposed to Python are taken off this
  72.    list.  */

  73. struct value *value_next (struct value *);

  74. /* Type of the value.  */

  75. extern struct type *value_type (const struct value *);

  76. /* This is being used to change the type of an existing value, that
  77.    code should instead be creating a new value with the changed type
  78.    (but possibly shared content).  */

  79. extern void deprecated_set_value_type (struct value *value,
  80.                                        struct type *type);

  81. /* Only used for bitfields; number of bits contained in them.  */

  82. extern int value_bitsize (const struct value *);
  83. extern void set_value_bitsize (struct value *, int bit);

  84. /* Only used for bitfields; position of start of field.  For
  85.    gdbarch_bits_big_endian=0 targets, it is the position of the LSB.  For
  86.    gdbarch_bits_big_endian=1 targets, it is the position of the MSB.  */

  87. extern int value_bitpos (const struct value *);
  88. extern void set_value_bitpos (struct value *, int bit);

  89. /* Only used for bitfields; the containing value.  This allows a
  90.    single read from the target when displaying multiple
  91.    bitfields.  */

  92. struct value *value_parent (struct value *);
  93. extern void set_value_parent (struct value *value, struct value *parent);

  94. /* Describes offset of a value within lval of a structure in bytes.
  95.    If lval == lval_memory, this is an offset to the address.  If lval
  96.    == lval_register, this is a further offset from location.address
  97.    within the registers structure.  Note also the member
  98.    embedded_offset below.  */

  99. extern int value_offset (const struct value *);
  100. extern void set_value_offset (struct value *, int offset);

  101. /* The comment from "struct value" reads: ``Is it modifiable?  Only
  102.    relevant if lval != not_lval.''.  Shouldn't the value instead be
  103.    not_lval and be done with it?  */

  104. extern int deprecated_value_modifiable (struct value *value);

  105. /* If a value represents a C++ object, then the `type' field gives the
  106.    object's compile-time type.  If the object actually belongs to some
  107.    class derived from `type', perhaps with other base classes and
  108.    additional members, then `type' is just a subobject of the real
  109.    thing, and the full object is probably larger than `type' would
  110.    suggest.

  111.    If `type' is a dynamic class (i.e. one with a vtable), then GDB can
  112.    actually determine the object's run-time type by looking at the
  113.    run-time type information in the vtable.  When this information is
  114.    available, we may elect to read in the entire object, for several
  115.    reasons:

  116.    - When printing the value, the user would probably rather see the
  117.      full object, not just the limited portion apparent from the
  118.      compile-time type.

  119.    - If `type' has virtual base classes, then even printing `type'
  120.      alone may require reaching outside the `type' portion of the
  121.      object to wherever the virtual base class has been stored.

  122.    When we store the entire object, `enclosing_type' is the run-time
  123.    type -- the complete object -- and `embedded_offset' is the offset
  124.    of `type' within that larger type, in bytes.  The value_contents()
  125.    macro takes `embedded_offset' into account, so most GDB code
  126.    continues to see the `type' portion of the value, just as the
  127.    inferior would.

  128.    If `type' is a pointer to an object, then `enclosing_type' is a
  129.    pointer to the object's run-time type, and `pointed_to_offset' is
  130.    the offset in bytes from the full object to the pointed-to object
  131.    -- that is, the value `embedded_offset' would have if we followed
  132.    the pointer and fetched the complete object.  (I don't really see
  133.    the point.  Why not just determine the run-time type when you
  134.    indirect, and avoid the special case?  The contents don't matter
  135.    until you indirect anyway.)

  136.    If we're not doing anything fancy, `enclosing_type' is equal to
  137.    `type', and `embedded_offset' is zero, so everything works
  138.    normally.  */

  139. extern struct type *value_enclosing_type (struct value *);
  140. extern void set_value_enclosing_type (struct value *val,
  141.                                       struct type *new_type);

  142. /* Returns value_type or value_enclosing_type depending on
  143.    value_print_options.objectprint.

  144.    If RESOLVE_SIMPLE_TYPES is 0 the enclosing type will be resolved
  145.    only for pointers and references, else it will be returned
  146.    for all the types (e.g. structures).  This option is useful
  147.    to prevent retrieving enclosing type for the base classes fields.

  148.    REAL_TYPE_FOUND is used to inform whether the real type was found
  149.    (or just static type was used).  The NULL may be passed if it is not
  150.    necessary. */

  151. extern struct type *value_actual_type (struct value *value,
  152.                                        int resolve_simple_types,
  153.                                        int *real_type_found);

  154. extern int value_pointed_to_offset (struct value *value);
  155. extern void set_value_pointed_to_offset (struct value *value, int val);
  156. extern int value_embedded_offset (struct value *value);
  157. extern void set_value_embedded_offset (struct value *value, int val);

  158. /* For lval_computed values, this structure holds functions used to
  159.    retrieve and set the value (or portions of the value).

  160.    For each function, 'V' is the 'this' pointer: an lval_funcs
  161.    function F may always assume that the V it receives is an
  162.    lval_computed value, and has F in the appropriate slot of its
  163.    lval_funcs structure.  */

  164. struct lval_funcs
  165. {
  166.   /* Fill in VALUE's contents.  This is used to "un-lazy" values.  If
  167.      a problem arises in obtaining VALUE's bits, this function should
  168.      call 'error'.  If it is NULL value_fetch_lazy on "un-lazy"
  169.      non-optimized-out value is an internal error.  */
  170.   void (*read) (struct value *v);

  171.   /* Handle an assignment TOVAL = FROMVAL by writing the value of
  172.      FROMVAL to TOVAL's location.  The contents of TOVAL have not yet
  173.      been updated.  If a problem arises in doing so, this function
  174.      should call 'error'.  If it is NULL such TOVAL assignment is an error as
  175.      TOVAL is not considered as an lvalue.  */
  176.   void (*write) (struct value *toval, struct value *fromval);

  177.   /* If non-NULL, this is used to implement pointer indirection for
  178.      this value.  This method may return NULL, in which case value_ind
  179.      will fall back to ordinary indirection.  */
  180.   struct value *(*indirect) (struct value *value);

  181.   /* If non-NULL, this is used to implement reference resolving for
  182.      this value.  This method may return NULL, in which case coerce_ref
  183.      will fall back to ordinary references resolving.  */
  184.   struct value *(*coerce_ref) (const struct value *value);

  185.   /* If non-NULL, this is used to determine whether the indicated bits
  186.      of VALUE are a synthetic pointer.  */
  187.   int (*check_synthetic_pointer) (const struct value *value,
  188.                                   int offset, int length);

  189.   /* Return a duplicate of VALUE's closure, for use in a new value.
  190.      This may simply return the same closure, if VALUE's is
  191.      reference-counted or statically allocated.

  192.      This may be NULL, in which case VALUE's closure is re-used in the
  193.      new value.  */
  194.   void *(*copy_closure) (const struct value *v);

  195.   /* Drop VALUE's reference to its closure.  Maybe this frees the
  196.      closure; maybe this decrements a reference count; maybe the
  197.      closure is statically allocated and this does nothing.

  198.      This may be NULL, in which case no action is taken to free
  199.      VALUE's closure.  */
  200.   void (*free_closure) (struct value *v);
  201. };

  202. /* Create a computed lvalue, with type TYPE, function pointers FUNCS,
  203.    and closure CLOSURE.  */

  204. extern struct value *allocate_computed_value (struct type *type,
  205.                                               const struct lval_funcs *funcs,
  206.                                               void *closure);

  207. /* Helper function to check the validity of some bits of a value.

  208.    If TYPE represents some aggregate type (e.g., a structure), return 1.

  209.    Otherwise, any of the bytes starting at OFFSET and extending for
  210.    TYPE_LENGTH(TYPE) bytes are invalid, print a message to STREAM and
  211.    return 0.  The checking is done using FUNCS.

  212.    Otherwise, return 1.  */

  213. extern int valprint_check_validity (struct ui_file *stream, struct type *type,
  214.                                     int embedded_offset,
  215.                                     const struct value *val);

  216. extern struct value *allocate_optimized_out_value (struct type *type);

  217. /* If VALUE is lval_computed, return its lval_funcs structure.  */

  218. extern const struct lval_funcs *value_computed_funcs (const struct value *);

  219. /* If VALUE is lval_computed, return its closure.  The meaning of the
  220.    returned value depends on the functions VALUE uses.  */

  221. extern void *value_computed_closure (const struct value *value);

  222. /* If zero, contents of this value are in the contents field.  If
  223.    nonzero, contents are in inferior.  If the lval field is lval_memory,
  224.    the contents are in inferior memory at location.address plus offset.
  225.    The lval field may also be lval_register.

  226.    WARNING: This field is used by the code which handles watchpoints
  227.    (see breakpoint.c) to decide whether a particular value can be
  228.    watched by hardware watchpoints.  If the lazy flag is set for some
  229.    member of a value chain, it is assumed that this member of the
  230.    chain doesn't need to be watched as part of watching the value
  231.    itself.  This is how GDB avoids watching the entire struct or array
  232.    when the user wants to watch a single struct member or array
  233.    element.  If you ever change the way lazy flag is set and reset, be
  234.    sure to consider this use as well!  */

  235. extern int value_lazy (struct value *);
  236. extern void set_value_lazy (struct value *value, int val);

  237. extern int value_stack (struct value *);
  238. extern void set_value_stack (struct value *value, int val);

  239. /* Throw an error complaining that the value has been optimized
  240.    out.  */

  241. extern void error_value_optimized_out (void);

  242. /* value_contents() and value_contents_raw() both return the address
  243.    of the gdb buffer used to hold a copy of the contents of the lval.
  244.    value_contents() is used when the contents of the buffer are needed
  245.    -- it uses value_fetch_lazy() to load the buffer from the process
  246.    being debugged if it hasn't already been loaded
  247.    (value_contents_writeable() is used when a writeable but fetched
  248.    buffer is required)..  value_contents_raw() is used when data is
  249.    being stored into the buffer, or when it is certain that the
  250.    contents of the buffer are valid.

  251.    Note: The contents pointer is adjusted by the offset required to
  252.    get to the real subobject, if the value happens to represent
  253.    something embedded in a larger run-time object.  */

  254. extern gdb_byte *value_contents_raw (struct value *);

  255. /* Actual contents of the value.  For use of this value; setting it
  256.    uses the stuff above.  Not valid if lazy is nonzero.  Target
  257.    byte-order.  We force it to be aligned properly for any possible
  258.    value.  Note that a value therefore extends beyond what is
  259.    declared here.  */

  260. extern const gdb_byte *value_contents (struct value *);
  261. extern gdb_byte *value_contents_writeable (struct value *);

  262. /* The ALL variants of the above two macros do not adjust the returned
  263.    pointer by the embedded_offset value.  */

  264. extern gdb_byte *value_contents_all_raw (struct value *);
  265. extern const gdb_byte *value_contents_all (struct value *);

  266. /* Like value_contents_all, but does not require that the returned
  267.    bits be valid.  This should only be used in situations where you
  268.    plan to check the validity manually.  */
  269. extern const gdb_byte *value_contents_for_printing (struct value *value);

  270. /* Like value_contents_for_printing, but accepts a constant value
  271.    pointer.  Unlike value_contents_for_printing however, the pointed
  272.    value must _not_ be lazy.  */
  273. extern const gdb_byte *
  274.   value_contents_for_printing_const (const struct value *value);

  275. extern int value_fetch_lazy (struct value *val);

  276. /* If nonzero, this is the value of a variable which does not actually
  277.    exist in the program, at least partially.  If the value is lazy,
  278.    this may fetch it now.  */
  279. extern int value_optimized_out (struct value *value);

  280. /* Given a value, return true if any of the contents bits starting at
  281.    OFFSET and extending for LENGTH bits is optimized out, false
  282.    otherwise.  */

  283. extern int value_bits_any_optimized_out (const struct value *value,
  284.                                          int bit_offset, int bit_length);

  285. /* Like value_optimized_out, but return true iff the whole value is
  286.    optimized out.  */
  287. extern int value_entirely_optimized_out (struct value *value);

  288. /* Mark VALUE's content bytes starting at OFFSET and extending for
  289.    LENGTH bytes as optimized out.  */

  290. extern void mark_value_bytes_optimized_out (struct value *value,
  291.                                             int offset, int length);

  292. /* Mark VALUE's content bits starting at OFFSET and extending for
  293.    LENGTH bits as optimized out.  */

  294. extern void mark_value_bits_optimized_out (struct value *value,
  295.                                            int offset, int length);

  296. /* Set or return field indicating whether a variable is initialized or
  297.    not, based on debugging information supplied by the compiler.
  298.    1 = initialized; 0 = uninitialized.  */
  299. extern int value_initialized (struct value *);
  300. extern void set_value_initialized (struct value *, int);

  301. /* Set COMPONENT's location as appropriate for a component of WHOLE
  302.    --- regardless of what kind of lvalue WHOLE is.  */
  303. extern void set_value_component_location (struct value *component,
  304.                                           const struct value *whole);

  305. /* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a
  306.    single value might have multiple LVALs), this hacked interface is
  307.    limited to just the first PIECE.  Expect further change.  */
  308. /* Type of value; either not an lval, or one of the various different
  309.    possible kinds of lval.  */
  310. extern enum lval_type *deprecated_value_lval_hack (struct value *);
  311. #define VALUE_LVAL(val) (*deprecated_value_lval_hack (val))

  312. /* Like VALUE_LVAL, except the parameter can be const.  */
  313. extern enum lval_type value_lval_const (const struct value *value);

  314. /* If lval == lval_memory, return the address in the inferior.  If
  315.    lval == lval_register, return the byte offset into the registers
  316.    structure.  Otherwise, return 0.  The returned address
  317.    includes the offset, if any.  */
  318. extern CORE_ADDR value_address (const struct value *);

  319. /* Like value_address, except the result does not include value's
  320.    offset.  */
  321. extern CORE_ADDR value_raw_address (struct value *);

  322. /* Set the address of a value.  */
  323. extern void set_value_address (struct value *, CORE_ADDR);

  324. /* Pointer to internal variable.  */
  325. extern struct internalvar **deprecated_value_internalvar_hack (struct value *);
  326. #define VALUE_INTERNALVAR(val) (*deprecated_value_internalvar_hack (val))

  327. /* Frame register value is relative to.  This will be described in the
  328.    lval enum above as "lval_register".  */
  329. extern struct frame_id *deprecated_value_frame_id_hack (struct value *);
  330. #define VALUE_FRAME_ID(val) (*deprecated_value_frame_id_hack (val))

  331. /* Register number if the value is from a register.  */
  332. extern short *deprecated_value_regnum_hack (struct value *);
  333. #define VALUE_REGNUM(val) (*deprecated_value_regnum_hack (val))

  334. /* Return value after lval_funcs->coerce_ref (after check_typedef).  Return
  335.    NULL if lval_funcs->coerce_ref is not applicable for whatever reason.  */

  336. extern struct value *coerce_ref_if_computed (const struct value *arg);

  337. /* Setup a new value type and enclosing value type for dereferenced value VALUE.
  338.    ENC_TYPE is the new enclosing type that should be set.  ORIGINAL_TYPE and
  339.    ORIGINAL_VAL are the type and value of the original reference or pointer.

  340.    Note, that VALUE is modified by this function.

  341.    It is a common implementation for coerce_ref and value_ind.  */

  342. extern struct value * readjust_indirect_value_type (struct value *value,
  343.                                                     struct type *enc_type,
  344.                                                     struct type *original_type,
  345.                                                     struct value *original_val);

  346. /* Convert a REF to the object referenced.  */

  347. extern struct value *coerce_ref (struct value *value);

  348. /* If ARG is an array, convert it to a pointer.
  349.    If ARG is a function, convert it to a function pointer.

  350.    References are dereferenced.  */

  351. extern struct value *coerce_array (struct value *value);

  352. /* Given a value, determine whether the bits starting at OFFSET and
  353.    extending for LENGTH bits are a synthetic pointer.  */

  354. extern int value_bits_synthetic_pointer (const struct value *value,
  355.                                          int offset, int length);

  356. /* Given a value, determine whether the contents bytes starting at
  357.    OFFSET and extending for LENGTH bytes are available.  This returns
  358.    nonzero if all bytes in the given range are available, zero if any
  359.    byte is unavailable.  */

  360. extern int value_bytes_available (const struct value *value,
  361.                                   int offset, int length);

  362. /* Given a value, determine whether the contents bits starting at
  363.    OFFSET and extending for LENGTH bits are available.  This returns
  364.    nonzero if all bits in the given range are available, zero if any
  365.    bit is unavailable.  */

  366. extern int value_bits_available (const struct value *value,
  367.                                  int offset, int length);

  368. /* Like value_bytes_available, but return false if any byte in the
  369.    whole object is unavailable.  */
  370. extern int value_entirely_available (struct value *value);

  371. /* Like value_entirely_available, but return false if any byte in the
  372.    whole object is available.  */
  373. extern int value_entirely_unavailable (struct value *value);

  374. /* Mark VALUE's content bytes starting at OFFSET and extending for
  375.    LENGTH bytes as unavailable.  */

  376. extern void mark_value_bytes_unavailable (struct value *value,
  377.                                           int offset, int length);

  378. /* Mark VALUE's content bits starting at OFFSET and extending for
  379.    LENGTH bits as unavailable.  */

  380. extern void mark_value_bits_unavailable (struct value *value,
  381.                                          int offset, int length);

  382. /* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with
  383.    LENGTH bytes of VAL2's contents starting at OFFSET2.

  384.    Note that "contents" refers to the whole value's contents
  385.    (value_contents_all), without any embedded offset adjustment.  For
  386.    example, to compare a complete object value with itself, including
  387.    its enclosing type chunk, you'd do:

  388.      int len = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
  389.      value_contents_eq (val, 0, val, 0, len);

  390.    Returns true iff the set of available/valid contents match.

  391.    Optimized-out contents are equal to optimized-out contents, and are
  392.    not equal to non-optimized-out contents.

  393.    Unavailable contente are equal to unavailable contents, and are not
  394.    equal to non-unavailable contents.

  395.    For example, if 'x's represent an unavailable byte, and 'V' and 'Z'
  396.    represent different available/valid bytes, in a value with length
  397.    16:

  398.      offset:   0   4   8   12  16
  399.      contents: xxxxVVVVxxxxVVZZ

  400.    then:

  401.      value_contents_eq(val, 0, val, 8, 6) => 1
  402.      value_contents_eq(val, 0, val, 4, 4) => 0
  403.      value_contents_eq(val, 0, val, 8, 8) => 0
  404.      value_contents_eq(val, 4, val, 12, 2) => 1
  405.      value_contents_eq(val, 4, val, 12, 4) => 0
  406.      value_contents_eq(val, 3, val, 4, 4) => 0

  407.    If 'x's represent an unavailable byte, 'o' represents an optimized
  408.    out byte, in a value with length 8:

  409.      offset:   0   4   8
  410.      contents: xxxxoooo

  411.    then:

  412.      value_contents_eq(val, 0, val, 2, 2) => 1
  413.      value_contents_eq(val, 4, val, 6, 2) => 1
  414.      value_contents_eq(val, 0, val, 4, 4) => 0

  415.    We only know whether a value chunk is unavailable or optimized out
  416.    if we've tried to read it.  As this routine is used by printing
  417.    routines, which may be printing values in the value history, long
  418.    after the inferior is gone, it works with const values.  Therefore,
  419.    this routine must not be called with lazy values.  */

  420. extern int value_contents_eq (const struct value *val1, int offset1,
  421.                               const struct value *val2, int offset2,
  422.                               int length);

  423. /* Read LENGTH bytes of memory starting at MEMADDR into BUFFER, which
  424.    is (or will be copied to) VAL's contents buffer offset by
  425.    EMBEDDED_OFFSET (that is, to &VAL->contents[EMBEDDED_OFFSET]).
  426.    Marks value contents ranges as unavailable if the corresponding
  427.    memory is likewise unavailable.  STACK indicates whether the memory
  428.    is known to be stack memory.  */

  429. extern void read_value_memory (struct value *val, int embedded_offset,
  430.                                int stack, CORE_ADDR memaddr,
  431.                                gdb_byte *buffer, size_t length);

  432. /* Cast SCALAR_VALUE to the element type of VECTOR_TYPE, then replicate
  433.    into each element of a new vector value with VECTOR_TYPE.  */

  434. struct value *value_vector_widen (struct value *scalar_value,
  435.                                   struct type *vector_type);



  436. #include "symtab.h"
  437. #include "gdbtypes.h"
  438. #include "expression.h"

  439. struct frame_info;
  440. struct fn_field;

  441. extern int print_address_demangle (const struct value_print_options *,
  442.                                    struct gdbarch *, CORE_ADDR,
  443.                                    struct ui_file *, int);

  444. extern LONGEST value_as_long (struct value *val);
  445. extern DOUBLEST value_as_double (struct value *val);
  446. extern CORE_ADDR value_as_address (struct value *val);

  447. extern LONGEST unpack_long (struct type *type, const gdb_byte *valaddr);
  448. extern DOUBLEST unpack_double (struct type *type, const gdb_byte *valaddr,
  449.                                int *invp);
  450. extern CORE_ADDR unpack_pointer (struct type *type, const gdb_byte *valaddr);

  451. extern LONGEST unpack_field_as_long (struct type *type,
  452.                                      const gdb_byte *valaddr,
  453.                                      int fieldno);
  454. extern int unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
  455.                                 int embedded_offset, int fieldno,
  456.                                 const struct value *val, LONGEST *result);

  457. extern void unpack_value_bitfield (struct value *dest_val,
  458.                                    int bitpos, int bitsize,
  459.                                    const gdb_byte *valaddr, int embedded_offset,
  460.                                    const struct value *val);

  461. extern struct value *value_field_bitfield (struct type *type, int fieldno,
  462.                                            const gdb_byte *valaddr,
  463.                                            int embedded_offset,
  464.                                            const struct value *val);

  465. extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num);

  466. extern struct value *value_from_longest (struct type *type, LONGEST num);
  467. extern struct value *value_from_ulongest (struct type *type, ULONGEST num);
  468. extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
  469. extern struct value *value_from_double (struct type *type, DOUBLEST num);
  470. extern struct value *value_from_decfloat (struct type *type,
  471.                                           const gdb_byte *decbytes);
  472. extern struct value *value_from_history_ref (const char *, const char **);

  473. extern struct value *value_at (struct type *type, CORE_ADDR addr);
  474. extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);

  475. extern struct value *value_from_contents_and_address_unresolved
  476.      (struct type *, const gdb_byte *, CORE_ADDR);
  477. extern struct value *value_from_contents_and_address (struct type *,
  478.                                                       const gdb_byte *,
  479.                                                       CORE_ADDR);
  480. extern struct value *value_from_contents (struct type *, const gdb_byte *);

  481. extern struct value *default_value_from_register (struct gdbarch *gdbarch,
  482.                                                   struct type *type,
  483.                                                   int regnum,
  484.                                                   struct frame_id frame_id);

  485. extern void read_frame_register_value (struct value *value,
  486.                                        struct frame_info *frame);

  487. extern struct value *value_from_register (struct type *type, int regnum,
  488.                                           struct frame_info *frame);

  489. extern CORE_ADDR address_from_register (int regnum,
  490.                                         struct frame_info *frame);

  491. extern struct value *value_of_variable (struct symbol *var,
  492.                                         const struct block *b);

  493. extern struct value *address_of_variable (struct symbol *var,
  494.                                           const struct block *b);

  495. extern struct value *value_of_register (int regnum, struct frame_info *frame);

  496. struct value *value_of_register_lazy (struct frame_info *frame, int regnum);

  497. extern int symbol_read_needs_frame (struct symbol *);

  498. extern struct value *read_var_value (struct symbol *var,
  499.                                      struct frame_info *frame);

  500. extern struct value *default_read_var_value (struct symbol *var,
  501.                                              struct frame_info *frame);

  502. extern struct value *allocate_value (struct type *type);
  503. extern struct value *allocate_value_lazy (struct type *type);
  504. extern void value_contents_copy (struct value *dst, int dst_offset,
  505.                                  struct value *src, int src_offset,
  506.                                  int length);
  507. extern void value_contents_copy_raw (struct value *dst, int dst_offset,
  508.                                      struct value *src, int src_offset,
  509.                                      int length);

  510. extern struct value *allocate_repeat_value (struct type *type, int count);

  511. extern struct value *value_mark (void);

  512. extern void value_free_to_mark (struct value *mark);

  513. extern struct value *value_cstring (char *ptr, ssize_t len,
  514.                                     struct type *char_type);
  515. extern struct value *value_string (char *ptr, ssize_t len,
  516.                                    struct type *char_type);

  517. extern struct value *value_array (int lowbound, int highbound,
  518.                                   struct value **elemvec);

  519. extern struct value *value_concat (struct value *arg1, struct value *arg2);

  520. extern struct value *value_binop (struct value *arg1, struct value *arg2,
  521.                                   enum exp_opcode op);

  522. extern struct value *value_ptradd (struct value *arg1, LONGEST arg2);

  523. extern LONGEST value_ptrdiff (struct value *arg1, struct value *arg2);

  524. extern int value_must_coerce_to_target (struct value *arg1);

  525. extern struct value *value_coerce_to_target (struct value *arg1);

  526. extern struct value *value_coerce_array (struct value *arg1);

  527. extern struct value *value_coerce_function (struct value *arg1);

  528. extern struct value *value_ind (struct value *arg1);

  529. extern struct value *value_addr (struct value *arg1);

  530. extern struct value *value_ref (struct value *arg1);

  531. extern struct value *value_assign (struct value *toval,
  532.                                    struct value *fromval);

  533. extern struct value *value_pos (struct value *arg1);

  534. extern struct value *value_neg (struct value *arg1);

  535. extern struct value *value_complement (struct value *arg1);

  536. extern struct value *value_struct_elt (struct value **argp,
  537.                                        struct value **args,
  538.                                        const char *name, int *static_memfuncp,
  539.                                        const char *err);

  540. extern struct value *value_struct_elt_bitpos (struct value **argp,
  541.                                               int bitpos,
  542.                                               struct type *field_type,
  543.                                               const char *err);

  544. extern struct value *value_aggregate_elt (struct type *curtype,
  545.                                           const char *name,
  546.                                           struct type *expect_type,
  547.                                           int want_address,
  548.                                           enum noside noside);

  549. extern struct value *value_static_field (struct type *type, int fieldno);

  550. enum oload_search_type { NON_METHOD, METHOD, BOTH };

  551. extern int find_overload_match (struct value **args, int nargs,
  552.                                 const char *name,
  553.                                 enum oload_search_type method,
  554.                                 struct value **objp, struct symbol *fsym,
  555.                                 struct value **valp, struct symbol **symp,
  556.                                 int *staticp, const int no_adl,
  557.                                 enum noside noside);

  558. extern struct value *value_field (struct value *arg1, int fieldno);

  559. extern struct value *value_primitive_field (struct value *arg1, int offset,
  560.                                             int fieldno,
  561.                                             struct type *arg_type);


  562. extern struct type *value_rtti_indirect_type (struct value *, int *, int *,
  563.                                               int *);

  564. extern struct value *value_full_object (struct value *, struct type *, int,
  565.                                         int, int);

  566. extern struct value *value_cast_pointers (struct type *, struct value *, int);

  567. extern struct value *value_cast (struct type *type, struct value *arg2);

  568. extern struct value *value_reinterpret_cast (struct type *type,
  569.                                              struct value *arg);

  570. extern struct value *value_dynamic_cast (struct type *type, struct value *arg);

  571. extern struct value *value_zero (struct type *type, enum lval_type lv);

  572. extern struct value *value_one (struct type *type);

  573. extern struct value *value_repeat (struct value *arg1, int count);

  574. extern struct value *value_subscript (struct value *array, LONGEST index);

  575. extern struct value *value_bitstring_subscript (struct type *type,
  576.                                                 struct value *bitstring,
  577.                                                 LONGEST index);

  578. extern struct value *register_value_being_returned (struct type *valtype,
  579.                                                     struct regcache *retbuf);

  580. extern int value_in (struct value *element, struct value *set);

  581. extern int value_bit_index (struct type *type, const gdb_byte *addr,
  582.                             int index);

  583. extern enum return_value_convention
  584. struct_return_convention (struct gdbarch *gdbarch, struct value *function,
  585.                           struct type *value_type);

  586. extern int using_struct_return (struct gdbarch *gdbarch,
  587.                                 struct value *function,
  588.                                 struct type *value_type);

  589. extern struct value *evaluate_expression (struct expression *exp);

  590. extern struct value *evaluate_type (struct expression *exp);

  591. extern struct value *evaluate_subexp (struct type *expect_type,
  592.                                       struct expression *exp,
  593.                                       int *pos, enum noside noside);

  594. extern struct value *evaluate_subexpression_type (struct expression *exp,
  595.                                                   int subexp);

  596. extern void fetch_subexp_value (struct expression *exp, int *pc,
  597.                                 struct value **valp, struct value **resultp,
  598.                                 struct value **val_chain,
  599.                                 int preserve_errors);

  600. extern char *extract_field_op (struct expression *exp, int *subexp);

  601. extern struct value *evaluate_subexp_with_coercion (struct expression *,
  602.                                                     int *, enum noside);

  603. extern struct value *parse_and_eval (const char *exp);

  604. extern struct value *parse_to_comma_and_eval (const char **expp);

  605. extern struct type *parse_and_eval_type (char *p, int length);

  606. extern CORE_ADDR parse_and_eval_address (const char *exp);

  607. extern LONGEST parse_and_eval_long (const char *exp);

  608. extern void unop_promote (const struct language_defn *language,
  609.                           struct gdbarch *gdbarch,
  610.                           struct value **arg1);

  611. extern void binop_promote (const struct language_defn *language,
  612.                            struct gdbarch *gdbarch,
  613.                            struct value **arg1, struct value **arg2);

  614. extern struct value *access_value_history (int num);

  615. extern struct value *value_of_internalvar (struct gdbarch *gdbarch,
  616.                                            struct internalvar *var);

  617. extern int get_internalvar_integer (struct internalvar *var, LONGEST *l);

  618. extern void set_internalvar (struct internalvar *var, struct value *val);

  619. extern void set_internalvar_integer (struct internalvar *var, LONGEST l);

  620. extern void set_internalvar_string (struct internalvar *var,
  621.                                     const char *string);

  622. extern void clear_internalvar (struct internalvar *var);

  623. extern void set_internalvar_component (struct internalvar *var,
  624.                                        int offset,
  625.                                        int bitpos, int bitsize,
  626.                                        struct value *newvalue);

  627. extern struct internalvar *lookup_only_internalvar (const char *name);

  628. extern struct internalvar *create_internalvar (const char *name);

  629. extern VEC (char_ptr) *complete_internalvar (const char *name);

  630. /* An internalvar can be dynamically computed by supplying a vector of
  631.    function pointers to perform various operations.  */

  632. struct internalvar_funcs
  633. {
  634.   /* Compute the value of the variable.  The DATA argument passed to
  635.      the function is the same argument that was passed to
  636.      `create_internalvar_type_lazy'.  */

  637.   struct value *(*make_value) (struct gdbarch *arch,
  638.                                struct internalvar *var,
  639.                                void *data);

  640.   /* Update the agent expression EXPR with bytecode to compute the
  641.      value.  VALUE is the agent value we are updating.  The DATA
  642.      argument passed to this function is the same argument that was
  643.      passed to `create_internalvar_type_lazy'.  If this pointer is
  644.      NULL, then the internalvar cannot be compiled to an agent
  645.      expression.  */

  646.   void (*compile_to_ax) (struct internalvar *var,
  647.                          struct agent_expr *expr,
  648.                          struct axs_value *value,
  649.                          void *data);

  650.   /* If non-NULL, this is called to destroy DATA.  The DATA argument
  651.      passed to this function is the same argument that was passed to
  652.      `create_internalvar_type_lazy'.  */

  653.   void (*destroy) (void *data);
  654. };

  655. extern struct internalvar *create_internalvar_type_lazy (const char *name,
  656.                                 const struct internalvar_funcs *funcs,
  657.                                 void *data);

  658. /* Compile an internal variable to an agent expressionVAR is the
  659.    variable to compile; EXPR and VALUE are the agent expression we are
  660.    updating.  This will return 0 if there is no known way to compile
  661.    VAR, and 1 if VAR was successfully compiled.  It may also throw an
  662.    exception on error.  */

  663. extern int compile_internalvar_to_ax (struct internalvar *var,
  664.                                       struct agent_expr *expr,
  665.                                       struct axs_value *value);

  666. extern struct internalvar *lookup_internalvar (const char *name);

  667. extern int value_equal (struct value *arg1, struct value *arg2);

  668. extern int value_equal_contents (struct value *arg1, struct value *arg2);

  669. extern int value_less (struct value *arg1, struct value *arg2);

  670. extern int value_logical_not (struct value *arg1);

  671. /* C++ */

  672. extern struct value *value_of_this (const struct language_defn *lang);

  673. extern struct value *value_of_this_silent (const struct language_defn *lang);

  674. extern struct value *value_x_binop (struct value *arg1, struct value *arg2,
  675.                                     enum exp_opcode op,
  676.                                     enum exp_opcode otherop,
  677.                                     enum noside noside);

  678. extern struct value *value_x_unop (struct value *arg1, enum exp_opcode op,
  679.                                    enum noside noside);

  680. extern struct value *value_fn_field (struct value **arg1p, struct fn_field *f,
  681.                                      int j, struct type *type, int offset);

  682. extern int binop_types_user_defined_p (enum exp_opcode op,
  683.                                        struct type *type1,
  684.                                        struct type *type2);

  685. extern int binop_user_defined_p (enum exp_opcode op, struct value *arg1,
  686.                                  struct value *arg2);

  687. extern int unop_user_defined_p (enum exp_opcode op, struct value *arg1);

  688. extern int destructor_name_p (const char *name, struct type *type);

  689. extern void value_incref (struct value *val);

  690. extern void value_free (struct value *val);

  691. extern void free_all_values (void);

  692. extern void free_value_chain (struct value *v);

  693. extern void release_value (struct value *val);

  694. extern void release_value_or_incref (struct value *val);

  695. extern int record_latest_value (struct value *val);

  696. extern void modify_field (struct type *type, gdb_byte *addr,
  697.                           LONGEST fieldval, int bitpos, int bitsize);

  698. extern void type_print (struct type *type, const char *varstring,
  699.                         struct ui_file *stream, int show);

  700. extern char *type_to_string (struct type *type);

  701. extern gdb_byte *baseclass_addr (struct type *type, int index,
  702.                                  gdb_byte *valaddr,
  703.                                  struct value **valuep, int *errp);

  704. extern void print_longest (struct ui_file *stream, int format,
  705.                            int use_local, LONGEST val);

  706. extern void print_floating (const gdb_byte *valaddr, struct type *type,
  707.                             struct ui_file *stream);

  708. extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
  709.                                     struct ui_file *stream);

  710. extern void value_print (struct value *val, struct ui_file *stream,
  711.                          const struct value_print_options *options);

  712. extern void value_print_array_elements (struct value *val,
  713.                                         struct ui_file *stream, int format,
  714.                                         enum val_prettyformat pretty);

  715. extern struct value *value_release_to_mark (struct value *mark);

  716. extern void val_print (struct type *type, const gdb_byte *valaddr,
  717.                        int embedded_offset, CORE_ADDR address,
  718.                        struct ui_file *stream, int recurse,
  719.                        const struct value *val,
  720.                        const struct value_print_options *options,
  721.                        const struct language_defn *language);

  722. extern void common_val_print (struct value *val,
  723.                               struct ui_file *stream, int recurse,
  724.                               const struct value_print_options *options,
  725.                               const struct language_defn *language);

  726. extern int val_print_string (struct type *elttype, const char *encoding,
  727.                              CORE_ADDR addr, int len,
  728.                              struct ui_file *stream,
  729.                              const struct value_print_options *options);

  730. extern void print_variable_and_value (const char *name,
  731.                                       struct symbol *var,
  732.                                       struct frame_info *frame,
  733.                                       struct ui_file *stream,
  734.                                       int indent);

  735. extern void typedef_print (struct type *type, struct symbol *news,
  736.                            struct ui_file *stream);

  737. extern char *internalvar_name (struct internalvar *var);

  738. extern void preserve_values (struct objfile *);

  739. /* From values.c */

  740. extern struct value *value_copy (struct value *);

  741. extern struct value *value_non_lval (struct value *);

  742. extern void value_force_lval (struct value *, CORE_ADDR);

  743. extern void preserve_one_value (struct value *, struct objfile *, htab_t);

  744. /* From valops.c */

  745. extern struct value *varying_to_slice (struct value *);

  746. extern struct value *value_slice (struct value *, int, int);

  747. extern struct value *value_literal_complex (struct value *, struct value *,
  748.                                             struct type *);

  749. extern struct value *find_function_in_inferior (const char *,
  750.                                                 struct objfile **);

  751. extern struct value *value_allocate_space_in_inferior (int);

  752. extern struct value *value_subscripted_rvalue (struct value *array,
  753.                                                LONGEST index, int lowerbound);

  754. /* User function handler.  */

  755. typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch,
  756.                                                const struct language_defn *language,
  757.                                                void *cookie,
  758.                                                int argc,
  759.                                                struct value **argv);

  760. void add_internal_function (const char *name, const char *doc,
  761.                             internal_function_fn handler,
  762.                             void *cookie);

  763. struct value *call_internal_function (struct gdbarch *gdbarch,
  764.                                       const struct language_defn *language,
  765.                                       struct value *function,
  766.                                       int argc, struct value **argv);

  767. char *value_internal_function_name (struct value *);

  768. extern struct value *value_of_xmethod (struct xmethod_worker *);

  769. struct value *call_xmethod (struct value *function,
  770.                             int argc, struct value **argv);

  771. #endif /* !defined (VALUE_H) */