* gdbint.texinfo (Target Architecture Definition): Remove
[deliverable/binutils-gdb.git] / gdb / values.c
index 42395c886e2b4cf38b68f62468a87ed9a6308edd..a42e53a298b980ddc696ad602d6dd389372f1912 100644 (file)
@@ -214,7 +214,7 @@ value_release_to_mark (struct value *mark)
 struct value *
 value_copy (struct value *arg)
 {
-  register struct type *encl_type = VALUE_ENCLOSING_TYPE (arg);
+  struct type *encl_type = VALUE_ENCLOSING_TYPE (arg);
   struct value *val = allocate_value (encl_type);
   VALUE_TYPE (val) = VALUE_TYPE (arg);
   VALUE_LVAL (val) = VALUE_LVAL (arg);
@@ -291,8 +291,8 @@ struct value *
 access_value_history (int num)
 {
   struct value_history_chunk *chunk;
-  register int i;
-  register int absnum = num;
+  int i;
+  int absnum = num;
 
   if (absnum <= 0)
     absnum += value_history_count;
@@ -329,7 +329,7 @@ void
 clear_value_history (void)
 {
   struct value_history_chunk *next;
-  register int i;
+  int i;
   struct value *val;
 
   while (value_history_chain)
@@ -347,7 +347,7 @@ clear_value_history (void)
 static void
 show_values (char *num_exp, int from_tty)
 {
-  register int i;
+  int i;
   struct value *val;
   static int num = 1;
 
@@ -404,7 +404,7 @@ static struct internalvar *internalvars;
 struct internalvar *
 lookup_internalvar (char *name)
 {
-  register struct internalvar *var;
+  struct internalvar *var;
 
   for (var = internalvars; var; var = var->next)
     if (strcmp (var->name, name) == 0)
@@ -436,7 +436,7 @@ void
 set_internalvar_component (struct internalvar *var, int offset, int bitpos,
                           int bitsize, struct value *newval)
 {
-  register char *addr = VALUE_CONTENTS (var->value) + offset;
+  char *addr = VALUE_CONTENTS (var->value) + offset;
 
   if (bitsize)
     modify_field (addr, value_as_long (newval),
@@ -483,7 +483,7 @@ internalvar_name (struct internalvar *var)
 void
 clear_internalvars (void)
 {
-  register struct internalvar *var;
+  struct internalvar *var;
 
   while (internalvars)
     {
@@ -498,7 +498,7 @@ clear_internalvars (void)
 static void
 show_convenience (char *ignore, int from_tty)
 {
-  register struct internalvar *var;
+  struct internalvar *var;
   int varseen = 0;
 
   for (var = internalvars; var; var = var->next)
@@ -664,9 +664,9 @@ value_as_address (struct value *val)
 LONGEST
 unpack_long (struct type *type, const char *valaddr)
 {
-  register enum type_code code = TYPE_CODE (type);
-  register int len = TYPE_LENGTH (type);
-  register int nosign = TYPE_UNSIGNED (type);
+  enum type_code code = TYPE_CODE (type);
+  int len = TYPE_LENGTH (type);
+  int nosign = TYPE_UNSIGNED (type);
 
   if (current_language->la_language == language_scm
       && is_scmvalue_type (type))
@@ -739,7 +739,14 @@ unpack_double (struct type *type, const char *valaddr, int *invp)
         also not defined either.  Oops!
 
          Hopefully someone will add both the missing floatformat
-         definitions and floatformat_is_invalid() function.  */
+         definitions and the new cases for floatformat_is_valid ().  */
+
+      if (!floatformat_is_valid (floatformat_from_type (type), valaddr))
+       {
+         *invp = 1;
+         return 0.0;
+       }
+
       return extract_typed_floating (valaddr, type);
     }
   else if (nosign)
@@ -876,10 +883,10 @@ value_change_enclosing_type (struct value *val, struct type *new_encl_type)
 
 struct value *
 value_primitive_field (struct value *arg1, int offset,
-                      register int fieldno, register struct type *arg_type)
+                      int fieldno, struct type *arg_type)
 {
   struct value *v;
-  register struct type *type;
+  struct type *type;
 
   CHECK_TYPEDEF (arg_type);
   type = TYPE_FIELD_TYPE (arg_type, fieldno);
@@ -945,7 +952,7 @@ value_primitive_field (struct value *arg1, int offset,
    FIELDNO says which field. */
 
 struct value *
-value_field (struct value *arg1, register int fieldno)
+value_field (struct value *arg1, int fieldno)
 {
   return value_primitive_field (arg1, 0, fieldno, VALUE_TYPE (arg1));
 }
@@ -963,7 +970,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, int j, struct type *ty
                int offset)
 {
   struct value *v;
-  register struct type *ftype = TYPE_FN_FIELD_TYPE (f, j);
+  struct type *ftype = TYPE_FN_FIELD_TYPE (f, j);
   char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
   struct symbol *sym;
   struct minimal_symbol *msym;
@@ -1107,11 +1114,11 @@ modify_field (char *addr, LONGEST fieldval, int bitpos, int bitsize)
 /* Convert C numbers into newly allocated values */
 
 struct value *
-value_from_longest (struct type *type, register LONGEST num)
+value_from_longest (struct type *type, LONGEST num)
 {
   struct value *val = allocate_value (type);
-  register enum type_code code;
-  register int len;
+  enum type_code code;
+  int len;
 retry:
   code = TYPE_CODE (type);
   len = TYPE_LENGTH (type);
@@ -1182,8 +1189,8 @@ value_from_double (struct type *type, DOUBLEST num)
 {
   struct value *val = allocate_value (type);
   struct type *base_type = check_typedef (type);
-  register enum type_code code = TYPE_CODE (base_type);
-  register int len = TYPE_LENGTH (base_type);
+  enum type_code code = TYPE_CODE (base_type);
+  int len = TYPE_LENGTH (base_type);
 
   if (code == TYPE_CODE_FLT)
     {
@@ -1195,61 +1202,10 @@ value_from_double (struct type *type, DOUBLEST num)
   return val;
 }
 \f
-/* Deal with the value that is "about to be returned".  */
-
-/* Return the value that a function returning now
-   would be returning to its caller, assuming its type is VALTYPE.
-   RETBUF is where we look for what ought to be the contents
-   of the registers (in raw form).  This is because it is often
-   desirable to restore old values to those registers
-   after saving the contents of interest, and then call
-   this function using the saved values.
-   struct_return is non-zero when the function in question is
-   using the structure return conventions on the machine in question;
-   0 when it is using the value returning conventions (this often
-   means returning pointer to where structure is vs. returning value). */
-
-/* ARGSUSED */
-struct value *
-value_being_returned (struct type *valtype, struct regcache *retbuf,
-                     int struct_return)
-{
-  struct value *val;
-  CORE_ADDR addr;
-
-  /* If this is not defined, just use EXTRACT_RETURN_VALUE instead.  */
-  if (EXTRACT_STRUCT_VALUE_ADDRESS_P ())
-    if (struct_return)
-      {
-       addr = EXTRACT_STRUCT_VALUE_ADDRESS (retbuf);
-       if (!addr)
-         error ("Function return value unknown.");
-       return value_at (valtype, addr, NULL);
-      }
-
-  /* If this is not defined, just use EXTRACT_RETURN_VALUE instead.  */
-  if (DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS_P ())
-    if (struct_return)
-      {
-       char *buf = deprecated_grub_regcache_for_registers (retbuf);
-       addr = DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS (buf);
-       if (!addr)
-         error ("Function return value unknown.");
-       return value_at (valtype, addr, NULL);
-      }
-
-  val = allocate_value (valtype);
-  CHECK_TYPEDEF (valtype);
-  /* If the function returns void, don't bother fetching the return value.  */
-  if (TYPE_CODE (valtype) != TYPE_CODE_VOID)
-    EXTRACT_RETURN_VALUE (valtype, retbuf, VALUE_CONTENTS_RAW (val));
-
-  return val;
-}
 
-/* Should we use EXTRACT_STRUCT_VALUE_ADDRESS instead of
-   EXTRACT_RETURN_VALUE?  GCC_P is true if compiled with gcc
-   and TYPE is the type (which is known to be struct, union or array).
+/* Should we use DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS instead of
+   EXTRACT_RETURN_VALUE?  GCC_P is true if compiled with gcc and TYPE
+   is the type (which is known to be struct, union or array).
 
    On most machines, the struct convention is used unless we are
    using gcc and the type is of a special size.  */
@@ -1261,63 +1217,42 @@ value_being_returned (struct type *valtype, struct regcache *retbuf,
    2.0-2.3.3.  This is somewhat unfortunate, but changing gcc2_compiled
    would cause more chaos than dealing with some struct returns being
    handled wrong.  */
+/* NOTE: cagney/2004-06-13: Deleted check for "gcc_p".  GCC 1.x is
+   dead.  */
 
 int
 generic_use_struct_convention (int gcc_p, struct type *value_type)
 {
-  return !((gcc_p == 1)
-          && (TYPE_LENGTH (value_type) == 1
-              || TYPE_LENGTH (value_type) == 2
-              || TYPE_LENGTH (value_type) == 4
-              || TYPE_LENGTH (value_type) == 8));
+  return !(TYPE_LENGTH (value_type) == 1
+          || TYPE_LENGTH (value_type) == 2
+          || TYPE_LENGTH (value_type) == 4
+          || TYPE_LENGTH (value_type) == 8);
 }
 
-/* Return true if the function specified is using the structure returning
-   convention on this machine to return arguments, or 0 if it is using
-   the value returning convention.  FUNCTION is the value representing
-   the function, FUNCADDR is the address of the function, and VALUE_TYPE
-   is the type returned by the function.  GCC_P is nonzero if compiled
+/* Return true if the function returning the specified type is using
+   the convention of returning structures in memory (passing in the
+   address as a hidden first parameter).  GCC_P is nonzero if compiled
    with GCC.  */
 
-/* ARGSUSED */
 int
-using_struct_return (struct value *function, CORE_ADDR funcaddr,
-                    struct type *value_type, int gcc_p)
+using_struct_return (struct type *value_type, int gcc_p)
 {
-  register enum type_code code = TYPE_CODE (value_type);
+  enum type_code code = TYPE_CODE (value_type);
 
   if (code == TYPE_CODE_ERROR)
     error ("Function return type unknown.");
 
-  if (code == TYPE_CODE_STRUCT
-      || code == TYPE_CODE_UNION
-      || code == TYPE_CODE_ARRAY
-      || RETURN_VALUE_ON_STACK (value_type))
-    return USE_STRUCT_CONVENTION (gcc_p, value_type);
+  if (code == TYPE_CODE_VOID)
+    /* A void return value is never in memory.  See also corresponding
+       code in "print_return_value".  */
+    return 0;
 
-  return 0;
+  /* Probe the architecture for the return-value convention.  */
+  return (gdbarch_return_value (current_gdbarch, value_type,
+                               NULL, NULL, NULL)
+         != RETURN_VALUE_REGISTER_CONVENTION);
 }
 
-/* Store VAL so it will be returned if a function returns now.
-   Does not verify that VAL's type matches what the current
-   function wants to return.  */
-
-void
-set_return_value (struct value *val)
-{
-  struct type *type = check_typedef (VALUE_TYPE (val));
-  register enum type_code code = TYPE_CODE (type);
-
-  if (code == TYPE_CODE_ERROR)
-    error ("Function return type unknown.");
-
-  if (code == TYPE_CODE_STRUCT
-      || code == TYPE_CODE_UNION)      /* FIXME, implement struct return.  */
-    error ("GDB does not support specifying a struct or union return value.");
-
-  STORE_RETURN_VALUE (type, current_regcache, VALUE_CONTENTS (val));
-}
-\f
 void
 _initialize_values (void)
 {
This page took 0.054829 seconds and 4 git commands to generate.