* gdbtypes.h (TYPE_OBJFILE_OWNED, TYPE_OWNER): New macros.
[deliverable/binutils-gdb.git] / gdb / gnu-v3-abi.c
index 8f2a53be1939be66c6e7853efaaad368330b9265..09c8e69f7443a0389a43511321efe1e6b4850c15 100644 (file)
@@ -128,9 +128,7 @@ build_gdb_vtable_type (struct gdbarch *arch)
 
   /* ARCH can't give us the true ptrdiff_t type, so we guess.  */
   struct type *ptrdiff_type
-    = init_type (TYPE_CODE_INT,
-                gdbarch_ptr_bit (arch) / TARGET_CHAR_BIT, 0,
-                 "ptrdiff_t", 0);
+    = arch_integer_type (arch, gdbarch_ptr_bit (arch), 0, "ptrdiff_t");
 
   /* We assume no padding is necessary, since GDB doesn't know
      anything about alignment at the moment.  If this assumption bites
@@ -145,9 +143,7 @@ build_gdb_vtable_type (struct gdbarch *arch)
 
   /* ptrdiff_t vcall_and_vbase_offsets[0]; */
   FIELD_NAME (*field) = "vcall_and_vbase_offsets";
-  FIELD_TYPE (*field)
-    = create_array_type (0, ptrdiff_type,
-                         create_range_type (0, builtin_type_int32, 0, -1));
+  FIELD_TYPE (*field) = lookup_array_range_type (ptrdiff_type, 0, -1);
   FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
   offset += TYPE_LENGTH (FIELD_TYPE (*field));
   field++;
@@ -168,9 +164,7 @@ build_gdb_vtable_type (struct gdbarch *arch)
 
   /* void (*virtual_functions[0]) (); */
   FIELD_NAME (*field) = "virtual_functions";
-  FIELD_TYPE (*field)
-    = create_array_type (0, ptr_to_void_fn_type,
-                         create_range_type (0, builtin_type_int32, 0, -1));
+  FIELD_TYPE (*field) = lookup_array_range_type (ptr_to_void_fn_type, 0, -1);
   FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
   offset += TYPE_LENGTH (FIELD_TYPE (*field));
   field++;
@@ -178,10 +172,11 @@ build_gdb_vtable_type (struct gdbarch *arch)
   /* We assumed in the allocation above that there were four fields.  */
   gdb_assert (field == (field_list + 4));
 
-  t = init_type (TYPE_CODE_STRUCT, offset, 0, 0, 0);
+  t = arch_type (arch, TYPE_CODE_STRUCT, offset, NULL);
   TYPE_NFIELDS (t) = field - field_list;
   TYPE_FIELDS (t) = field_list;
   TYPE_TAG_NAME (t) = "gdb_gnu_v3_abi_vtable";
+  INIT_CPLUS_SPECIFIC (t);
 
   return t;
 }
@@ -269,8 +264,7 @@ gnuv3_rtti_type (struct value *value,
   
   /* Find the linker symbol for this vtable.  */
   vtable_symbol
-    = lookup_minimal_symbol_by_pc (VALUE_ADDRESS (vtable)
-                                   + value_offset (vtable)
+    = lookup_minimal_symbol_by_pc (value_address (vtable)
                                    + value_embedded_offset (vtable));
   if (! vtable_symbol)
     return NULL;
@@ -360,7 +354,7 @@ gnuv3_get_virtual_fn (struct gdbarch *gdbarch, struct value *container,
 
   /* Fetch the appropriate function pointer from the vtable.  */
   vfn = value_subscript (value_field (vtable, vtable_field_virtual_functions),
-                         value_from_longest (builtin_type_int32, vtable_index));
+                         vtable_index);
 
   /* If this architecture uses function descriptors directly in the vtable,
      then the address of the vtable entry is actually a "function pointer"
@@ -420,7 +414,7 @@ gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
   struct type *ptr_type;
   struct value *vtable;
   struct type *vbasetype;
-  struct value *offset_val, *vbase_array;
+  struct value *vbase_array;
   CORE_ADDR vtable_address;
   long int cur_base_offset, base_offset;
   int vbasetype_vptr_fieldno;
@@ -460,7 +454,7 @@ gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
      start of whichever baseclass it resides in, as a sanity measure - iff
      we have debugging information for that baseclass.  */
 
-  vbasetype = TYPE_VPTR_BASETYPE (type);
+  vbasetype = check_typedef (TYPE_VPTR_BASETYPE (type));
   vbasetype_vptr_fieldno = get_vptr_fieldno (vbasetype, NULL);
 
   if (vbasetype_vptr_fieldno >= 0
@@ -472,9 +466,8 @@ gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
   vtable
     = value_at_lazy (vtable_type,
                     vtable_address - vtable_address_point_offset (gdbarch));
-  offset_val = value_from_longest (builtin_type_int32, cur_base_offset);
   vbase_array = value_field (vtable, vtable_field_vcall_and_vbase_offsets);
-  base_offset = value_as_long (value_subscript (vbase_array, offset_val));
+  base_offset = value_as_long (value_subscript (vbase_array, cur_base_offset));
   return base_offset;
 }
 
@@ -482,7 +475,7 @@ gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
    which has virtual table index VOFFSET.  The method has an associated
    "this" adjustment of ADJUSTMENT bytes.  */
 
-const char *
+static const char *
 gnuv3_find_method_in (struct type *domain, CORE_ADDR voffset,
                      LONGEST adjustment)
 {
@@ -692,7 +685,6 @@ gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr)
   CORE_ADDR ptr_value;
   struct type *domain_type, *final_type, *method_type;
   LONGEST adjustment;
-  struct value *adjval;
   int vbit;
 
   domain_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));
@@ -724,9 +716,7 @@ gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr)
      You can provoke this case by casting a Base::* to a Derived::*, for
      instance.  */
   *this_p = value_cast (builtin_type (gdbarch)->builtin_data_ptr, *this_p);
-  adjval = value_from_longest (builtin_type (gdbarch)->builtin_long,
-                              adjustment);
-  *this_p = value_ptradd (*this_p, adjval);
+  *this_p = value_ptradd (*this_p, adjustment);
   *this_p = value_cast (final_type, *this_p);
 
   if (vbit)
This page took 0.026008 seconds and 4 git commands to generate.