* doc/gdb.texinfo
[deliverable/binutils-gdb.git] / gdb / value.h
CommitLineData
bd5635a1
RP
1/* Definitions for values of C expressions, for GDB.
2 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6GDB is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GDB is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GDB; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20#if !defined (VALUE_H)
21#define VALUE_H 1
22/*
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).
26 */
27enum lval_type {
28 /* Not an lval. */
29 not_lval,
30 /* In memory. Could be a saved register. */
31 lval_memory,
32 /* In a register. */
33 lval_register,
34 /* In a gdb internal variable. */
35 lval_internalvar,
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,
42};
43
44struct value
45 {
46 /* Type of value; either not an lval, or one of the various
47 different possible kinds of lval. */
48 enum lval_type lval;
49 /* Location of value (if lval). */
50 union
51 {
52 /* Address in inferior or byte of registers structure. */
53 CORE_ADDR address;
54 /* Pointer to interrnal variable. */
55 struct internalvar *internalvar;
56 /* Number of register. Only used with
57 lval_reg_frame_relative. */
58 int regnum;
59 } location;
60 /* Describes offset of a value within lval a structure in bytes. */
61 int offset;
62 /* Only used for bitfields; number of bits contained in them. */
63 int bitsize;
64 /* Only used for bitfields; position of start of field. */
65 int bitpos;
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". */
71 CORE_ADDR frame_addr;
72 /* Type of the value. */
73 struct type *type;
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
77 list. */
78 struct value *next;
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. */
81 short repeated;
82 short repetitions;
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? */
86 short regno;
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). */
91 char lazy;
92 /* If nonzero, this is the value of a variable which does not
93 actually exist in the program. */
94 char optimized_out;
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
98 possible value. */
99 union {
100 long contents[1];
101 double force_double_align;
102#ifdef LONG_LONG
103 long long force_longlong_align;
104#endif
105 } aligner;
106
107 };
108
109typedef struct value *value;
110
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))
123extern 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)
137
138/* Convert a REF to the object referenced. */
139
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)));}
145
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.
149
150 References are dereferenced. */
151
152#define COERCE_ARRAY(arg) \
153{ COERCE_REF(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); \
161}
162
163/* If ARG is an enum, convert it to an integer. */
164
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); \
170}
171
172/* Internal variables (variables for convenience of use of debugger)
173 are recorded as a chain of these structures. */
174
175struct internalvar
176{
177 struct internalvar *next;
178 char *name;
179 value value;
180};
181\f
182#include "symtab.h"
183LONGEST value_as_long ();
184double value_as_double ();
185LONGEST unpack_long ();
186double unpack_double ();
187long unpack_field_as_long ();
188value value_from_long ();
189value value_from_double ();
190value value_at ();
191value value_at_lazy ();
192value value_from_register ();
193value value_of_variable ();
194value value_of_register ();
195value read_var_value ();
196value locate_var_value ();
197value allocate_value ();
198value allocate_repeat_value ();
fcb887ff
JK
199value value_mark ();
200void value_free_to_mark ();
bd5635a1
RP
201value value_string ();
202
203value value_binop ();
204value value_add ();
205value value_sub ();
206value value_coerce_array ();
207value value_coerce_function ();
208value value_ind ();
209value value_addr ();
210value value_assign ();
211value value_neg ();
212value value_lognot ();
213value value_struct_elt (), value_struct_elt_for_address ();
214value value_field (), value_primitive_field ();
215value value_cast ();
216value value_zero ();
217value value_repeat ();
218value value_subscript ();
b99f250b 219value value_from_vtable_info ();
bd5635a1
RP
220
221value value_being_returned ();
222int using_struct_return ();
223void set_return_value ();
224
225value evaluate_expression ();
226value evaluate_type ();
227value parse_and_eval ();
228value parse_to_comma_and_eval ();
229extern CORE_ADDR parse_and_eval_address ();
230extern CORE_ADDR parse_and_eval_address_1 ();
231
232value access_value_history ();
233value value_of_internalvar ();
234void set_internalvar ();
235void set_internalvar_component ();
236struct internalvar *lookup_internalvar ();
237
238int value_equal ();
239int value_less ();
240int value_zerop ();
241
242/* C++ */
243value value_of_this ();
244value value_static_field ();
245value value_x_binop ();
246value value_x_unop ();
247value value_fn_field ();
248value value_virtual_fn_field ();
bd5635a1
RP
249int binop_user_defined_p ();
250int unop_user_defined_p ();
251int typecmp ();
b99f250b 252void fill_in_vptr_fieldno ();
bd5635a1
RP
253int destructor_name_p ();
254
255#define value_free(val) free (val)
256void free_all_values ();
257void release_value ();
258int record_latest_value ();
259
260void registers_changed ();
261void read_register_bytes ();
262void write_register_bytes ();
263void read_register_gen ();
264CORE_ADDR read_register ();
265void write_register ();
266void supply_register ();
267void get_saved_register ();
268
269void modify_field ();
270void type_print ();
271void type_print_1 ();
272
273/* Possibilities for prettyprint parameters to routines which print
274 things. */
275enum val_prettyprint {
276 Val_no_prettyprint = 0,
277 Val_prettyprint,
278 /* Use the default setting which the user has specified. */
279 Val_pretty_default
280 };
281
282char *baseclass_addr ();
283void print_floating ();
284int value_print ();
285int val_print ();
286void print_variable_value ();
287char *internalvar_name ();
288void clear_value_history ();
289void clear_internalvars ();
290
291#endif /* value.h not already included. */
This page took 0.047242 seconds and 4 git commands to generate.