Detect the absence of a symbol hash table.
[deliverable/binutils-gdb.git] / gdb / values.c
index 6f631acdc42cee96f0a4b070d2e7f1ef240238e4..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
+   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
@@ -761,13 +772,13 @@ value_primitive_field (arg1, offset, fieldno, arg_type)
 
   /* Handle packed fields */
 
-  offset += TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
   if (TYPE_FIELD_BITSIZE (arg_type, fieldno))
     {
       v = value_from_longest (type,
-                          unpack_field_as_long (arg_type,
-                                                VALUE_CONTENTS (arg1),
-                                                fieldno));
+                             unpack_field_as_long (arg_type,
+                                                   VALUE_CONTENTS (arg1)
+                                                     + offset,
+                                                   fieldno));
       VALUE_BITPOS (v) = TYPE_FIELD_BITPOS (arg_type, fieldno) % 8;
       VALUE_BITSIZE (v) = TYPE_FIELD_BITSIZE (arg_type, fieldno);
     }
@@ -777,14 +788,17 @@ value_primitive_field (arg1, offset, fieldno, arg_type)
       if (VALUE_LAZY (arg1))
        VALUE_LAZY (v) = 1;
       else
-       memcpy (VALUE_CONTENTS_RAW (v), VALUE_CONTENTS_RAW (arg1) + offset,
+       memcpy (VALUE_CONTENTS_RAW (v),
+               VALUE_CONTENTS_RAW (arg1) + offset
+                 + TYPE_FIELD_BITPOS (arg_type, fieldno) / 8,
                TYPE_LENGTH (type));
     }
   VALUE_LVAL (v) = VALUE_LVAL (arg1);
   if (VALUE_LVAL (arg1) == lval_internalvar)
     VALUE_LVAL (v) = lval_internalvar_component;
   VALUE_ADDRESS (v) = VALUE_ADDRESS (arg1);
-  VALUE_OFFSET (v) = offset + VALUE_OFFSET (arg1);
+  VALUE_OFFSET (v) = VALUE_OFFSET (arg1) + offset
+                    + TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
   return v;
 }
 
@@ -1173,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. */
 
@@ -1191,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)))
            {
@@ -1284,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;
 }
@@ -1364,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.02455 seconds and 4 git commands to generate.