* mn10300.igen (OP_F0F4): Need to load contents of register AN0
[platform/upstream/binutils.git] / gdb / valops.c
index 6e6eae0..f902304 100644 (file)
@@ -1,5 +1,5 @@
 /* Perform non-arithmetic operations on values, for GDB.
-   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995
+   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -32,13 +32,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include <errno.h>
 #include "gdb_string.h"
 
+/* Default to coercing float to double in function calls only when there is
+   no prototype.  Otherwise on targets where the debug information is incorrect
+   for either the prototype or non-prototype case, we can force it by defining
+   COERCE_FLOAT_TO_DOUBLE in the target configuration file. */
+
+#ifndef COERCE_FLOAT_TO_DOUBLE
+#define COERCE_FLOAT_TO_DOUBLE (param_type == NULL)
+#endif
+
 /* Local functions.  */
 
 static int typecmp PARAMS ((int staticp, struct type *t1[], value_ptr t2[]));
 
+#ifdef CALL_DUMMY
 static CORE_ADDR find_function_addr PARAMS ((value_ptr, struct type **));
+static value_ptr value_arg_coerce PARAMS ((value_ptr, struct type *));
+#endif
+
 
+#ifndef PUSH_ARGUMENTS
 static CORE_ADDR value_push PARAMS ((CORE_ADDR, value_ptr));
+#endif
 
 static value_ptr search_struct_field PARAMS ((char *, value_ptr, int,
                                              struct type *, int));
@@ -57,7 +72,9 @@ static value_ptr cast_into_complex PARAMS ((struct type *, value_ptr));
 
 /* Flag for whether we want to abandon failed expression evals by default.  */
 
+#if 0
 static int auto_abandon = 0;
+#endif
 
 \f
 /* Find the address of function name NAME in the inferior.  */
@@ -163,7 +180,7 @@ value_cast (type, arg2)
            low_bound = 0, high_bound = 0;
          new_length = val_length / element_length;
          if (val_length % element_length != 0)
-       warning("array element type size does not divide object size in cast");
+           warning("array element type size does not divide object size in cast");
          /* FIXME-type-allocation: need a way to free this type when we are
             done with it.  */
          range_type = create_range_type ((struct type *) NULL,
@@ -187,11 +204,11 @@ value_cast (type, arg2)
   COERCE_VARYING_ARRAY (arg2, type2);
   code2 = TYPE_CODE (type2);
 
-  if (code1 == TYPE_CODE_COMPLEX) 
-    return cast_into_complex (type, arg2); 
-  if (code1 == TYPE_CODE_BOOL
+  if (code1 == TYPE_CODE_COMPLEX)
+    return cast_into_complex (type, arg2);
+  if (code1 == TYPE_CODE_BOOL || code1 == TYPE_CODE_CHAR)
     code1 = TYPE_CODE_INT; 
-  if (code2 == TYPE_CODE_BOOL
+  if (code2 == TYPE_CODE_BOOL || code2 == TYPE_CODE_CHAR)
     code2 = TYPE_CODE_INT;
 
   scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_FLT
@@ -288,7 +305,8 @@ value_cast (type, arg2)
     }
   else if (VALUE_LVAL (arg2) == lval_memory)
     {
-      return value_at_lazy (type, VALUE_ADDRESS (arg2) + VALUE_OFFSET (arg2));
+      return value_at_lazy (type, VALUE_ADDRESS (arg2) + VALUE_OFFSET (arg2),
+                           VALUE_BFD_SECTION (arg2));
     }
   else if (code1 == TYPE_CODE_VOID)
     {
@@ -326,9 +344,10 @@ value_zero (type, lv)
    the contents are actually required.  */
 
 value_ptr
-value_at (type, addr)
+value_at (type, addr, sect)
      struct type *type;
      CORE_ADDR addr;
+     asection *sect;
 {
   register value_ptr val;
 
@@ -337,10 +356,23 @@ value_at (type, addr)
 
   val = allocate_value (type);
 
-  read_memory (addr, VALUE_CONTENTS_RAW (val), TYPE_LENGTH (type));
+#ifdef GDB_TARGET_IS_D10V
+  if (TYPE_TARGET_TYPE(type) && TYPE_CODE(TYPE_TARGET_TYPE(type)) == TYPE_CODE_FUNC)
+    {
+      int num;
+      short snum;
+      read_memory (addr, (char *)&snum, 2);
+      num = D10V_MAKE_IADDR(snum);
+      memcpy( VALUE_CONTENTS_RAW (val), &num, 4);
+    }
+  else
+#endif
+
+  read_memory_section (addr, VALUE_CONTENTS_RAW (val), TYPE_LENGTH (type), sect);
 
   VALUE_LVAL (val) = lval_memory;
   VALUE_ADDRESS (val) = addr;
+  VALUE_BFD_SECTION (val) = sect;
 
   return val;
 }
@@ -348,9 +380,10 @@ value_at (type, addr)
 /* Return a lazy value with type TYPE located at ADDR (cf. value_at).  */
 
 value_ptr
-value_at_lazy (type, addr)
+value_at_lazy (type, addr, sect)
      struct type *type;
      CORE_ADDR addr;
+     asection *sect;
 {
   register value_ptr val;
 
@@ -362,6 +395,7 @@ value_at_lazy (type, addr)
   VALUE_LVAL (val) = lval_memory;
   VALUE_ADDRESS (val) = addr;
   VALUE_LAZY (val) = 1;
+  VALUE_BFD_SECTION (val) = sect;
 
   return val;
 }
@@ -385,8 +419,22 @@ value_fetch_lazy (val)
   CORE_ADDR addr = VALUE_ADDRESS (val) + VALUE_OFFSET (val);
   int length = TYPE_LENGTH (VALUE_TYPE (val));
 
+#ifdef GDB_TARGET_IS_D10V
+  struct type *type = VALUE_TYPE(val);
+  if (TYPE_TARGET_TYPE(type) && TYPE_CODE(TYPE_TARGET_TYPE(type)) == TYPE_CODE_FUNC)
+    {
+      int num;
+      short snum;
+      read_memory (addr, (char *)&snum, 2);
+      num = D10V_MAKE_IADDR(snum);
+      memcpy( VALUE_CONTENTS_RAW (val), &num, 4);
+    }
+  else
+#endif
+
   if (length)
-    read_memory (addr, VALUE_CONTENTS_RAW (val), length);
+    read_memory_section (addr, VALUE_CONTENTS_RAW (val), length,
+                        VALUE_BFD_SECTION (val));
   VALUE_LAZY (val) = 0;
   return 0;
 }
@@ -407,12 +455,13 @@ value_assign (toval, fromval)
   if (!toval->modifiable)
     error ("Left operand of assignment is not a modifiable lvalue.");
 
-  COERCE_ARRAY (fromval);
   COERCE_REF (toval);
 
   type = VALUE_TYPE (toval);
   if (VALUE_LVAL (toval) != lval_internalvar)
     fromval = value_cast (type, fromval);
+  else
+    COERCE_ARRAY (fromval);
   CHECK_TYPEDEF (type);
 
   /* If TOVAL is a special machine register requiring conversion
@@ -439,7 +488,7 @@ value_assign (toval, fromval)
     {
     case lval_internalvar:
       set_internalvar (VALUE_INTERNALVAR (toval), fromval);
-      return VALUE_INTERNALVAR (toval)->value;
+      return value_copy (VALUE_INTERNALVAR (toval)->value);
 
     case lval_internalvar_component:
       set_internalvar_component (VALUE_INTERNALVAR (toval),
@@ -460,7 +509,7 @@ value_assign (toval, fromval)
                     + HOST_CHAR_BIT - 1)
                    / HOST_CHAR_BIT;
 
-         if (len > sizeof (LONGEST))
+         if (len > (int) sizeof (LONGEST))
            error ("Can't handle bitfields which don't fit in a %d bit word.",
                   sizeof (LONGEST) * HOST_CHAR_BIT);
 
@@ -485,7 +534,7 @@ value_assign (toval, fromval)
          char buffer[sizeof (LONGEST)];
           int len = REGISTER_RAW_SIZE (VALUE_REGNO (toval));
 
-         if (len > sizeof (LONGEST))
+         if (len > (int) sizeof (LONGEST))
            error ("Can't handle bitfields in registers larger than %d bits.",
                   sizeof (LONGEST) * HOST_CHAR_BIT);
 
@@ -614,10 +663,10 @@ Can't handle bitfield which doesn't fit in a single register.");
   /* If the field does not entirely fill a LONGEST, then zero the sign bits.
      If the field is signed, and is negative, then sign extend. */
   if ((VALUE_BITSIZE (toval) > 0)
-      && (VALUE_BITSIZE (toval) < 8 * sizeof (LONGEST)))
+      && (VALUE_BITSIZE (toval) < 8 * (int) sizeof (LONGEST)))
     {
       LONGEST fieldval = value_as_long (fromval);
-      LONGEST valmask = (((unsigned LONGEST) 1) << VALUE_BITSIZE (toval)) - 1;
+      LONGEST valmask = (((ULONGEST) 1) << VALUE_BITSIZE (toval)) - 1;
 
       fieldval &= valmask;
       if (!TYPE_UNSIGNED (type) && (fieldval & (valmask ^ (valmask >> 1))))
@@ -665,27 +714,26 @@ value_of_variable (var, b)
      struct block *b;
 {
   value_ptr val;
-  struct frame_info *frame;
+  struct frame_info *frame = NULL;
 
-  if (b == NULL)
-    /* Use selected frame.  */
-    frame = NULL;
-  else
+  if (!b)
+    frame = NULL;              /* Use selected frame.  */
+  else if (symbol_read_needs_frame (var))
     {
       frame = block_innermost_frame (b);
-      if (frame == NULL && symbol_read_needs_frame (var))
-       {
-         if (BLOCK_FUNCTION (b) != NULL
-             && SYMBOL_NAME (BLOCK_FUNCTION (b)) != NULL)
-           error ("No frame is currently executing in block %s.",
-                  SYMBOL_NAME (BLOCK_FUNCTION (b)));
-         else
-           error ("No frame is currently executing in specified block");
-       }
+      if (!frame)
+       if (BLOCK_FUNCTION (b)
+           && SYMBOL_NAME (BLOCK_FUNCTION (b)))
+         error ("No frame is currently executing in block %s.",
+                SYMBOL_NAME (BLOCK_FUNCTION (b)));
+       else
+         error ("No frame is currently executing in specified block");
     }
+
   val = read_var_value (var, frame);
-  if (val == 0)
+  if (!val)
     error ("Address of symbol \"%s\" is unknown.", SYMBOL_SOURCE_NAME (var));
+
   return val;
 }
 
@@ -732,12 +780,15 @@ value_ptr
 value_coerce_function (arg1)
      value_ptr arg1;
 {
+  value_ptr retval;
 
   if (VALUE_LVAL (arg1) != lval_memory)
     error ("Attempt to take address of value not located in memory.");
 
-  return value_from_longest (lookup_pointer_type (VALUE_TYPE (arg1)),
-               (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
+  retval = value_from_longest (lookup_pointer_type (VALUE_TYPE (arg1)),
+                              (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
+  VALUE_BFD_SECTION (retval) = VALUE_BFD_SECTION (arg1);
+  return retval;
 }  
 
 /* Return a pointer value for the object for which ARG1 is the contents.  */
@@ -746,6 +797,8 @@ value_ptr
 value_addr (arg1)
      value_ptr arg1;
 {
+  value_ptr retval;
+
   struct type *type = check_typedef (VALUE_TYPE (arg1));
   if (TYPE_CODE (type) == TYPE_CODE_REF)
     {
@@ -762,8 +815,10 @@ value_addr (arg1)
   if (VALUE_LVAL (arg1) != lval_memory)
     error ("Attempt to take address of value not located in memory.");
 
-  return value_from_longest (lookup_pointer_type (VALUE_TYPE (arg1)),
-               (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
+  retval = value_from_longest (lookup_pointer_type (VALUE_TYPE (arg1)),
+                              (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
+  VALUE_BFD_SECTION (retval) = VALUE_BFD_SECTION (arg1);
+  return retval;
 }
 
 /* Given a value of a pointer type, apply the C unary * operator to it.  */
@@ -785,9 +840,11 @@ value_ind (arg1)
      BUILTIN_TYPE_LONGEST would seem to be a mistake.  */
   if (TYPE_CODE (type1) == TYPE_CODE_INT)
     return value_at (builtin_type_int,
-                    (CORE_ADDR) value_as_long (arg1));
+                    (CORE_ADDR) value_as_long (arg1),
+                    VALUE_BFD_SECTION (arg1));
   else if (TYPE_CODE (type1) == TYPE_CODE_PTR)
-    return value_at_lazy (TYPE_TARGET_TYPE (type1), value_as_pointer (arg1));
+    return value_at_lazy (TYPE_TARGET_TYPE (type1), value_as_pointer (arg1),
+                         VALUE_BFD_SECTION (arg1));
   error ("Attempt to take contents of a non-pointer value.");
   return 0;  /* For lint -- never reached */
 }
@@ -799,7 +856,7 @@ value_ind (arg1)
 CORE_ADDR
 push_word (sp, word)
      CORE_ADDR sp;
-     unsigned LONGEST word;
+     ULONGEST word;
 {
   register int len = REGISTER_SIZE;
   char buffer[MAX_REGISTER_RAW_SIZE];
@@ -837,6 +894,8 @@ push_bytes (sp, buffer, len)
 
 /* Push onto the stack the specified value VALUE.  */
 
+#ifndef PUSH_ARGUMENTS
+
 static CORE_ADDR
 value_push (sp, arg)
      register CORE_ADDR sp;
@@ -855,6 +914,9 @@ value_push (sp, arg)
   return sp;
 }
 
+#endif /* !PUSH_ARGUMENTS */
+
+#ifdef CALL_DUMMY
 /* Perform the standard coercions that are specified
    for arguments to be passed to C functions.
 
@@ -886,10 +948,16 @@ value_arg_coerce (arg, param_type)
       if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int))
        type = builtin_type_int;
       break;
-    case TYPE_CODE_FLT:
-      if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_double))
-       type = builtin_type_double;
-      break;
+   case TYPE_CODE_FLT:
+     /* coerce float to double, unless the function prototype specifies float */
+     if (COERCE_FLOAT_TO_DOUBLE)
+       {
+        if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_double))
+          type = builtin_type_double;
+        else if (TYPE_LENGTH (type) > TYPE_LENGTH (builtin_type_double))
+          type = builtin_type_long_double;
+       }
+     break;
     case TYPE_CODE_FUNC:
       type = lookup_pointer_type (type);
       break;
@@ -976,7 +1044,6 @@ find_function_addr (function, retval_type)
   return funaddr;
 }
 
-#if defined (CALL_DUMMY)
 /* All this stuff with a dummy frame may seem unnecessarily complicated
    (why not just save registers in GDB?).  The purpose of pushing a dummy
    frame which looks just like a real frame is so that if you call a
@@ -1006,18 +1073,18 @@ call_function_by_hand (function, nargs, args)
   CORE_ADDR start_sp;
   /* CALL_DUMMY is an array of words (REGISTER_SIZE), but each word
      is in host byte order.  Before calling FIX_CALL_DUMMY, we byteswap it
-     and remove any extra bytes which might exist because unsigned LONGEST is
+     and remove any extra bytes which might exist because ULONGEST is
      bigger than REGISTER_SIZE.  */
-  static unsigned LONGEST dummy[] = CALL_DUMMY;
-  char dummy1[REGISTER_SIZE * sizeof dummy / sizeof (unsigned LONGEST)];
+  static ULONGEST dummy[] = CALL_DUMMY;
+  char dummy1[REGISTER_SIZE * sizeof dummy / sizeof (ULONGEST)];
   CORE_ADDR old_sp;
   struct type *value_type;
   unsigned char struct_return;
-  CORE_ADDR struct_addr;
+  CORE_ADDR struct_addr = 0;
   struct inferior_status inf_status;
   struct cleanup *old_chain;
   CORE_ADDR funaddr;
-  int using_gcc;
+  int using_gcc;       /* Set to version of gcc in use, or zero if not gcc */
   CORE_ADDR real_pc;
   struct type *ftype = check_typedef (SYMBOL_TYPE (function));
 
@@ -1047,8 +1114,8 @@ call_function_by_hand (function, nargs, args)
 
   {
     struct block *b = block_for_pc (funaddr);
-    /* If compiled without -g, assume GCC.  */
-    using_gcc = b == NULL ? 0 : BLOCK_GCC_COMPILED (b);
+    /* If compiled without -g, assume GCC 2.  */
+    using_gcc = (b == NULL ? 2 : BLOCK_GCC_COMPILED (b));
   }
 
   /* Are we returning a value using a structure return or a normal
@@ -1059,10 +1126,10 @@ call_function_by_hand (function, nargs, args)
 
   /* Create a call sequence customized for this function
      and the number of arguments for it.  */
-  for (i = 0; i < sizeof dummy / sizeof (dummy[0]); i++)
+  for (i = 0; i < (int) (sizeof (dummy) / sizeof (dummy[0])); i++)
     store_unsigned_integer (&dummy1[i * REGISTER_SIZE],
                            REGISTER_SIZE,
-                           (unsigned LONGEST)dummy[i]);
+                           (ULONGEST)dummy[i]);
 
 #ifdef GDB_TARGET_IS_HPPA
   real_pc = FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args,
@@ -1137,12 +1204,20 @@ call_function_by_hand (function, nargs, args)
        if ((TYPE_CODE (arg_type) == TYPE_CODE_STRUCT
             || TYPE_CODE (arg_type) == TYPE_CODE_UNION
             || TYPE_CODE (arg_type) == TYPE_CODE_ARRAY
-            || TYPE_CODE (arg_type) == TYPE_CODE_STRING)
+            || TYPE_CODE (arg_type) == TYPE_CODE_STRING
+            || TYPE_CODE (arg_type) == TYPE_CODE_BITSTRING
+            || TYPE_CODE (arg_type) == TYPE_CODE_SET
+            || (TYPE_CODE (arg_type) == TYPE_CODE_FLT
+                && TYPE_LENGTH (arg_type) > 8)
+            )
          && REG_STRUCT_HAS_ADDR (using_gcc, arg_type))
          {
            CORE_ADDR addr;
            int len = TYPE_LENGTH (arg_type);
 #ifdef STACK_ALIGN
+  /* MVS 11/22/96: I think at least some of this stack_align code is
+     really broken.  Better to let PUSH_ARGUMENTS adjust the stack in
+     a target-defined manner.  */
            int aligned_len = STACK_ALIGN (len);
 #else
            int aligned_len = len;
@@ -1179,6 +1254,9 @@ call_function_by_hand (function, nargs, args)
     {
       int len = TYPE_LENGTH (value_type);
 #ifdef STACK_ALIGN
+  /* MVS 11/22/96: I think at least some of this stack_align code is
+     really broken.  Better to let PUSH_ARGUMENTS adjust the stack in
+     a target-defined manner.  */
       len = STACK_ALIGN (len);
 #endif
 #if 1 INNER_THAN 2
@@ -1190,9 +1268,12 @@ call_function_by_hand (function, nargs, args)
 #endif
     }
 
-#ifdef STACK_ALIGN
-  /* If stack grows down, we must leave a hole at the top. */
+#if defined(STACK_ALIGN) && (1 INNER_THAN 2)
+  /* MVS 11/22/96: I think at least some of this stack_align code is
+     really broken.  Better to let PUSH_ARGUMENTS adjust the stack in
+     a target-defined manner.  */
   {
+  /* If stack grows down, we must leave a hole at the top. */
     int len = 0;
 
     for (i = nargs - 1; i >= 0; i--)
@@ -1200,11 +1281,7 @@ call_function_by_hand (function, nargs, args)
 #ifdef CALL_DUMMY_STACK_ADJUST
     len += CALL_DUMMY_STACK_ADJUST;
 #endif
-#if 1 INNER_THAN 2
     sp -= STACK_ALIGN (len) - len;
-#else
-    sp += STACK_ALIGN (len) - len;
-#endif
   }
 #endif /* STACK_ALIGN */
 
@@ -1215,11 +1292,38 @@ call_function_by_hand (function, nargs, args)
     sp = value_push (sp, args[i]);
 #endif /* !PUSH_ARGUMENTS */
 
+#ifdef PUSH_RETURN_ADDRESS     /* for targets that use no CALL_DUMMY */
+  /* There are a number of targets now which actually don't write any
+     CALL_DUMMY instructions into the target, but instead just save the
+     machine state, push the arguments, and jump directly to the callee
+     function.  Since this doesn't actually involve executing a JSR/BSR
+     instruction, the return address must be set up by hand, either by
+     pushing onto the stack or copying into a return-address register
+     as appropriate.  Formerly this has been done in PUSH_ARGUMENTS, 
+     but that's overloading its functionality a bit, so I'm making it
+     explicit to do it here.  */
+  sp = PUSH_RETURN_ADDRESS(real_pc, sp);
+#endif /* PUSH_RETURN_ADDRESS */
+
+#if defined(STACK_ALIGN) && !(1 INNER_THAN 2)
+  {
+  /* If stack grows up, we must leave a hole at the bottom, note
+     that sp already has been advanced for the arguments!  */
+#ifdef CALL_DUMMY_STACK_ADJUST
+    sp += CALL_DUMMY_STACK_ADJUST;
+#endif
+    sp = STACK_ALIGN (sp);
+  }
+#endif /* STACK_ALIGN */
+
+/* XXX This seems wrong.  For stacks that grow down we shouldn't do
+   anything here!  */
+  /* MVS 11/22/96: I think at least some of this stack_align code is
+     really broken.  Better to let PUSH_ARGUMENTS adjust the stack in
+     a target-defined manner.  */
 #ifdef CALL_DUMMY_STACK_ADJUST
 #if 1 INNER_THAN 2
   sp -= CALL_DUMMY_STACK_ADJUST;
-#else
-  sp += CALL_DUMMY_STACK_ADJUST;
 #endif
 #endif /* CALL_DUMMY_STACK_ADJUST */
 
@@ -1338,7 +1442,7 @@ value_array (lowbound, highbound, elemvec)
 {
   int nelem;
   int idx;
-  int typelength;
+  unsigned int typelength;
   value_ptr val;
   struct type *rangetype;
   struct type *arraytype;
@@ -1361,6 +1465,24 @@ value_array (lowbound, highbound, elemvec)
        }
     }
 
+  rangetype = create_range_type ((struct type *) NULL, builtin_type_int,
+                                lowbound, highbound);
+  arraytype = create_array_type ((struct type *) NULL, 
+                                VALUE_TYPE (elemvec[0]), rangetype);
+
+  if (!current_language->c_style_arrays)
+    {
+      val = allocate_value (arraytype);
+      for (idx = 0; idx < nelem; idx++)
+       {
+         memcpy (VALUE_CONTENTS_RAW (val) + (idx * typelength),
+                 VALUE_CONTENTS (elemvec[idx]),
+                 typelength);
+       }
+      VALUE_BFD_SECTION (val) = VALUE_BFD_SECTION (elemvec[0]);
+      return val;
+    }
+
   /* Allocate space to store the array in the inferior, and then initialize
      it by copying in each element.  FIXME:  Is it worth it to create a
      local buffer in which to collect each value and then write all the
@@ -1375,11 +1497,7 @@ value_array (lowbound, highbound, elemvec)
 
   /* Create the array type and set up an array value to be evaluated lazily. */
 
-  rangetype = create_range_type ((struct type *) NULL, builtin_type_int,
-                                lowbound, highbound);
-  arraytype = create_array_type ((struct type *) NULL, 
-                                VALUE_TYPE (elemvec[0]), rangetype);
-  val = value_at_lazy (arraytype, addr);
+  val = value_at_lazy (arraytype, addr, VALUE_BFD_SECTION (elemvec[0]));
   return (val);
 }
 
@@ -1419,7 +1537,7 @@ value_string (ptr, len)
   addr = allocate_space_in_inferior (len);
   write_memory (addr, ptr, len);
 
-  val = value_at_lazy (stringtype, addr);
+  val = value_at_lazy (stringtype, addr, NULL);
   return (val);
 }
 
@@ -1544,7 +1662,7 @@ search_struct_field (name, arg1, offset, type, looking_for_baseclass)
                    error ("Internal error: could not find physical static variable named %s",
                           phys_name);
                v = value_at (TYPE_FIELD_TYPE (type, i),
-                             (CORE_ADDR)SYMBOL_BLOCK_VALUE (sym));
+                             SYMBOL_VALUE_ADDRESS (sym), SYMBOL_BFD_SECTION (sym));
              }
            else
              v = value_primitive_field (arg1, offset, i, type);
@@ -1662,6 +1780,7 @@ search_struct_method (name, arg1p, args, offset, static_memfuncp, type)
   for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--)
     {
       char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
+      /* FIXME!  May need to check for ARM demangling here */
       if (strncmp(t_field_name, "__", 2)==0 ||
        strncmp(t_field_name, "op", 2)==0 ||
        strncmp(t_field_name, "type", 4)==0 )
@@ -1817,11 +1936,19 @@ value_struct_elt (argp, args, name, static_memfuncp, err)
     {
       if (!args[1])
        {
-         /* destructors are a special case.  */
-         v = value_fn_field (NULL, TYPE_FN_FIELDLIST1 (t, 0),
-                             TYPE_FN_FIELDLIST_LENGTH (t, 0), 0, 0);
-         if (!v) error("could not find destructor function named %s.", name);
-         else return v;
+         /* Destructors are a special case.  */
+         int m_index, f_index;
+
+         v = NULL;
+         if (get_destructor_fn_field (t, &m_index, &f_index))
+           {
+             v = value_fn_field (NULL, TYPE_FN_FIELDLIST1 (t, m_index),
+                                 f_index, NULL, 0);
+           }
+         if (v == NULL)
+           error ("could not find destructor function named %s.", name);
+         else
+           return v;
        }
       else
        {
@@ -1862,7 +1989,7 @@ destructor_name_p (name, type)
     {
       char *dname = type_name_no_tag (type);
       char *cp = strchr (dname, '<');
-      int len;
+      unsigned int len;
 
       /* Do not compare the template part for template classes.  */
       if (cp == NULL)
@@ -1900,7 +2027,11 @@ check_field_in (type, name)
 
   /* Destructors are a special case.  */
   if (destructor_name_p (name, type))
-    return 1;
+    {
+      int m_index, f_index;
+
+      return get_destructor_fn_field (type, &m_index, &f_index);
+    }
 
   for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
     {
@@ -1987,7 +2118,8 @@ value_struct_elt_for_reference (domain, offset, curtype, name, intype)
                error ("Internal error: could not find physical static variable named %s",
                       phys_name);
              return value_at (SYMBOL_TYPE (sym),
-                              (CORE_ADDR)SYMBOL_BLOCK_VALUE (sym));
+                              SYMBOL_VALUE_ADDRESS (sym),
+                              SYMBOL_BFD_SECTION (sym));
            }
          if (TYPE_FIELD_PACKED (t, i))
            error ("pointers to bitfield members not allowed");
@@ -2178,7 +2310,7 @@ value_slice (array, lowbound, length)
      done with it.  */
   slice_range_type = create_range_type ((struct type*) NULL,
                                        TYPE_TARGET_TYPE (range_type),
-                                       lowerbound, lowerbound + length - 1);
+                                       lowbound, lowbound + length - 1);
   if (TYPE_CODE (array_type) == TYPE_CODE_BITSTRING)
     {
       int i;