diff options
author | Daniel Jacobowitz <drow@false.org> | 2001-11-30 17:47:51 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2001-11-30 17:47:51 +0000 |
commit | 21cfb3b661790e5e3153db2158f16c3991074553 (patch) | |
tree | e44271a3895e7bdced5d391621a51cf303155392 | |
parent | 215007a64883740af82c24537ecf5641163159f2 (diff) | |
download | gdb-21cfb3b661790e5e3153db2158f16c3991074553.zip gdb-21cfb3b661790e5e3153db2158f16c3991074553.tar.gz gdb-21cfb3b661790e5e3153db2158f16c3991074553.tar.bz2 |
* 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.
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/gnu-v3-abi.c | 25 | ||||
-rw-r--r-- | gdb/values.c | 3 |
3 files changed, 30 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0bac755..7078df5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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. diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index bffdca5..b9cc0db 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -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)); diff --git a/gdb/values.c b/gdb/values.c index d9a523f..5647097 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -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) |