home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Atari / Gnu / gdb36p4s.zoo / value.h < prev    next >
C/C++ Source or Header  |  1993-08-13  |  8KB  |  242 lines

  1. /* Definitions for values of C expressions, for GDB.
  2.    Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
  3.  
  4. This file is part of GDB.
  5.  
  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)
  9. any later version.
  10.  
  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.
  15.  
  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.  */
  19.  
  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.  */
  25. enum 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. };
  41.  
  42. struct value
  43.   {
  44.     /* Type of value; either not an lval, or one of the various
  45.        different possible kinds of lval.  */
  46.     enum lval_type lval;
  47.     /* Location of value (if lval).  */
  48.     union
  49.       {
  50.     /* Address in inferior or byte of registers structure.  */
  51.     CORE_ADDR address;
  52.     /* Pointer to interrnal variable.  */
  53.     struct internalvar *internalvar;
  54.     /* Number of register.  Only used with
  55.        lval_reg_frame_relative.  */
  56.     int regnum;
  57.       } location;
  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.  */
  61.     int bitsize;
  62.     /* Only used for bitfields; position of start of field.  */
  63.     int bitpos;
  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.  */
  71.     struct type *type;
  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.  */
  76.     struct value *next;
  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.  */
  79.     short repeated;
  80.     short repetitions;
  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?  */
  84.     short regno;
  85.     /* Actual contents of the value.  For use of this value; setting
  86.        it uses the stuff above.  */
  87.     long contents[1];
  88.   };
  89.  
  90. typedef 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
  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
  106.  
  107. #ifdef atarist
  108. extern int gcc_mshort;
  109. #endif
  110.  
  111. /* If ARG is an array, convert it to a pointer.
  112.    If ARG is an enum, convert it to an integer.
  113.  
  114.    References are dereferenced.  */
  115.  
  116. #ifdef atarist
  117. #define COERCE_ARRAY(arg)    \
  118. { if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF)            \
  119.     arg = value_ind (arg);                        \
  120.   if (VALUE_REPEATED (arg)                        \
  121.       || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY)        \
  122.     arg = value_coerce_array (arg);                    \
  123.   if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM)            \
  124.     arg = value_cast (gcc_mshort ? builtin_type_unsigned_short        \
  125.               : builtin_type_unsigned_int, arg);        \
  126. }
  127. #else
  128. #define COERCE_ARRAY(arg)    \
  129. { if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF)            \
  130.     arg = value_ind (arg);                        \
  131.   if (VALUE_REPEATED (arg)                        \
  132.       || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY)        \
  133.     arg = value_coerce_array (arg);                    \
  134.   if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM)            \
  135.     arg = value_cast (builtin_type_unsigned_int, arg);            \
  136. }
  137. #endif
  138.  
  139. /* If ARG is an enum, convert it to an integer.  */
  140.  
  141. #ifdef atarist
  142. #define COERCE_ENUM(arg)    \
  143. { if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF)            \
  144.     arg = value_ind (arg);                        \
  145.   if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM)            \
  146.     arg = value_cast (gcc_mshort ? builtin_type_unsigned_short        \
  147.               : builtin_type_unsigned_int, arg);        \
  148. }
  149. #else
  150. #define COERCE_ENUM(arg)    \
  151. { if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF)            \
  152.     arg = value_ind (arg);                        \
  153.   if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM)            \
  154.     arg = value_cast (builtin_type_unsigned_int, arg);            \
  155. }
  156. #endif
  157.  
  158. /* Internal variables (variables for convenience of use of debugger)
  159.    are recorded as a chain of these structures.  */
  160.  
  161. struct internalvar
  162. {
  163.   struct internalvar *next;
  164.   char *name;
  165.   value value;
  166. };
  167.  
  168. LONGEST value_as_long ();
  169. double value_as_double ();
  170. LONGEST unpack_long ();
  171. double unpack_double ();
  172. long unpack_field_as_long ();
  173. value value_from_long ();
  174. value value_from_double ();
  175. value value_at ();
  176. value value_from_register ();
  177. value value_of_variable ();
  178. value value_of_register ();
  179. value read_var_value ();
  180. value locate_var_value ();
  181. value allocate_value ();
  182. value allocate_repeat_value ();
  183. value value_string ();
  184.  
  185. value value_binop ();
  186. value value_add ();
  187. value value_sub ();
  188. value value_coerce_array ();
  189. value value_ind ();
  190. value value_addr ();
  191. value value_assign ();
  192. value value_neg ();
  193. value value_lognot ();
  194. value value_struct_elt (), value_struct_elt_for_address ();
  195. value value_field ();
  196. value value_cast ();
  197. value value_zero ();
  198. value value_repeat ();
  199. value value_subscript ();
  200.  
  201. value call_function ();
  202. value value_being_returned ();
  203. int using_struct_return ();
  204.  
  205. value evaluate_expression ();
  206. value evaluate_type ();
  207. value parse_and_eval ();
  208. value parse_to_comma_and_eval ();
  209.  
  210. value access_value_history ();
  211. value value_of_internalvar ();
  212. struct internalvar *lookup_internalvar ();
  213.  
  214. int value_equal ();
  215. int value_less ();
  216. int value_zerop ();
  217.  
  218. /* C++ */
  219. value value_of_this ();
  220. value value_static_field ();
  221. value value_x_binop ();
  222. value value_x_unop ();
  223. int binop_user_defined_p ();
  224. int unop_user_defined_p ();
  225.  
  226. void read_register_bytes ();
  227. void modify_field ();
  228. void type_print ();
  229. void type_print_1 ();
  230.  
  231. /* Possibilities for prettyprint parameters to routines which print
  232.    things.  */
  233. enum val_prettyprint {
  234.   Val_no_prettyprint = 0,
  235.   Val_prettyprint,
  236.   /* Use the default setting which the user has specified.  */
  237.   Val_pretty_default
  238.   };
  239.  
  240. char *baseclass_addr ();
  241.  
  242.