1 /* Definitions for values of C expressions, for GDB.
2 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
4 This file is part of GDB.
6 GDB is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GDB is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 * The structure which defines the type of a value. It should never
22 * be possible for a program lval value to survive over a call to the inferior
23 * (ie to be put into the history list or an internal variable).
28 /* In memory. Could be a saved register. */
32 /* In a gdb internal variable. */
34 /* Part of a gdb internal variable (structure field). */
35 lval_internalvar_component
,
36 /* In a register series in a frame not the current one, which may have been
37 partially saved or saved in different places (otherwise would be
38 lval_register or lval_memory). */
39 lval_reg_frame_relative
,
44 /* Type of value; either not an lval, or one of the various
45 different possible kinds of lval. */
47 /* Location of value (if lval). */
50 /* Address in inferior or byte of registers structure. */
52 /* Pointer to interrnal variable. */
53 struct internalvar
*internalvar
;
54 /* Number of register. Only used with
55 lval_reg_frame_relative. */
58 /* Describes offset of a value within lval a structure in bytes. */
60 /* Only used for bitfields; number of bits contained in them. */
62 /* Only used for bitfields; position of start of field. */
64 /* Frame value is relative to. In practice, this address is only
65 used if the value is stored in several registers in other than
66 the current frame, and these registers have not all been saved
67 at the same place in memory. This will be described in the
68 lval enum above as "lval_reg_frame_relative". */
70 /* Type of the value. */
72 /* Values are stored in a chain, so that they can be deleted
73 easily over calls to the inferior. Values assigned to internal
74 variables or put into the value history are taken off this
77 /* If an lval is forced to repeat, a new value is created with
78 these fields set. The new value is not an lval. */
81 /* Register number if the value is from a register. Is not kept
82 if you take a field of a structure that is stored in a
83 register. Shouldn't it be? */
85 /* Actual contents of the value. For use of this value; setting
86 it uses the stuff above. */
90 typedef struct value
*value
;
92 #define VALUE_TYPE(val) (val)->type
93 #define VALUE_CONTENTS(val) ((char *) (val)->contents)
94 #define VALUE_LVAL(val) (val)->lval
95 #define VALUE_ADDRESS(val) (val)->location.address
96 #define VALUE_INTERNALVAR(val) (val)->location.internalvar
97 #define VALUE_FRAME_REGNUM(val) ((val)->location.regnum)
98 #define VALUE_FRAME(val) ((val)->frame_addr)
99 #define VALUE_OFFSET(val) (val)->offset
100 #define VALUE_BITSIZE(val) (val)->bitsize
101 #define VALUE_BITPOS(val) (val)->bitpos
102 #define VALUE_NEXT(val) (val)->next
103 #define VALUE_REPEATED(val) (val)->repeated
104 #define VALUE_REPETITIONS(val) (val)->repetitions
105 #define VALUE_REGNO(val) (val)->regno
107 /* If ARG is an array, convert it to a pointer.
108 If ARG is an enum, convert it to an integer.
110 References are dereferenced. */
112 #define COERCE_ARRAY(arg) \
113 { if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
114 arg = value_ind (arg); \
115 if (VALUE_REPEATED (arg) \
116 || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY) \
117 arg = value_coerce_array (arg); \
118 if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
119 arg = value_cast (builtin_type_unsigned_int, arg); \
122 /* If ARG is an enum, convert it to an integer. */
124 #define COERCE_ENUM(arg) \
125 { if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
126 arg = value_ind (arg); \
127 if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
128 arg = value_cast (builtin_type_unsigned_int, arg); \
131 /* Internal variables (variables for convenience of use of debugger)
132 are recorded as a chain of these structures. */
136 struct internalvar
*next
;
141 LONGEST
value_as_long ();
142 double value_as_double ();
143 LONGEST
unpack_long ();
144 double unpack_double ();
145 long unpack_field_as_long ();
146 value
value_from_long ();
147 value
value_from_double ();
149 value
value_from_register ();
150 value
value_of_variable ();
151 value
value_of_register ();
152 value
read_var_value ();
153 value
locate_var_value ();
154 value
allocate_value ();
155 value
allocate_repeat_value ();
156 value
value_string ();
158 value
value_binop ();
161 value
value_coerce_array ();
164 value
value_assign ();
166 value
value_lognot ();
167 value
value_struct_elt (), value_struct_elt_for_address ();
168 value
value_field ();
171 value
value_repeat ();
172 value
value_subscript ();
174 value
call_function ();
175 value
value_being_returned ();
176 int using_struct_return ();
178 value
evaluate_expression ();
179 value
evaluate_type ();
180 value
parse_and_eval ();
181 value
parse_to_comma_and_eval ();
183 value
access_value_history ();
184 value
value_of_internalvar ();
185 struct internalvar
*lookup_internalvar ();
192 value
value_of_this ();
193 value
value_static_field ();
194 value
value_x_binop ();
195 value
value_x_unop ();
196 int binop_user_defined_p ();
197 int unop_user_defined_p ();
199 void read_register_bytes ();
200 void modify_field ();
202 void type_print_1 ();
204 /* Possibilities for prettyprint parameters to routines which print
206 enum val_prettyprint
{
207 Val_no_prettyprint
= 0,
209 /* Use the default setting which the user has specified. */