* Rename remote-es1800.c to remote-es.c
[deliverable/binutils-gdb.git] / gdb / value.h
CommitLineData
bd5635a1 1/* Definitions for values of C expressions, for GDB.
e17960fb 2 Copyright 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
bd5635a1
RP
3
4This file is part of GDB.
5
e17960fb 6This program is free software; you can redistribute it and/or modify
bd5635a1 7it under the terms of the GNU General Public License as published by
e17960fb
JG
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
bd5635a1 10
e17960fb 11This program is distributed in the hope that it will be useful,
bd5635a1
RP
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
e17960fb
JG
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
bd5635a1
RP
19
20#if !defined (VALUE_H)
21#define VALUE_H 1
01be6913 22
bd5635a1
RP
23/*
24 * The structure which defines the type of a value. It should never
25 * be possible for a program lval value to survive over a call to the inferior
26 * (ie to be put into the history list or an internal variable).
27 */
28enum lval_type {
29 /* Not an lval. */
30 not_lval,
31 /* In memory. Could be a saved register. */
32 lval_memory,
33 /* In a register. */
34 lval_register,
35 /* In a gdb internal variable. */
36 lval_internalvar,
37 /* Part of a gdb internal variable (structure field). */
38 lval_internalvar_component,
39 /* In a register series in a frame not the current one, which may have been
40 partially saved or saved in different places (otherwise would be
41 lval_register or lval_memory). */
e17960fb 42 lval_reg_frame_relative
bd5635a1
RP
43};
44
45struct value
46 {
47 /* Type of value; either not an lval, or one of the various
48 different possible kinds of lval. */
49 enum lval_type lval;
50 /* Location of value (if lval). */
51 union
52 {
53 /* Address in inferior or byte of registers structure. */
54 CORE_ADDR address;
35fcebce 55 /* Pointer to internal variable. */
bd5635a1
RP
56 struct internalvar *internalvar;
57 /* Number of register. Only used with
58 lval_reg_frame_relative. */
59 int regnum;
60 } location;
61 /* Describes offset of a value within lval a structure in bytes. */
62 int offset;
63 /* Only used for bitfields; number of bits contained in them. */
64 int bitsize;
35fcebce
PB
65 /* Only used for bitfields; position of start of field.
66 For BITS_BIG_ENDIAN=0 targets, it is the position of the LSB.
67 For BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
bd5635a1
RP
68 int bitpos;
69 /* Frame value is relative to. In practice, this address is only
70 used if the value is stored in several registers in other than
71 the current frame, and these registers have not all been saved
72 at the same place in memory. This will be described in the
73 lval enum above as "lval_reg_frame_relative". */
74 CORE_ADDR frame_addr;
75 /* Type of the value. */
76 struct type *type;
77 /* Values are stored in a chain, so that they can be deleted
78 easily over calls to the inferior. Values assigned to internal
79 variables or put into the value history are taken off this
80 list. */
81 struct value *next;
82 /* If an lval is forced to repeat, a new value is created with
83 these fields set. The new value is not an lval. */
84 short repeated;
85 short repetitions;
86 /* Register number if the value is from a register. Is not kept
87 if you take a field of a structure that is stored in a
88 register. Shouldn't it be? */
89 short regno;
90 /* If zero, contents of this value are in the contents field.
91 If nonzero, contents are in inferior memory at address
92 in the location.address field plus the offset field
93 (and the lval field should be lval_memory). */
94 char lazy;
95 /* If nonzero, this is the value of a variable which does not
96 actually exist in the program. */
97 char optimized_out;
98 /* Actual contents of the value. For use of this value; setting
99 it uses the stuff above. Not valid if lazy is nonzero.
100 Target byte-order. We force it to be aligned properly for any
101 possible value. */
102 union {
103 long contents[1];
104 double force_double_align;
7efb57c3 105#ifdef CC_HAS_LONG_LONG
bd5635a1
RP
106 long long force_longlong_align;
107#endif
108 } aligner;
109
110 };
111
112typedef struct value *value;
113
114#define VALUE_TYPE(val) (val)->type
115#define VALUE_LAZY(val) (val)->lazy
116/* VALUE_CONTENTS and VALUE_CONTENTS_RAW both return the address of
117 the gdb buffer used to hold a copy of the contents of the lval.
118 VALUE_CONTENTS is used when the contents of the buffer are needed --
119 it uses value_fetch_lazy() to load the buffer from the process being
120 debugged if it hasn't already been loaded. VALUE_CONTENTS_RAW is
121 used when data is being stored into the buffer, or when it is
122 certain that the contents of the buffer are valid. */
123#define VALUE_CONTENTS_RAW(val) ((char *) (val)->aligner.contents)
124#define VALUE_CONTENTS(val) ((void)(VALUE_LAZY(val) && value_fetch_lazy(val)),\
125 VALUE_CONTENTS_RAW(val))
01be6913
PB
126extern int
127value_fetch_lazy PARAMS ((value val));
128
bd5635a1
RP
129#define VALUE_LVAL(val) (val)->lval
130#define VALUE_ADDRESS(val) (val)->location.address
131#define VALUE_INTERNALVAR(val) (val)->location.internalvar
132#define VALUE_FRAME_REGNUM(val) ((val)->location.regnum)
133#define VALUE_FRAME(val) ((val)->frame_addr)
134#define VALUE_OFFSET(val) (val)->offset
135#define VALUE_BITSIZE(val) (val)->bitsize
136#define VALUE_BITPOS(val) (val)->bitpos
137#define VALUE_NEXT(val) (val)->next
138#define VALUE_REPEATED(val) (val)->repeated
139#define VALUE_REPETITIONS(val) (val)->repetitions
140#define VALUE_REGNO(val) (val)->regno
141#define VALUE_OPTIMIZED_OUT(val) ((val)->optimized_out)
142
143/* Convert a REF to the object referenced. */
144
145#define COERCE_REF(arg) \
e17960fb 146{ if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_REF) \
bd5635a1
RP
147 arg = value_at_lazy (TYPE_TARGET_TYPE (VALUE_TYPE (arg)), \
148 unpack_long (VALUE_TYPE (arg), \
149 VALUE_CONTENTS (arg)));}
150
151/* If ARG is an array, convert it to a pointer.
152 If ARG is an enum, convert it to an integer.
153 If ARG is a function, convert it to a function pointer.
154
155 References are dereferenced. */
156
157#define COERCE_ARRAY(arg) \
158{ COERCE_REF(arg); \
159 if (VALUE_REPEATED (arg) \
160 || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY) \
161 arg = value_coerce_array (arg); \
162 if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FUNC) \
163 arg = value_coerce_function (arg); \
164 if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
165 arg = value_cast (builtin_type_unsigned_int, arg); \
166}
167
168/* If ARG is an enum, convert it to an integer. */
169
170#define COERCE_ENUM(arg) \
e17960fb 171{ if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_REF) \
bd5635a1
RP
172 arg = value_ind (arg); \
173 if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
174 arg = value_cast (builtin_type_unsigned_int, arg); \
175}
176
177/* Internal variables (variables for convenience of use of debugger)
178 are recorded as a chain of these structures. */
179
180struct internalvar
181{
182 struct internalvar *next;
183 char *name;
184 value value;
185};
01be6913 186
35fcebce
PB
187/* Pointer to member function. Depends on compiler implementation. */
188
189#define METHOD_PTR_IS_VIRTUAL(ADDR) ((ADDR) & 0x80000000)
190#define METHOD_PTR_FROM_VOFFSET(OFFSET) (0x80000000 + (OFFSET))
191#define METHOD_PTR_TO_VOFFSET(ADDR) (~0x80000000 & (ADDR))
192
bd5635a1
RP
193\f
194#include "symtab.h"
01be6913
PB
195#include "gdbtypes.h"
196#include "expression.h"
197
e17960fb 198#ifdef __STDC__
01be6913 199struct frame_info;
c7da3ed3 200struct fn_field;
e17960fb 201#endif
01be6913
PB
202
203extern void
204print_address_demangle PARAMS ((CORE_ADDR, FILE *, int));
205
206extern LONGEST
207value_as_long PARAMS ((value val));
208
209extern double
210value_as_double PARAMS ((value val));
211
212extern CORE_ADDR
213value_as_pointer PARAMS ((value val));
214
215extern LONGEST
216unpack_long PARAMS ((struct type *type, char *valaddr));
217
218extern double
219unpack_double PARAMS ((struct type *type, char *valaddr, int *invp));
220
221extern CORE_ADDR
222unpack_pointer PARAMS ((struct type *type, char *valaddr));
223
35fcebce 224extern LONGEST
01be6913
PB
225unpack_field_as_long PARAMS ((struct type *type, char *valaddr,
226 int fieldno));
227
228extern value
229value_from_longest PARAMS ((struct type *type, LONGEST num));
230
231extern value
232value_from_double PARAMS ((struct type *type, double num));
233
234extern value
235value_at PARAMS ((struct type *type, CORE_ADDR addr));
236
237extern value
238value_at_lazy PARAMS ((struct type *type, CORE_ADDR addr));
239
240/* FIXME: Assumes equivalence of "struct frame_info *" and "FRAME" */
241extern value
242value_from_register PARAMS ((struct type *type, int regnum,
243 struct frame_info * frame));
244
245extern value
246value_of_variable PARAMS ((struct symbol *var));
247
248extern value
249value_of_register PARAMS ((int regnum));
250
251/* FIXME: Assumes equivalence of "struct frame_info *" and "FRAME" */
252extern value
253read_var_value PARAMS ((struct symbol *var, struct frame_info *frame));
254
255/* FIXME: Assumes equivalence of "struct frame_info *" and "FRAME" */
256extern value
257locate_var_value PARAMS ((struct symbol *var, struct frame_info *frame));
258
259extern value
260allocate_value PARAMS ((struct type *type));
261
262extern value
263allocate_repeat_value PARAMS ((struct type *type, int count));
264
265extern value
266value_mark PARAMS ((void));
267
268extern void
269value_free_to_mark PARAMS ((value mark));
270
271extern value
272value_string PARAMS ((char *ptr, int len));
273
7efb57c3
FF
274extern value
275value_array PARAMS ((int lowbound, int highbound, value *elemvec));
276
277extern value
278value_concat PARAMS ((value arg1, value arg2));
279
01be6913
PB
280extern value
281value_binop PARAMS ((value arg1, value arg2, enum exp_opcode op));
282
283extern value
284value_add PARAMS ((value arg1, value arg2));
285
286extern value
287value_sub PARAMS ((value arg1, value arg2));
288
289extern value
290value_coerce_array PARAMS ((value arg1));
291
292extern value
293value_coerce_function PARAMS ((value arg1));
294
295extern value
296value_ind PARAMS ((value arg1));
297
298extern value
299value_addr PARAMS ((value arg1));
300
301extern value
302value_assign PARAMS ((value toval, value fromval));
303
304extern value
305value_neg PARAMS ((value arg1));
306
307extern value
c7da3ed3 308value_complement PARAMS ((value arg1));
01be6913
PB
309
310extern value
311value_struct_elt PARAMS ((value *argp, value *args, char *name,
312 int *static_memfuncp, char *err));
313
314extern value
315value_struct_elt_for_reference PARAMS ((struct type *domain,
35fcebce 316 int offset,
01be6913
PB
317 struct type *curtype,
318 char *name,
319 struct type *intype));
320
321extern value
322value_field PARAMS ((value arg1, int fieldno));
323
324extern value
325value_primitive_field PARAMS ((value arg1, int offset, int fieldno,
326 struct type *arg_type));
327
328extern value
329value_cast PARAMS ((struct type *type, value arg2));
330
331extern value
332value_zero PARAMS ((struct type *type, enum lval_type lv));
333
334extern value
335value_repeat PARAMS ((value arg1, int count));
336
337extern value
338value_subscript PARAMS ((value array, value idx));
339
340extern value
341value_from_vtable_info PARAMS ((value arg, struct type *type));
342
343extern value
344value_being_returned PARAMS ((struct type *valtype,
345 char retbuf[REGISTER_BYTES],
346 int struct_return));
347
348extern int
349using_struct_return PARAMS ((value function, CORE_ADDR funcaddr,
350 struct type *value_type, int gcc_p));
351
352extern void
353set_return_value PARAMS ((value val));
354
355extern value
356evaluate_expression PARAMS ((struct expression *exp));
357
358extern value
359evaluate_type PARAMS ((struct expression *exp));
360
361extern value
362parse_and_eval PARAMS ((char *exp));
363
364extern value
365parse_to_comma_and_eval PARAMS ((char **expp));
366
367extern struct type *
368parse_and_eval_type PARAMS ((char *p, int length));
369
370extern CORE_ADDR
371parse_and_eval_address PARAMS ((char *exp));
372
373extern CORE_ADDR
374parse_and_eval_address_1 PARAMS ((char **expptr));
375
376extern value
377access_value_history PARAMS ((int num));
378
379extern value
380value_of_internalvar PARAMS ((struct internalvar *var));
381
382extern void
383set_internalvar PARAMS ((struct internalvar *var, value val));
384
385extern void
386set_internalvar_component PARAMS ((struct internalvar *var, int offset,
387 int bitpos, int bitsize,
388 value newvalue));
389
390extern struct internalvar *
391lookup_internalvar PARAMS ((char *name));
392
393extern int
394value_equal PARAMS ((value arg1, value arg2));
395
396extern int
397value_less PARAMS ((value arg1, value arg2));
398
399extern int
c7da3ed3 400value_logical_not PARAMS ((value arg1));
bd5635a1
RP
401
402/* C++ */
01be6913
PB
403
404extern value
405value_of_this PARAMS ((int complain));
406
407extern value
408value_x_binop PARAMS ((value arg1, value arg2, enum exp_opcode op,
409 enum exp_opcode otherop));
410
411extern value
412value_x_unop PARAMS ((value arg1, enum exp_opcode op));
413
414extern value
35fcebce
PB
415value_fn_field PARAMS ((value *arg1p, struct fn_field *f, int j,
416 struct type* type, int offset));
01be6913
PB
417
418extern value
35fcebce
PB
419value_virtual_fn_field PARAMS ((value *arg1p, struct fn_field *f, int j,
420 struct type *type, int offset));
01be6913
PB
421
422extern int
423binop_user_defined_p PARAMS ((enum exp_opcode op, value arg1, value arg2));
424
425extern int
426unop_user_defined_p PARAMS ((enum exp_opcode op, value arg1));
427
01be6913
PB
428extern int
429destructor_name_p PARAMS ((const char *name, const struct type *type));
bd5635a1 430
35fcebce 431#define value_free(val) free ((PTR)val)
01be6913
PB
432
433extern void
434free_all_values PARAMS ((void));
435
436extern void
437release_value PARAMS ((value val));
438
439extern int
440record_latest_value PARAMS ((value val));
441
442extern void
443registers_changed PARAMS ((void));
444
445extern void
446read_register_bytes PARAMS ((int regbyte, char *myaddr, int len));
447
448extern void
449write_register_bytes PARAMS ((int regbyte, char *myaddr, int len));
450
451extern void
452read_register_gen PARAMS ((int regno, char *myaddr));
453
454extern CORE_ADDR
455read_register PARAMS ((int regno));
456
457extern void
458write_register PARAMS ((int regno, int val));
459
460extern void
461supply_register PARAMS ((int regno, char *val));
462
463/* FIXME: Assumes equivalence of "struct frame_info *" and "FRAME" */
464extern void
465get_saved_register PARAMS ((char *raw_buffer, int *optimized,
466 CORE_ADDR *addrp, struct frame_info *frame,
467 int regnum, enum lval_type *lval));
468
469extern void
470modify_field PARAMS ((char *addr, int fieldval, int bitpos, int bitsize));
471
472extern void
473type_print PARAMS ((struct type *type, char *varstring, FILE *stream,
474 int show));
475
01be6913
PB
476extern char *
477baseclass_addr PARAMS ((struct type *type, int index, char *valaddr,
478 value *valuep, int *errp));
479
7efb57c3
FF
480extern void
481print_longest PARAMS ((FILE *stream, char format, int use_local,
482 LONGEST value));
483
01be6913
PB
484extern void
485print_floating PARAMS ((char *valaddr, struct type *type, FILE *stream));
486
487extern int
488value_print PARAMS ((value val, FILE *stream, int format,
489 enum val_prettyprint pretty));
490
491extern int
492val_print PARAMS ((struct type *type, char *valaddr, CORE_ADDR address,
493 FILE *stream, int format, int deref_ref,
494 int recurse, enum val_prettyprint pretty));
495
c7da3ed3 496extern int
7efb57c3 497val_print_string PARAMS ((CORE_ADDR addr, unsigned int len, FILE *stream));
c7da3ed3 498
01be6913
PB
499/* FIXME: Assumes equivalence of "struct frame_info *" and "FRAME" */
500extern void
501print_variable_value PARAMS ((struct symbol *var, struct frame_info *frame,
502 FILE *stream));
503
504extern value
505value_arg_coerce PARAMS ((value));
506
507extern int
508check_field PARAMS ((value, const char *));
509
510extern void
c7da3ed3 511c_typedef_print PARAMS ((struct type *type, struct symbol *new, FILE *stream));
01be6913
PB
512
513extern char *
514internalvar_name PARAMS ((struct internalvar *var));
515
516extern void
517clear_value_history PARAMS ((void));
518
519extern void
520clear_internalvars PARAMS ((void));
521
522/* From values.c */
523
524extern value
525value_copy PARAMS ((value));
526
c7da3ed3
FF
527extern int
528baseclass_offset PARAMS ((struct type *, int, value, int));
529
01be6913 530/* From valops.c */
bd5635a1 531
e17960fb 532extern value
01be6913 533call_function_by_hand PARAMS ((value, int, value *));
e17960fb 534
01be6913 535#endif /* !defined (VALUE_H) */
This page took 0.132814 seconds and 4 git commands to generate.