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. */
20 #if !defined (VALUE_H)
23 * The structure which defines the type of a value. It should never
24 * be possible for a program lval value to survive over a call to the inferior
25 * (ie to be put into the history list or an internal variable).
30 /* In memory. Could be a saved register. */
34 /* In a gdb internal variable. */
36 /* Part of a gdb internal variable (structure field). */
37 lval_internalvar_component,
38 /* In a register series in a frame not the current one, which may have been
39 partially saved or saved in different places (otherwise would be
40 lval_register or lval_memory). */
41 lval_reg_frame_relative,
46 /* Type of value; either not an lval, or one of the various
47 different possible kinds of lval. */
49 /* Location of value (if lval). */
52 /* Address in inferior or byte of registers structure. */
54 /* Pointer to interrnal variable. */
55 struct internalvar *internalvar;
56 /* Number of register. Only used with
57 lval_reg_frame_relative. */
60 /* Describes offset of a value within lval a structure in bytes. */
62 /* Only used for bitfields; number of bits contained in them. */
64 /* Only used for bitfields; position of start of field. */
66 /* Frame value is relative to. In practice, this address is only
67 used if the value is stored in several registers in other than
68 the current frame, and these registers have not all been saved
69 at the same place in memory. This will be described in the
70 lval enum above as "lval_reg_frame_relative". */
72 /* Type of the value. */
74 /* Values are stored in a chain, so that they can be deleted
75 easily over calls to the inferior. Values assigned to internal
76 variables or put into the value history are taken off this
79 /* If an lval is forced to repeat, a new value is created with
80 these fields set. The new value is not an lval. */
83 /* Register number if the value is from a register. Is not kept
84 if you take a field of a structure that is stored in a
85 register. Shouldn't it be? */
87 /* If zero, contents of this value are in the contents field.
88 If nonzero, contents are in inferior memory at address
89 in the location.address field plus the offset field
90 (and the lval field should be lval_memory). */
92 /* If nonzero, this is the value of a variable which does not
93 actually exist in the program. */
95 /* Actual contents of the value. For use of this value; setting
96 it uses the stuff above. Not valid if lazy is nonzero.
97 Target byte-order. We force it to be aligned properly for any
101 double force_double_align;
103 long long force_longlong_align;
109 typedef struct value *value;
111 #define VALUE_TYPE(val) (val)->type
112 #define VALUE_LAZY(val) (val)->lazy
113 /* VALUE_CONTENTS and VALUE_CONTENTS_RAW both return the address of
114 the gdb buffer used to hold a copy of the contents of the lval.
115 VALUE_CONTENTS is used when the contents of the buffer are needed --
116 it uses value_fetch_lazy() to load the buffer from the process being
117 debugged if it hasn't already been loaded. VALUE_CONTENTS_RAW is
118 used when data is being stored into the buffer, or when it is
119 certain that the contents of the buffer are valid. */
120 #define VALUE_CONTENTS_RAW(val) ((char *) (val)->aligner.contents)
121 #define VALUE_CONTENTS(val) ((void)(VALUE_LAZY(val) && value_fetch_lazy(val)),\
122 VALUE_CONTENTS_RAW(val))
123 extern int value_fetch_lazy ();
124 #define VALUE_LVAL(val) (val)->lval
125 #define VALUE_ADDRESS(val) (val)->location.address
126 #define VALUE_INTERNALVAR(val) (val)->location.internalvar
127 #define VALUE_FRAME_REGNUM(val) ((val)->location.regnum)
128 #define VALUE_FRAME(val) ((val)->frame_addr)
129 #define VALUE_OFFSET(val) (val)->offset
130 #define VALUE_BITSIZE(val) (val)->bitsize
131 #define VALUE_BITPOS(val) (val)->bitpos
132 #define VALUE_NEXT(val) (val)->next
133 #define VALUE_REPEATED(val) (val)->repeated
134 #define VALUE_REPETITIONS(val) (val)->repetitions
135 #define VALUE_REGNO(val) (val)->regno
136 #define VALUE_OPTIMIZED_OUT(val) ((val)->optimized_out)
138 /* Convert a REF to the object referenced. */
140 #define COERCE_REF(arg) \
141 { if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
142 arg = value_at_lazy (TYPE_TARGET_TYPE (VALUE_TYPE (arg)), \
143 unpack_long (VALUE_TYPE (arg), \
144 VALUE_CONTENTS (arg)));}
146 /* If ARG is an array, convert it to a pointer.
147 If ARG is an enum, convert it to an integer.
148 If ARG is a function, convert it to a function pointer.
150 References are dereferenced. */
152 #define COERCE_ARRAY(arg) \
154 if (VALUE_REPEATED (arg) \
155 || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY) \
156 arg = value_coerce_array (arg); \
157 if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FUNC) \
158 arg = value_coerce_function (arg); \
159 if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
160 arg = value_cast (builtin_type_unsigned_int, arg); \
163 /* If ARG is an enum, convert it to an integer. */
165 #define COERCE_ENUM(arg) \
166 { if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
167 arg = value_ind (arg); \
168 if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
169 arg = value_cast (builtin_type_unsigned_int, arg); \
172 /* Internal variables (variables for convenience of use of debugger)
173 are recorded as a chain of these structures. */
177 struct internalvar *next;
183 LONGEST value_as_long ();
184 double value_as_double ();
185 LONGEST unpack_long ();
186 double unpack_double ();
187 long unpack_field_as_long ();
188 value value_from_long ();
189 value value_from_double ();
191 value value_at_lazy ();
192 value value_from_register ();
193 value value_of_variable ();
194 value value_of_register ();
195 value read_var_value ();
196 value locate_var_value ();
197 value allocate_value ();
198 value allocate_repeat_value ();
200 void value_free_to_mark ();
201 value value_string ();
203 value value_binop ();
206 value value_coerce_array ();
207 value value_coerce_function ();
210 value value_assign ();
212 value value_lognot ();
213 value value_struct_elt (), value_struct_elt_for_address ();
214 value value_field (), value_primitive_field ();
217 value value_repeat ();
218 value value_subscript ();
219 value value_from_vtable_info ();
221 value value_being_returned ();
222 int using_struct_return ();
223 void set_return_value ();
225 value evaluate_expression ();
226 value evaluate_type ();
227 value parse_and_eval ();
228 value parse_to_comma_and_eval ();
229 extern CORE_ADDR parse_and_eval_address ();
230 extern CORE_ADDR parse_and_eval_address_1 ();
232 value access_value_history ();
233 value value_of_internalvar ();
234 void set_internalvar ();
235 void set_internalvar_component ();
236 struct internalvar *lookup_internalvar ();
243 value value_of_this ();
244 value value_static_field ();
245 value value_x_binop ();
246 value value_x_unop ();
247 value value_fn_field ();
248 value value_virtual_fn_field ();
249 int binop_user_defined_p ();
250 int unop_user_defined_p ();
252 void fill_in_vptr_fieldno ();
253 int destructor_name_p ();
255 #define value_free(val) free (val)
256 void free_all_values ();
257 void release_value ();
258 int record_latest_value ();
260 void registers_changed ();
261 void read_register_bytes ();
262 void write_register_bytes ();
263 void read_register_gen ();
264 CORE_ADDR read_register ();
265 void write_register ();
266 void supply_register ();
267 void get_saved_register ();
269 void modify_field ();
271 void type_print_1 ();
273 /* Possibilities for prettyprint parameters to routines which print
275 enum val_prettyprint {
276 Val_no_prettyprint = 0,
278 /* Use the default setting which the user has specified. */
282 char *baseclass_addr ();
283 void print_floating ();
286 void print_variable_value ();
287 char *internalvar_name ();
288 void clear_value_history ();
289 void clear_internalvars ();
291 #endif /* value.h not already included. */