* gdb.asm/{Makefile.in,configure.in,configure}: New files.
[deliverable/binutils-gdb.git] / gdb / values.c
index ff29d31515593230427669d1659deef117b2634c..69c19a6399ce358ed5e46861f5aa3c576a4ac694 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, 1987, 1989, 1991, 1993, 1994, 1995, 1996, 1997
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -634,6 +634,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:
@@ -714,12 +718,37 @@ unpack_pointer (type, valaddr)
   return unpack_long (type, valaddr);
 }
 \f
+/* Get the value of the FIELDN'th field (which must be static) of TYPE. */
+
+value_ptr
+value_static_field (type, fieldno)
+     struct type *type;
+     int fieldno;
+{
+  CORE_ADDR addr;
+  asection *sect;
+  if (TYPE_FIELD_STATIC_HAS_ADDR (type, fieldno))
+    {
+      addr = TYPE_FIELD_STATIC_PHYSADDR (type, fieldno);
+      sect = NULL;
+    }
+  else
+    {
+      char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
+      struct symbol *sym = lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL);
+      if (sym == NULL)
+       return NULL;
+      addr = SYMBOL_VALUE_ADDRESS (sym);
+      sect = SYMBOL_BFD_SECTION (sym);
+      SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno), addr);
+    }
+  return value_at (TYPE_FIELD_TYPE (type, fieldno), addr, sect);
+}
+
 /* Given a value ARG1 (offset by OFFSET bytes)
    of a struct or union type ARG_TYPE,
-   extract and return the value of one of its fields.
-   FIELDNO says which field.
-
-   For C++, must also be able to return values from static fields */
+   extract and return the value of one of its (non-static) fields.
+   FIELDNO says which field. */
 
 value_ptr
 value_primitive_field (arg1, offset, fieldno, arg_type)
@@ -736,13 +765,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);
     }
@@ -752,22 +781,23 @@ 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;
 }
 
 /* Given a value ARG1 of a struct or union type,
-   extract and return the value of one of its fields.
-   FIELDNO says which field.
-
-   For C++, must also be able to return values from static fields */
+   extract and return the value of one of its (non-static) fields.
+   FIELDNO says which field. */
 
 value_ptr
 value_field (arg1, fieldno)
This page took 0.045979 seconds and 4 git commands to generate.