+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.
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. */
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,
>= 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;
}
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));
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)