sim: cris/frv/h8300/iq2000/lm32/m32r/sh64: standardize cpu state
[deliverable/binutils-gdb.git] / gdb / valops.c
index f1779074943b92370dc1b77b00417e1e05072007..66c63c16c288db55520c487390616f1567d4d34d 100644 (file)
@@ -1,6 +1,6 @@
 /* Perform non-arithmetic operations on values, for GDB.
 
-   Copyright (C) 1986-2014 Free Software Foundation, Inc.
+   Copyright (C) 1986-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -38,7 +38,6 @@
 #include "tracepoint.h"
 #include "observer.h"
 #include "objfiles.h"
-#include "exceptions.h"
 #include "extension.h"
 
 extern unsigned int overload_debug;
@@ -140,7 +139,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
        }
 
       if (objf_p)
-       *objf_p = SYMBOL_SYMTAB (sym)->objfile;
+       *objf_p = symbol_objfile (sym);
 
       return value_of_variable (sym, NULL);
     }
@@ -333,7 +332,7 @@ value_cast_pointers (struct type *type, struct value *arg2,
          deprecated_set_value_type (v, type);
          return v;
        }
-   }
+    }
 
   /* No superclass found, just change the pointer type.  */
   arg2 = value_copy (arg2);
@@ -736,7 +735,7 @@ value_dynamic_cast (struct type *type, struct value *arg)
       && TYPE_CODE (resolved_type) != TYPE_CODE_REF)
     error (_("Argument to dynamic_cast must be a pointer or reference type"));
   if (TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_VOID
-      && TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_CLASS)
+      && TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_STRUCT)
     error (_("Argument to dynamic_cast must be pointer to class or `void *'"));
 
   class_type = check_typedef (TYPE_TARGET_TYPE (resolved_type));
@@ -749,7 +748,7 @@ value_dynamic_cast (struct type *type, struct value *arg)
       if (TYPE_CODE (arg_type) == TYPE_CODE_PTR)
        {
          arg_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
-         if (TYPE_CODE (arg_type) != TYPE_CODE_CLASS)
+         if (TYPE_CODE (arg_type) != TYPE_CODE_STRUCT)
            error (_("Argument to dynamic_cast does "
                     "not have pointer to class type"));
        }
@@ -762,7 +761,7 @@ value_dynamic_cast (struct type *type, struct value *arg)
     }
   else
     {
-      if (TYPE_CODE (arg_type) != TYPE_CODE_CLASS)
+      if (TYPE_CODE (arg_type) != TYPE_CODE_STRUCT)
        error (_("Argument to dynamic_cast does not have class type"));
     }
 
@@ -1170,6 +1169,7 @@ value_assign (struct value *toval, struct value *fromval)
              }
          }
 
+       observer_notify_register_changed (frame, value_reg);
        if (deprecated_register_changed_hook)
          deprecated_register_changed_hook (-1);
        break;
@@ -1721,7 +1721,7 @@ typecmp (int staticp, int varargs, int nargs,
       tt2 = check_typedef (value_type (t2[i]));
 
       if (TYPE_CODE (tt1) == TYPE_CODE_REF
-      /* We should be doing hairy argument matching, as below.  */
+         /* We should be doing hairy argument matching, as below.  */
          && (TYPE_CODE (check_typedef (TYPE_TARGET_TYPE (tt1)))
              == TYPE_CODE (tt2)))
        {
@@ -1825,9 +1825,7 @@ do_search_struct_field (const char *name, struct value *arg1, int offset,
          }
 
        if (t_field_name
-           && (t_field_name[0] == '\0'
-               || (TYPE_CODE (type) == TYPE_CODE_UNION
-                   && (strcmp_iw (t_field_name, "else") == 0))))
+           && t_field_name[0] == '\0')
          {
            struct type *field_type = TYPE_FIELD_TYPE (type, i);
 
@@ -1994,9 +1992,9 @@ search_struct_method (const char *name, struct value **arg1p,
       const 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)
+      if (startswith (t_field_name, "__") ||
+         startswith (t_field_name, "op") ||
+         startswith (t_field_name, "type"))
        {
          if (cplus_demangle_opname (t_field_name, dem_opname, DMGL_ANSI))
            t_field_name = dem_opname;
@@ -2055,7 +2053,7 @@ search_struct_method (const char *name, struct value **arg1p,
 
          /* The virtual base class pointer might have been
             clobbered by the user program.  Make sure that it
-           still points to a valid memory location.  */
+            still points to a valid memory location.  */
 
          if (offset < 0 || offset >= TYPE_LENGTH (type))
            {
@@ -2185,8 +2183,8 @@ value_struct_elt (struct value **argp, struct value **args,
       return v;
     }
 
-    v = search_struct_method (name, argp, args, 0, 
-                             static_memfuncp, t);
+  v = search_struct_method (name, argp, args, 0, 
+                           static_memfuncp, t);
   
   if (v == (struct value *) - 1)
     {
@@ -2546,7 +2544,7 @@ find_overload_match (struct value **args, int nargs,
         value_find_oload_method_list above.  */
       if (fns_ptr)
        {
-         gdb_assert (TYPE_DOMAIN_TYPE (fns_ptr[0].type) != NULL);
+         gdb_assert (TYPE_SELF_TYPE (fns_ptr[0].type) != NULL);
 
          src_method_oload_champ = find_oload_champ (args, nargs,
                                                     num_fns, fns_ptr, NULL,
@@ -3050,7 +3048,7 @@ find_oload_champ (struct value **args, int nargs,
            parm_types[jj] = (fns_ptr != NULL
                              ? (TYPE_FN_FIELD_ARGS (fns_ptr, ix)[jj].type)
                              : TYPE_FIELD_TYPE (SYMBOL_TYPE (oload_syms[ix]),
-                             jj));
+                                                jj));
        }
 
       /* Compare parameter types to supplied argument types.  Skip
@@ -3362,7 +3360,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
                  type = check_typedef (value_type (ptr));
                  gdb_assert (type != NULL
                              && TYPE_CODE (type) == TYPE_CODE_MEMBERPTR);
-                 tmp = lookup_pointer_type (TYPE_DOMAIN_TYPE (type));
+                 tmp = lookup_pointer_type (TYPE_SELF_TYPE (type));
                  v = value_cast_pointers (tmp, v, 1);
                  mem_offset = value_as_long (ptr);
                  tmp = lookup_pointer_type (TYPE_TARGET_TYPE (type));
@@ -3388,9 +3386,9 @@ value_struct_elt_for_reference (struct type *domain, int offset,
       const char *t_field_name = TYPE_FN_FIELDLIST_NAME (t, i);
       char dem_opname[64];
 
-      if (strncmp (t_field_name, "__", 2) == 0 
-         || strncmp (t_field_name, "op", 2) == 0 
-         || strncmp (t_field_name, "type", 4) == 0)
+      if (startswith (t_field_name, "__") 
+         || startswith (t_field_name, "op") 
+         || startswith (t_field_name, "type"))
        {
          if (cplus_demangle_opname (t_field_name, 
                                     dem_opname, DMGL_ANSI))
@@ -3571,15 +3569,6 @@ value_maybe_namespace_elt (const struct type *curtype,
   sym = cp_lookup_symbol_namespace (namespace_name, name,
                                    get_selected_block (0), VAR_DOMAIN);
 
-  if (sym == NULL)
-    {
-      char *concatenated_name = alloca (strlen (namespace_name) + 2
-                                       + strlen (name) + 1);
-
-      sprintf (concatenated_name, "%s::%s", namespace_name, name);
-      sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
-    }
-
   if (sym == NULL)
     return NULL;
   else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -3588,7 +3577,7 @@ value_maybe_namespace_elt (const struct type *curtype,
   else
     result = value_of_variable (sym, get_selected_block (0));
 
-  if (result && want_address)
+  if (want_address)
     result = value_addr (result);
 
   return result;
@@ -3603,7 +3592,7 @@ struct type *
 value_rtti_indirect_type (struct value *v, int *full, 
                          int *top, int *using_enc)
 {
-  struct value *target;
+  struct value *target = NULL;
   struct type *type, *real_type, *target_type;
 
   type = value_type (v);
@@ -3611,7 +3600,25 @@ value_rtti_indirect_type (struct value *v, int *full,
   if (TYPE_CODE (type) == TYPE_CODE_REF)
     target = coerce_ref (v);
   else if (TYPE_CODE (type) == TYPE_CODE_PTR)
-    target = value_ind (v);
+    {
+
+      TRY
+        {
+         target = value_ind (v);
+        }
+      CATCH (except, RETURN_MASK_ERROR)
+       {
+         if (except.error == MEMORY_ERROR)
+           {
+             /* value_ind threw a memory error. The pointer is NULL or
+                contains an uninitialized value: we can't determine any
+                type.  */
+             return NULL;
+           }
+         throw_exception (except);
+       }
+      END_CATCH
+    }
   else
     return NULL;
 
@@ -3747,12 +3754,15 @@ struct value *
 value_of_this_silent (const struct language_defn *lang)
 {
   struct value *ret = NULL;
-  volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ERROR)
+  TRY
     {
       ret = value_of_this (lang);
     }
+  CATCH (except, RETURN_MASK_ERROR)
+    {
+    }
+  END_CATCH
 
   return ret;
 }
This page took 0.039314 seconds and 4 git commands to generate.