@@ -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
@@ -19929,6 +19932,14 @@ 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));
+
+ 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. */
new file mode 100644
@@ -0,0 +1,17 @@
+// origin PR debug/49047
+// { dg-options "-g -dA" }
+// { dg-do compile }
+
+struct K
+{
+ K () { }
+ ~K () { }
+};
+
+int
+main()
+{
+ K k;
+}
+
+// { dg-final {scan-assembler-times "\[^\n\r\]*DW_AT_MIPS_linkage_name:" 2 } }