diff options
author | Jason Merrill <jason@redhat.com> | 2001-11-29 21:38:43 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2001-11-29 21:38:43 -0500 |
commit | 649ce3f25afb756432e9e3c8558bf09f3daef4e5 (patch) | |
tree | c86dc6969fd82952537e402e6e79204e43f4aa63 /gcc/dwarf2out.c | |
parent | c7c737361bb8906ad2b086b971f581546f0297f3 (diff) | |
download | gcc-649ce3f25afb756432e9e3c8558bf09f3daef4e5.zip gcc-649ce3f25afb756432e9e3c8558bf09f3daef4e5.tar.gz gcc-649ce3f25afb756432e9e3c8558bf09f3daef4e5.tar.bz2 |
dwarf2out.c (add_data_member_location_attribute): Do the right thing for virtual bases.
* dwarf2out.c (add_data_member_location_attribute): Do the
right thing for virtual bases.
* dbxout.c (dbxout_type): For a virtual base, print the offset
within the vtable.
From-SVN: r47469
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 66 |
1 files changed, 54 insertions, 12 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index e5573bb..55bb264 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -8407,28 +8407,70 @@ add_data_member_location_attribute (die, decl) dw_die_ref die; tree decl; { - unsigned long offset; - dw_loc_descr_ref loc_descr; - enum dwarf_location_atom op; + long offset; + dw_loc_descr_ref loc_descr = 0; if (TREE_CODE (decl) == TREE_VEC) - offset = tree_low_cst (BINFO_OFFSET (decl), 0); + { + /* We're working on the TAG_inheritance for a base class. */ + + if (TREE_VIA_VIRTUAL (decl)) + { + /* For C++ virtual bases we can't just use BINFO_OFFSET, as they + aren't at a fixed offset from all (sub)objects of the same + type. We need to extract the appropriate offset from our + vtable. The following dwarf expression means + + BaseAddr = ObAddr + *((*ObAddr) - Offset) + + This is specific to the V3 ABI, of course. */ + + dw_loc_descr_ref tmp; + /* Make a copy of the object address. */ + tmp = new_loc_descr (DW_OP_dup, 0, 0); + add_loc_descr (&loc_descr, tmp); + /* Extract the vtable address. */ + tmp = new_loc_descr (DW_OP_deref, 0, 0); + add_loc_descr (&loc_descr, tmp); + /* Calculate the address of the offset. */ + offset = tree_low_cst (BINFO_VPTR_FIELD (decl), 0); + if (offset >= 0) + abort (); + tmp = int_loc_descriptor (-offset); + add_loc_descr (&loc_descr, tmp); + tmp = new_loc_descr (DW_OP_minus, 0, 0); + add_loc_descr (&loc_descr, tmp); + /* Extract the offset. */ + tmp = new_loc_descr (DW_OP_deref, 0, 0); + add_loc_descr (&loc_descr, tmp); + /* Add it to the object address. */ + tmp = new_loc_descr (DW_OP_plus, 0, 0); + add_loc_descr (&loc_descr, tmp); + } + else + offset = tree_low_cst (BINFO_OFFSET (decl), 0); + } else offset = field_byte_offset (decl); - /* The DWARF2 standard says that we should assume that the structure address - is already on the stack, so we can specify a structure field address - by using DW_OP_plus_uconst. */ + if (! loc_descr) + { + enum dwarf_location_atom op; + + /* The DWARF2 standard says that we should assume that the structure address + is already on the stack, so we can specify a structure field address + by using DW_OP_plus_uconst. */ #ifdef MIPS_DEBUGGING_INFO - /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator - correctly. It works only if we leave the offset on the stack. */ - op = DW_OP_constu; + /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator + correctly. It works only if we leave the offset on the stack. */ + op = DW_OP_constu; #else - op = DW_OP_plus_uconst; + op = DW_OP_plus_uconst; #endif - loc_descr = new_loc_descr (op, offset, 0); + loc_descr = new_loc_descr (op, offset, 0); + } add_AT_loc (die, DW_AT_data_member_location, loc_descr); } |