------- Comment #2 from jakub at gcc dot gnu dot org 2010-05-13 21:48 ------- If I understand it well, we should: --- dwarf2out.c 2010-05-13 23:36:24.000000000 +0200 +++ dwarf2out.c 2010-05-13 23:55:07.422464196 +0200 @@ -17094,10 +17094,19 @@ add_pure_or_virtual_attribute (dw_die_re add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
if (host_integerp (DECL_VINDEX (func_decl), 0)) - add_AT_loc (die, DW_AT_vtable_elem_location, - new_loc_descr (DW_OP_constu, - tree_low_cst (DECL_VINDEX (func_decl), 0), - 0)); + { + dw_loc_descr_ref loc; + HOST_WIDE_INT offset + = tree_low_cst (DECL_VINDEX (func_decl), 0) + * (POINTER_SIZE / BITS_PER_UNIT); + if (DWARF2_ADDR_SIZE == (POINTER_SIZE / BITS_PER_UNIT)) + loc = new_loc_descr (DW_OP_deref, 0, 0); + else + loc = new_loc_descr (DW_OP_deref_size, + POINTER_SIZE / BITS_PER_UNIT, 0); + add_loc_descr (&loc, new_loc_descr (DW_OP_plus_uconst, offset, 0)); + add_AT_loc (die, DW_AT_vtable_elem_location, loc); + } /* GNU extension: Record what type this method came from originally. * */ if (debug_info_level > DINFO_LEVEL_TERSE The consumers should be pushing address of object, so we need to dereference its first pointer to get at vtable + 8 resp. 16 and DECL_VINDEX is number of pointers after that spot (seems to be the case even on ia64). The problem is that gdb won't grok that, so we have a chicken-and-egg issue. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44126