http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49047
--- Comment #2 from dodji at seketeli dot org <dodji at seketeli dot org>
2011-05-25 15:15:03 UTC ---
The candidate patch below might do what you want.
Note that, constructors/destructor functions are cloned. The cloning
process yields a DIE tree. So the destructor K::~K is represented by an
abstract function DIE. There is then a concrete function DIE (let's
call it 'foo'), that would effectively contain the code of K::~K, and
which DW_AT_abstract_origin points to the DIE of the abstract function.
It's for 'foo' that the patch below emits the linkage name. Is this
enough for your need?
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 55453a3..c49f90a 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -19601,6 +19601,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
dw_die_ref old_die = lookup_decl_die (decl);
int declaration = (current_function_decl != decl
|| class_or_namespace_scope_p (context_die));
+ bool fn_has_code_addr_p = false;
premark_used_types ();
@@ -19769,6 +19770,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
/* We have already generated the labels. */
add_AT_lbl_id (subr_die, DW_AT_low_pc, fde->dw_fde_begin);
add_AT_lbl_id (subr_die, DW_AT_high_pc, fde->dw_fde_end);
+ fn_has_code_addr_p = true;
}
else
{
@@ -19780,6 +19782,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
current_function_funcdef_no);
add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id);
+ fn_has_code_addr_p = true;
}
#if VMS_DEBUGGING_INFO
@@ -19928,7 +19931,15 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
if (cfun->static_chain_decl)
add_AT_location_description (subr_die, DW_AT_static_link,
- loc_list_from_tree (cfun->static_chain_decl, 2));
+ loc_list_from_tree (cfun->static_chain_decl, 2));
+
+ if (fn_has_code_addr_p && origin && TREE_PUBLIC (origin))
+ /* So this is where the actual code for a publicly accessible
+ cloned function is. Let's emit linkage name attribute for
+ it. This helps debuggers to e.g, set breakpoints into
+ constructors/destructors when the user asks "break
+ K::K". */
+ add_linkage_name (subr_die, decl);
}
/* Generate child dies for template paramaters. */