[RFA] PR debug/41736

Dodji Seketeli dodji@redhat.com
Sat Oct 17 11:46:00 GMT 2009


Hello,

Consider this short code snippet:

template <int I> struct S {};
S<2> *s = 0;

The debug info generated for the S<2> type looks like:

~=~
.uleb128 0x2    # (DIE (0x2d) DW_TAG_structure_type)
.long   .LASF3  # DW_AT_name: "S<2>"
.byte   0x1     # DW_AT_declaration
~=~

There is no DW_TAG_template_value_param DIE generated.

The S<2> type is not used in this example - only the pointer to S<2> is used.
So the S<2> type is not fully instantiated and is thus considered non complete.

And the problem is that we are not generating template parameters debug info
for non complete types.

This patch relaxes that constraint and allows generating template
parameters debug info for non complete types.

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

commit 0b51ac60da6e3d30f61a571e4bbb938cf3ab079c
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Sat Oct 17 13:06:52 2009 +0200

    Patch for PR debug/41736
    
    gcc/ChangeLog:
    
	PR debug/41736
    	* dwarf2out.c (gen_generic_params_dies, gen_struct_or_union_type_die):
    	Emit template parameter debug info even for non complete types.
    
    gcc/testsuite/ChangeLog:
   
	PR debug/41736
    	* g++.dg/debug/dwarf2/template-params-8.C: New test.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1e47e7a..518197d 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -12196,7 +12196,7 @@ gen_generic_params_dies (tree t)
   int parms_num, i;
   dw_die_ref die = NULL;
 
-  if (!t || (TYPE_P (t) && !COMPLETE_TYPE_P (t)))
+  if (!t)
     return;
 
   if (TYPE_P (t))
@@ -18536,8 +18536,7 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die,
     remove_AT (type_die, DW_AT_declaration);
 
   /* Generate child dies for template paramaters.  */
-  if (debug_info_level > DINFO_LEVEL_TERSE
-      && COMPLETE_TYPE_P (type))
+  if (debug_info_level > DINFO_LEVEL_TERSE)
     gen_generic_params_dies (type);
 
   /* If this type has been completed, then give it a byte_size attribute and
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-8.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-8.C
new file mode 100644
index 0000000..5ffb75b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-8.C
@@ -0,0 +1,9 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin: PR debug/41736
+// { dg-options "-g -dA -fno-merge-debug-strings" }
+
+// There should be a DW_TAG_template_value_param for
+// the type S<2>.
+// { dg-final {scan-assembler-times "DIE \\(0x.*?\\) DW_TAG_template_value_param" 1 } }
+template <int I> struct S {};
+S<2> *s = 0;

-- 
Dodji Seketeli
Red Hat



More information about the Gcc-patches mailing list