diff mbox

Fix dwarf2out ARRAY_TYPE handling (PR debug/77363)

Message ID 20160829195332.GL14857@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Aug. 29, 2016, 7:53 p.m. UTC
Hi!

In r231058 gen_type_die_with_usage has been changed to treat ARRAY_TYPE like
VECTOR_TYPE and not to use type_main_variant in that case.  But as the
following testcase shows, modified_type_die has similar condition and if
those two don't agree, modified_type_die just fails the lookup if
type_main_variant (type) != type, and we then fail to add DW_AT_type to
the DW_TAG_typedef because of that.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk/6.2/5.5?

2016-08-29  Jakub Jelinek  <jakub@redhat.com>

	PR debug/77363
	* dwarf2out.c (modified_type_die): Use lookup_type_die (type)
	instead of lookup_type_die (type_main_variant (type)) even for array
	types.

	* g++.dg/debug/dwarf2/pr77363.C: New test.


	Jakub

Comments

Richard Biener Aug. 30, 2016, 4:42 a.m. UTC | #1
On August 29, 2016 9:53:32 PM GMT+02:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>In r231058 gen_type_die_with_usage has been changed to treat ARRAY_TYPE
>like
>VECTOR_TYPE and not to use type_main_variant in that case.  But as the
>following testcase shows, modified_type_die has similar condition and
>if
>those two don't agree, modified_type_die just fails the lookup if
>type_main_variant (type) != type, and we then fail to add DW_AT_type to
>the DW_TAG_typedef because of that.
>
>Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
>for
>trunk/6.2/5.5?

OK.

Thanks,
Richard.

>2016-08-29  Jakub Jelinek  <jakub@redhat.com>
>
>	PR debug/77363
>	* dwarf2out.c (modified_type_die): Use lookup_type_die (type)
>	instead of lookup_type_die (type_main_variant (type)) even for array
>	types.
>
>	* g++.dg/debug/dwarf2/pr77363.C: New test.
>
>--- gcc/dwarf2out.c.jj	2016-08-29 12:35:49.000000000 +0200
>+++ gcc/dwarf2out.c	2016-08-29 18:05:42.171597789 +0200
>@@ -11474,7 +11474,8 @@ modified_type_die (tree type, int cv_qua
> 	 copy was created to help us keep track of typedef names) and
> 	 that copy might have a different TYPE_UID from the original
> 	 ..._TYPE node.  */
>-      if (TREE_CODE (type) != VECTOR_TYPE)
>+      if (TREE_CODE (type) != VECTOR_TYPE
>+	  && TREE_CODE (type) != ARRAY_TYPE)
> 	return lookup_type_die (type_main_variant (type));
>       else
> 	/* Vectors have the debugging information in the type,
>--- gcc/testsuite/g++.dg/debug/dwarf2/pr77363.C.jj	2016-08-29
>18:26:09.218310766 +0200
>+++ gcc/testsuite/g++.dg/debug/dwarf2/pr77363.C	2016-08-29
>18:30:03.232579332 +0200
>@@ -0,0 +1,20 @@
>+// PR debug/77363
>+// { dg-options "-gdwarf-2 -dA -fno-merge-debug-strings" }
>+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\)
>DW_TAG_typedef\[^\n\r\]*\[\n\r]*\[^\n\r\]*type2\[^\n\r\]*
>DW_AT_name\[^\n\r\]*\[\n\r]*\[^\n\r\]*
>DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]*
>DW_AT_decl_line\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_type" } }
>+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\)
>DW_TAG_typedef\[^\n\r\]*\[\n\r]*\[^\n\r\]*type3\[^\n\r\]*
>DW_AT_name\[^\n\r\]*\[\n\r]*\[^\n\r\]*
>DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]*
>DW_AT_decl_line\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_type" } }
>+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\)
>DW_TAG_typedef\[^\n\r\]*\[\n\r]*\[^\n\r\]*type4\[^\n\r\]*
>DW_AT_name\[^\n\r\]*\[\n\r]*\[^\n\r\]*
>DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]*
>DW_AT_decl_line\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_type" } }
>+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\)
>DW_TAG_typedef\[^\n\r\]*\[\n\r]*\[^\n\r\]*type5\[^\n\r\]*
>DW_AT_name\[^\n\r\]*\[\n\r]*\[^\n\r\]*
>DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]*
>DW_AT_decl_line\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_type" } }
>+
>+typedef unsigned short type1;
>+typedef unsigned char type2;
>+typedef type2 type3[16];
>+typedef unsigned char type4[16];
>+typedef struct
>+{
>+  struct
>+  {
>+    type3 a;
>+    type4 b;
>+  } c;
>+} type5;
>+type5 var;
>
>	Jakub
diff mbox

Patch

--- gcc/dwarf2out.c.jj	2016-08-29 12:35:49.000000000 +0200
+++ gcc/dwarf2out.c	2016-08-29 18:05:42.171597789 +0200
@@ -11474,7 +11474,8 @@  modified_type_die (tree type, int cv_qua
 	 copy was created to help us keep track of typedef names) and
 	 that copy might have a different TYPE_UID from the original
 	 ..._TYPE node.  */
-      if (TREE_CODE (type) != VECTOR_TYPE)
+      if (TREE_CODE (type) != VECTOR_TYPE
+	  && TREE_CODE (type) != ARRAY_TYPE)
 	return lookup_type_die (type_main_variant (type));
       else
 	/* Vectors have the debugging information in the type,
--- gcc/testsuite/g++.dg/debug/dwarf2/pr77363.C.jj	2016-08-29 18:26:09.218310766 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/pr77363.C	2016-08-29 18:30:03.232579332 +0200
@@ -0,0 +1,20 @@ 
+// PR debug/77363
+// { dg-options "-gdwarf-2 -dA -fno-merge-debug-strings" }
+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\) DW_TAG_typedef\[^\n\r\]*\[\n\r]*\[^\n\r\]*type2\[^\n\r\]* DW_AT_name\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_line\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_type" } }
+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\) DW_TAG_typedef\[^\n\r\]*\[\n\r]*\[^\n\r\]*type3\[^\n\r\]* DW_AT_name\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_line\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_type" } }
+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\) DW_TAG_typedef\[^\n\r\]*\[\n\r]*\[^\n\r\]*type4\[^\n\r\]* DW_AT_name\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_line\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_type" } }
+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\) DW_TAG_typedef\[^\n\r\]*\[\n\r]*\[^\n\r\]*type5\[^\n\r\]* DW_AT_name\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_line\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_type" } }
+
+typedef unsigned short type1;
+typedef unsigned char type2;
+typedef type2 type3[16];
+typedef unsigned char type4[16];
+typedef struct
+{
+  struct
+  {
+    type3 a;
+    type4 b;
+  } c;
+} type5;
+type5 var;