* A few more improvements to gx jit prototype.
[deliverable/binutils-gdb.git] / gdb / values.c
index 0ffd5a63cb3fa2209fdad2f8da6d87ddd1b6afd4..db6f204af9a40dc031d03569d3463547755f6e6b 100644 (file)
@@ -1,5 +1,5 @@
 /* Low level packing and unpacking of values for GDB, the GNU Debugger.
-   Copyright 1986, 1987, 1989, 1991, 1993, 1994, 1995, 1996, 1997
+   Copyright 1986, 87, 89, 91, 93, 94, 95, 96, 97, 1998
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -32,7 +32,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "scm-lang.h"
 #include "demangle.h"
 
-/* Local function prototypes. */
+/* Prototypes for exported functions. */
+
+void _initialize_values PARAMS ((void));
+
+/* Prototypes for local functions. */
 
 static value_ptr value_headof PARAMS ((value_ptr, struct type *,
                                       struct type *));
@@ -634,6 +638,10 @@ unpack_long (type, valaddr)
     case TYPE_CODE_REF:
       /* Assume a CORE_ADDR can fit in a LONGEST (for now).  Not sure
         whether we want this to be true eventually.  */
+#ifdef GDB_TARGET_IS_D10V
+      if (len == 2)
+         return D10V_MAKE_DADDR(extract_address (valaddr, len));
+#endif
       return extract_address (valaddr, len);
 
     case TYPE_CODE_MEMBER:
@@ -657,12 +665,15 @@ unpack_double (type, valaddr, invp)
      char *valaddr;
      int *invp;
 {
-  register enum type_code code = TYPE_CODE (type);
-  register int len = TYPE_LENGTH (type);
-  register int nosign = TYPE_UNSIGNED (type);
+  enum type_code code;
+  int len;
+  int nosign;
 
   *invp = 0;                   /* Assume valid.   */
   CHECK_TYPEDEF (type);
+  code = TYPE_CODE (type);
+  len = TYPE_LENGTH (type);
+  nosign = TYPE_UNSIGNED (type);
   if (code == TYPE_CODE_FLT)
     {
 #ifdef INVALID_FLOAT
@@ -1176,8 +1187,11 @@ unpack_field_as_long (type, valaddr, fieldno)
   int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
   int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
   int lsbcount;
+  struct type *field_type;
 
   val = extract_unsigned_integer (valaddr + bitpos / 8, sizeof (val));
+  field_type = TYPE_FIELD_TYPE (type, fieldno);
+  CHECK_TYPEDEF (field_type);
 
   /* Extract bits.  See comment above. */
 
@@ -1194,7 +1208,7 @@ unpack_field_as_long (type, valaddr, fieldno)
     {
       valmask = (((ULONGEST) 1) << bitsize) - 1;
       val &= valmask;
-      if (!TYPE_UNSIGNED (TYPE_FIELD_TYPE (type, fieldno)))
+      if (!TYPE_UNSIGNED (field_type))
        {
          if (val & (valmask ^ (valmask >> 1)))
            {
@@ -1287,7 +1301,7 @@ value_from_longest (type, num)
       break;
       
     default:
-      error ("Unexpected type encountered for integer constant.");
+      error ("Unexpected type (%d) encountered for integer constant.", code);
     }
   return val;
 }
@@ -1367,14 +1381,21 @@ value_being_returned (valtype, retbuf, struct_return)
    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.  */
-#if !defined (USE_STRUCT_CONVENTION)
-#define USE_STRUCT_CONVENTION(gcc_p, type)\
-  (!((gcc_p == 1) && (TYPE_LENGTH (value_type) == 1                \
-                     || TYPE_LENGTH (value_type) == 2             \
-                     || TYPE_LENGTH (value_type) == 4             \
-                     || TYPE_LENGTH (value_type) == 8             \
-                     )                                            \
-     ))
+
+int
+generic_use_struct_convention (gcc_p, value_type)
+     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));
+}
+
+#ifndef USE_STRUCT_CONVENTION
+#define USE_STRUCT_CONVENTION(gcc_p,type) generic_use_struct_convention (gcc_p, type)
 #endif
 
 /* Some fundamental types (such as long double) are returned on the stack for
This page took 0.024256 seconds and 4 git commands to generate.