[PATCH] PR debug/43628

Dodji Seketeli dodji@redhat.com
Fri Apr 2 19:08:00 GMT 2010


Hello,

In the example of the patch below, when we output the DIE of the formal
parameter of t, we fail to emit the DW_AT_type pointing at the debug 
info of C.

This is because when add_type_attribute calls modified_type_die with a 
typedef variant type representing the self reference of C, we try to 
generate debug info for the typedef variant and gen_type_die_with_usage 
(rightfully) refuses to do so because TREE_ASM_WRITTEN is set for C.

I think we should not try to use the debug info of self reference 
typedefs so the patch below prevents modified_type from trying to return 
debug info for artificial typedefs. In that case, modified_type just 
returns the DIE of the main variant of C. Is that constraint too strong?

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

commit 967f3970cecbc50bb8e1babf6b1acaca9f0fa2e7
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Fri Apr 2 19:41:39 2010 +0200

    Fix PR debug/43628
    
    gcc/ChangeLog:
    	PR debug/43628
    	* dwarf2out.c (modified_type_die): Ignore artificial typedefs.
    
    gcc/testsuite/ChangeLog:
    	PR debug/43628
    	* g++.dg/debug/dwarf2/typedef2.C: New test.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 84a5fe7..47dbf4f 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -12128,7 +12128,8 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
   name = qualified_type ? TYPE_NAME (qualified_type) : NULL;
 
   /* Handle C typedef types.  */
-  if (name && TREE_CODE (name) == TYPE_DECL && DECL_ORIGINAL_TYPE (name))
+  if (name && TREE_CODE (name) == TYPE_DECL && DECL_ORIGINAL_TYPE (name)
+      && !DECL_ARTIFICIAL (name))
     {
       tree dtype = TREE_TYPE (name);
 
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/typedef2.C b/gcc/testsuite/g++.dg/debug/dwarf2/typedef2.C
new file mode 100644
index 0000000..5bf0499
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/typedef2.C
@@ -0,0 +1,11 @@
+// Origin: PR debug/43628
+// { dg-options "-g -dA" }
+// { dg-do compile }
+
+// { dg-final { scan-assembler-times "\[^\n\r\]*\\(DIE\[^\n\r\]*DW_TAG_formal_parameter\\)\[\n\r\]{1,2}\[^\n\r\]*DW_AT_type\[\n\r\]{1,2}" 1 } }
+class C
+{
+  public:
+  typedef void (*t) (C);
+};
+C::t f;

        Dodji



More information about the Gcc-patches mailing list