Patchwork PR debug/49047 (linkage name missing for cdtors)

login
register
mail settings
Submitter Dodji Seketeli
Date May 30, 2011, 12:52 p.m.
Message ID <m3ei3gbbat.fsf@seketeli.org>
Download mbox | patch
Permalink /patch/97912/
State New
Headers show

Comments

Dodji Seketeli - May 30, 2011, 12:52 p.m.
Jason Merrill <jason@redhat.com> a écrit:

> I think that we only generate debug info for a function if we emit it,
> so it should always have pc attributes.  But you could try adding an
> assert to see if I'm right.

Indeed.  I have put the exploratory assert there and it did bootstrap
fine.

>
>> +      if (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);
>
> add_name_and_src_coords_attributes doesn't check TREE_PUBLIC, so I
> don't think we should here, either; we want the debugger to be able to
> find cloned constructors in anonymous namespaces, too.

Right.  I removed that check.

Tested on x86_64-unknown-linux-gnu against trunk.

gcc/

	* dwarf2out.c (gen_subprogram_die): Emit linkage name attribute
	for concrete functions containing the code of cloned functions.

gcc/testsuite/

	* g++.dg/debug/dwarf2/cdtor-1.C: New test.
---
 gcc/dwarf2out.c                             |    6 ++++++
 gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C |   17 +++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
Jason Merrill - May 31, 2011, 9:11 a.m.
OK.

Jason

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 55453a3..bc3f976 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -19636,6 +19636,12 @@  gen_subprogram_die (tree decl, dw_die_ref context_die)
 
       subr_die = new_die (DW_TAG_subprogram, context_die, decl);
       add_abstract_origin_attribute (subr_die, origin);
+      /*  This is where the actual code for a 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);
     }
   else if (old_die)
     {
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
new file mode 100644
index 0000000..6d39e54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
@@ -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 } }