* values.c (value_primitive_field): Add embedded_offset to the
authorDaniel Jacobowitz <drow@false.org>
Fri, 30 Nov 2001 17:47:51 +0000 (17:47 +0000)
committerDaniel Jacobowitz <drow@false.org>
Fri, 30 Nov 2001 17:47:51 +0000 (17:47 +0000)
        address of structure members.
        * gnu-v3-abi.c (gnuv3_rtti_type): Cast to base type before
        attempting to access vtable pointer.  Set using_enc_p if we cast.
        (gnuv3_virtual_fn_field): Call value_cast with structure rather than
        structure pointer.  Cast to base type before attempting to access
        vtable pointer.

gdb/ChangeLog
gdb/gnu-v3-abi.c
gdb/values.c

index 0bac7553a603c7b78ff733a968eae31469b0edd0..7078df567a9c5736f2fdad0335a0ba8b024b357c 100644 (file)
@@ -1,3 +1,13 @@
+2001-11-30  Daniel Jacobowitz  <drow@mvista.com>
+
+       * values.c (value_primitive_field): Add embedded_offset to the
+       address of structure members.
+       * gnu-v3-abi.c (gnuv3_rtti_type): Cast to base type before
+       attempting to access vtable pointer.  Set using_enc_p if we cast.
+       (gnuv3_virtual_fn_field): Call value_cast with structure rather than
+       structure pointer.  Cast to base type before attempting to access
+       vtable pointer.
+
 2001-11-29  Elena Zannoni  <ezannoni@redhat.com>
 
        * Makefile.in (ppc-linux-nat.o): Add dependency on ppc-tdep.h.
index bffdca56b95a759d769fe4a1123b0428ece259ab..b9cc0db904532dca304c43ef7459fc23e97b09a6 100644 (file)
@@ -194,6 +194,7 @@ gnuv3_rtti_type (struct value *value,
   const char *class_name;
   struct symbol *class_symbol;
   struct type *run_time_type;
+  struct type *base_type;
   LONGEST offset_to_top;
 
   /* We only have RTTI for class objects.  */
@@ -206,8 +207,18 @@ gnuv3_rtti_type (struct value *value,
   if (TYPE_VPTR_FIELDNO (value_type) == -1)
     return NULL;
 
+  if (using_enc_p)
+    *using_enc_p = 0;
+
   /* Fetch VALUE's virtual table pointer, and tweak it to point at
-     an instance of our imaginary gdb_gnu_v3_abi_vtable structure.   */
+     an instance of our imaginary gdb_gnu_v3_abi_vtable structure.  */
+  base_type = check_typedef (TYPE_VPTR_BASETYPE (value_type));
+  if (value_type != base_type)
+    {
+      value = value_cast (base_type, value);
+      if (using_enc_p)
+       *using_enc_p = 1;
+    }
   vtable_address
     = value_as_address (value_field (value, TYPE_VPTR_FIELDNO (value_type)));
   vtable = value_at_lazy (vtable_type,
@@ -260,8 +271,6 @@ gnuv3_rtti_type (struct value *value,
                    >= TYPE_LENGTH (run_time_type)));
   if (top_p)
     *top_p = - offset_to_top;
-  if (using_enc_p)
-    *using_enc_p = 0;
 
   return run_time_type;
 }
@@ -303,15 +312,17 @@ gnuv3_virtual_fn_field (struct value **value_p,
      function, cast our value to that baseclass.  This takes care of
      any necessary `this' adjustments.  */
   if (vfn_base != value_type)
-    /* It would be nicer to simply cast the value to the appropriate
-       base class (and I think that is supposed to be legal), but
-       value_cast only does the right magic when casting pointers.  */
-    value = value_ind (value_cast (vfn_base, value_addr (value)));
+    value = value_cast (vfn_base, value);
 
   /* Now value is an object of the appropriate base type.  Fetch its
      virtual table.  */
+  /* It might be possible to do this cast at the same time as the above.
+     Does multiple inheritance affect this?  */
+  if (TYPE_VPTR_BASETYPE (vfn_base) != vfn_base)
+    value = value_cast (TYPE_VPTR_BASETYPE (vfn_base), value);
   vtable_address
     = value_as_address (value_field (value, TYPE_VPTR_FIELDNO (vfn_base)));
+
   vtable = value_at_lazy (vtable_type,
                           vtable_address - vtable_address_point_offset (),
                           VALUE_BFD_SECTION (value));
index d9a523fb4fe983e913c38e1ee4218202a7714881..5647097e1b906e6d511199e2fcc87061bf6f1111 100644 (file)
@@ -929,7 +929,8 @@ value_primitive_field (register value_ptr arg1, int offset,
        memcpy (VALUE_CONTENTS_RAW (v),
                VALUE_CONTENTS_RAW (arg1) + offset,
                TYPE_LENGTH (type));
-      VALUE_OFFSET (v) = VALUE_OFFSET (arg1) + offset;
+      VALUE_OFFSET (v) = VALUE_OFFSET (arg1) + offset
+                        + VALUE_EMBEDDED_OFFSET (arg1);
     }
   VALUE_LVAL (v) = VALUE_LVAL (arg1);
   if (VALUE_LVAL (arg1) == lval_internalvar)
This page took 0.030991 seconds and 4 git commands to generate.