gdb-3.5
[deliverable/binutils-gdb.git] / gdb / value.h
CommitLineData
7b4ac7e1 1/* Definitions for values of C expressions, for GDB.
4187119d 2 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
7b4ac7e1 3
4187119d 4This file is part of GDB.
7b4ac7e1 5
4187119d 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.
7b4ac7e1 10
4187119d 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. */
7b4ac7e1 19
e91b87a3 20/*
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).
24 */
25enum lval_type {
26 /* Not an lval. */
27 not_lval,
28 /* In memory. Could be a saved register. */
29 lval_memory,
30 /* In a register. */
31 lval_register,
32 /* In a gdb internal variable. */
33 lval_internalvar,
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,
40};
7b4ac7e1 41
42struct value
43 {
e91b87a3 44 /* Type of value; either not an lval, or one of the various
45 different possible kinds of lval. */
7b4ac7e1 46 enum lval_type lval;
e91b87a3 47 /* Location of value (if lval). */
7b4ac7e1 48 union
49 {
e91b87a3 50 /* Address in inferior or byte of registers structure. */
7b4ac7e1 51 CORE_ADDR address;
e91b87a3 52 /* Pointer to interrnal variable. */
7b4ac7e1 53 struct internalvar *internalvar;
e91b87a3 54 /* Number of register. Only used with
55 lval_reg_frame_relative. */
56 int regnum;
7b4ac7e1 57 } location;
e91b87a3 58 /* Describes offset of a value within lval a structure in bytes. */
59 int offset;
60 /* Only used for bitfields; number of bits contained in them. */
7b4ac7e1 61 int bitsize;
e91b87a3 62 /* Only used for bitfields; position of start of field. */
7b4ac7e1 63 int bitpos;
e91b87a3 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". */
69 CORE_ADDR frame_addr;
70 /* Type of the value. */
7b4ac7e1 71 struct type *type;
e91b87a3 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
75 list. */
7b4ac7e1 76 struct value *next;
e91b87a3 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. */
7b4ac7e1 79 short repeated;
80 short repetitions;
e91b87a3 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? */
7b4ac7e1 84 short regno;
e91b87a3 85 /* Actual contents of the value. For use of this value; setting
86 it uses the stuff above. */
7b4ac7e1 87 long contents[1];
88 };
89
90typedef struct value *value;
91
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
e91b87a3 97#define VALUE_FRAME_REGNUM(val) ((val)->location.regnum)
98#define VALUE_FRAME(val) ((val)->frame_addr)
7b4ac7e1 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
106
107/* If ARG is an array, convert it to a pointer.
bb7592f0 108 If ARG is an enum, convert it to an integer.
109
110 References are dereferenced. */
7b4ac7e1 111
112#define COERCE_ARRAY(arg) \
e91b87a3 113{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
bb7592f0 114 arg = value_ind (arg); \
115 if (VALUE_REPEATED (arg) \
7b4ac7e1 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); \
120}
121
122/* If ARG is an enum, convert it to an integer. */
123
124#define COERCE_ENUM(arg) \
e91b87a3 125{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
bb7592f0 126 arg = value_ind (arg); \
127 if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
7b4ac7e1 128 arg = value_cast (builtin_type_unsigned_int, arg); \
129}
130
131/* Internal variables (variables for convenience of use of debugger)
132 are recorded as a chain of these structures. */
133
134struct internalvar
135{
136 struct internalvar *next;
137 char *name;
138 value value;
139};
140\f
e91b87a3 141LONGEST value_as_long ();
7b4ac7e1 142double value_as_double ();
e91b87a3 143LONGEST unpack_long ();
7b4ac7e1 144double unpack_double ();
145long unpack_field_as_long ();
146value value_from_long ();
147value value_from_double ();
148value value_at ();
e91b87a3 149value value_from_register ();
7b4ac7e1 150value value_of_variable ();
151value value_of_register ();
152value read_var_value ();
153value locate_var_value ();
154value allocate_value ();
155value allocate_repeat_value ();
156value value_string ();
157
158value value_binop ();
159value value_add ();
160value value_sub ();
161value value_coerce_array ();
162value value_ind ();
163value value_addr ();
164value value_assign ();
165value value_neg ();
166value value_lognot ();
bb7592f0 167value value_struct_elt (), value_struct_elt_for_address ();
7b4ac7e1 168value value_field ();
169value value_cast ();
4187119d 170value value_zero ();
7b4ac7e1 171value value_repeat ();
172value value_subscript ();
173
174value call_function ();
175value value_being_returned ();
e91b87a3 176int using_struct_return ();
7b4ac7e1 177
178value evaluate_expression ();
179value evaluate_type ();
180value parse_and_eval ();
632ea0cc 181value parse_to_comma_and_eval ();
7b4ac7e1 182
183value access_value_history ();
184value value_of_internalvar ();
185struct internalvar *lookup_internalvar ();
186
187int value_equal ();
188int value_less ();
189int value_zerop ();
bb7592f0 190
191/* C++ */
192value value_of_this ();
193value value_static_field ();
194value value_x_binop ();
195value value_x_unop ();
196int binop_user_defined_p ();
197int unop_user_defined_p ();
e91b87a3 198
199void read_register_bytes ();
200void modify_field ();
201void type_print ();
202void type_print_1 ();
4187119d 203
204/* Possibilities for prettyprint parameters to routines which print
205 things. */
206enum val_prettyprint {
207 Val_no_prettyprint = 0,
208 Val_prettyprint,
209 /* Use the default setting which the user has specified. */
210 Val_pretty_default
211 };
212
This page took 0.032904 seconds and 4 git commands to generate.