Add debug output about skipping files and functions
[deliverable/binutils-gdb.git] / gdb / valops.c
index e038c04fd1df2551a7ab34b05d8fee35428b4937..de6f839c33c921cf561cb860b73a3ce6962cf110 100644 (file)
@@ -36,7 +36,7 @@
 #include "cp-support.h"
 #include "target-float.h"
 #include "tracepoint.h"
-#include "observer.h"
+#include "observable.h"
 #include "objfiles.h"
 #include "extension.h"
 #include "byte-vector.h"
@@ -244,7 +244,7 @@ value_cast_structs (struct type *type, struct value *v2)
      offset the pointer rather than just change its type.  */
   if (TYPE_NAME (t1) != NULL)
     {
-      v = search_struct_field (type_name_no_tag (t1),
+      v = search_struct_field (TYPE_NAME (t1),
                               v2, t2, 1);
       if (v)
        return v;
@@ -273,7 +273,7 @@ value_cast_structs (struct type *type, struct value *v2)
              && !strcmp (TYPE_NAME (real_type), TYPE_NAME (t1)))
            return v;
 
-         v = search_struct_field (type_name_no_tag (t2), v, real_type, 1);
+         v = search_struct_field (TYPE_NAME (t2), v, real_type, 1);
          if (v)
            return v;
        }
@@ -281,7 +281,7 @@ value_cast_structs (struct type *type, struct value *v2)
       /* Try downcasting using information from the destination type
         T2.  This wouldn't work properly for classes with virtual
         bases, but those were handled above.  */
-      v = search_struct_field (type_name_no_tag (t2),
+      v = search_struct_field (TYPE_NAME (t2),
                               value_zero (t1, not_lval), t1, 1);
       if (v)
        {
@@ -964,7 +964,7 @@ read_value_memory (struct value *val, LONGEST bit_offset,
       enum target_xfer_status status;
       ULONGEST xfered_partial;
 
-      status = target_xfer_partial (current_target.beneath,
+      status = target_xfer_partial (current_top_target (),
                                    object, NULL,
                                    buffer + xfered_total * unit_size, NULL,
                                    memaddr + xfered_total,
@@ -1177,7 +1177,7 @@ value_assign (struct value *toval, struct value *fromval)
              }
          }
 
-       observer_notify_register_changed (frame, value_reg);
+       gdb::observers::register_changed.notify (frame, value_reg);
        break;
       }
 
@@ -1208,7 +1208,7 @@ value_assign (struct value *toval, struct value *fromval)
     case lval_register:
     case lval_computed:
 
-      observer_notify_target_changed (&current_target);
+      gdb::observers::target_changed.notify (current_top_target ());
 
       /* Having destroyed the frame cache, restore the selected
         frame.  */
@@ -1588,7 +1588,6 @@ value_ind (struct value *arg1)
     }
 
   error (_("Attempt to take contents of a non-pointer value."));
-  return 0;                    /* For lint -- never reached.  */
 }
 \f
 /* Create a value for an array by allocating space in GDB, copying the
@@ -2257,6 +2256,50 @@ value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype,
   return NULL;
 }
 
+/* See value.h.  */
+
+int
+value_union_variant (struct type *union_type, const gdb_byte *contents)
+{
+  gdb_assert (TYPE_CODE (union_type) == TYPE_CODE_UNION
+             && TYPE_FLAG_DISCRIMINATED_UNION (union_type));
+
+  struct dynamic_prop *discriminant_prop
+    = get_dyn_prop (DYN_PROP_DISCRIMINATED, union_type);
+  gdb_assert (discriminant_prop != nullptr);
+
+  struct discriminant_info *info
+    = (struct discriminant_info *) discriminant_prop->data.baton;
+  gdb_assert (info != nullptr);
+
+  /* If this is a univariant union, just return the sole field.  */
+  if (TYPE_NFIELDS (union_type) == 1)
+    return 0;
+  /* This should only happen for univariants, which we already dealt
+     with.  */
+  gdb_assert (info->discriminant_index != -1);
+
+  /* Compute the discriminant.  Note that unpack_field_as_long handles
+     sign extension when necessary, as does the DWARF reader -- so
+     signed discriminants will be handled correctly despite the use of
+     an unsigned type here.  */
+  ULONGEST discriminant = unpack_field_as_long (union_type, contents,
+                                               info->discriminant_index);
+
+  for (int i = 0; i < TYPE_NFIELDS (union_type); ++i)
+    {
+      if (i != info->default_index
+         && i != info->discriminant_index
+         && discriminant == info->discriminants[i])
+       return i;
+    }
+
+  if (info->default_index == -1)
+    error (_("Could not find variant corresponding to discriminant %s"),
+          pulongest (discriminant));
+  return info->default_index;
+}
+
 /* Search through the methods of an object (and its bases) to find a
    specified method.  Return the pointer to the fn_field list FN_LIST of
    overloaded instances defined in the source language.  If available
@@ -3149,7 +3192,7 @@ destructor_name_p (const char *name, struct type *type)
 {
   if (name[0] == '~')
     {
-      const char *dname = type_name_no_tag_or_error (type);
+      const char *dname = type_name_or_error (type);
       const char *cp = strchr (dname, '<');
       unsigned int len;
 
@@ -3199,7 +3242,7 @@ enum_constant_from_type (struct type *type, const char *name)
     }
 
   error (_("no constant named \"%s\" in enum \"%s\""),
-        name, TYPE_TAG_NAME (type));
+        name, TYPE_NAME (type));
 }
 
 /* C++: Given an aggregate type CURTYPE, and a member name NAME,
@@ -3299,7 +3342,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
                                int want_address,
                                enum noside noside)
 {
-  struct type *t = curtype;
+  struct type *t = check_typedef (curtype);
   int i;
   struct value *v, *result;
 
@@ -3537,7 +3580,7 @@ value_namespace_elt (const struct type *curtype,
 
   if (retval == NULL)
     error (_("No symbol \"%s\" in namespace \"%s\"."), 
-          name, TYPE_TAG_NAME (curtype));
+          name, TYPE_NAME (curtype));
 
   return retval;
 }
@@ -3553,7 +3596,7 @@ value_maybe_namespace_elt (const struct type *curtype,
                           const char *name, int want_address,
                           enum noside noside)
 {
-  const char *namespace_name = TYPE_TAG_NAME (curtype);
+  const char *namespace_name = TYPE_NAME (curtype);
   struct block_symbol sym;
   struct value *result;
 
This page took 0.113409 seconds and 4 git commands to generate.