Patchwork PING^2: [patch] pr/54508: fix incomplete debug information for class

login
register
mail settings
Submitter Paul Koning
Date Oct. 4, 2012, 6:32 p.m.
Message ID <C75A84166056C94F84D238A44AF9F6AD2444C7@AUSX10MPS303.AMER.DELL.COM>
Download mbox | patch
Permalink /patch/189244/
State New
Headers show

Comments

Paul Koning - Oct. 4, 2012, 6:32 p.m.
On Oct 4, 2012, at 1:38 PM, Cary Coutant wrote:

>>      /* We also have to mark its parents as used.
>> -        (But we don't want to mark our parents' kids due to this.)  */
>> +        (But we don't want to mark our parent's kids due to this,
>> +        unless it is a class.)  */
>>      if (die->die_parent)
>> -       prune_unused_types_mark (die->die_parent, 0);
>> +       prune_unused_types_mark (die->die_parent,
>> +                                (die->die_parent->die_tag == DW_TAG_class_type ||
>> +                                 die->die_parent->die_tag == DW_TAG_structure_type ||
>> +                                 die->die_parent->die_tag == DW_TAG_union_type));
> 
> I'd suggest replacing these conditions with a call to class_scope_p().
> That will also cover DW_TAG_interface_type, which might be irrelevant
> for this particular case, but is probably good to cover in the general
> case.
> 
> -cary

Thanks, that makes it very simple.  Here is the updated patch.

Ok to commit with this change?

	paul

ChangeLog:

2012-10-04  Paul Koning  <ni1d@arrl.net>

	* dwarf2out.c (prune_unused_types_mark): Mark all of parent's
	children if parent is a class.

testsuite/ChangeLog:

2012-10-04  Paul Koning  <ni1d@arrl.net>

	* g++.dg/debug/dwarf2/pr54508.C: New.
Jakub Jelinek - Oct. 4, 2012, 6:58 p.m.
On Thu, Oct 04, 2012 at 06:32:20PM +0000, Paul_Koning@Dell.com wrote:
> --- testsuite/g++.dg/debug/dwarf2/pr54508.C	(revision 0)
> +++ testsuite/g++.dg/debug/dwarf2/pr54508.C	(revision 0)
> @@ -0,0 +1,67 @@
> +// PR debug/54508
> +// { dg-do compile }
> +// { dg-options "-g2 -dA" }

Better than this just add -fno-merge-debug-strings to dg-options

> +
> +// { dg-final { scan-assembler "\"cbase\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name\|DW_AT_name: \"cbase\"" } }
> +// { dg-final { scan-assembler "\"OPCODE\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name\|DW_AT_name: \"OPCODE\"" } }
> +// { dg-final { scan-assembler "\"bi\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name" } }
> +// { dg-final { scan-assembler "\"si\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name" } }
> +// { dg-final { scan-assembler "\"f1\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name" } }
> +// { dg-final { scan-assembler "\"f2\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name" } }
> +// { dg-final { scan-assembler-not "\"nc\\\\0\"\[ \t\]+\# DW_AT_name\|DW_AT_name: \"nc\"" } }

and use just one of the alternatives in the regexps.

	Jakub

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 192048)
+++ gcc/dwarf2out.c	(working copy)
@@ -21035,9 +21035,11 @@ 
       prune_unused_types_mark_generic_parms_dies (die);
 
       /* We also have to mark its parents as used.
-	 (But we don't want to mark our parents' kids due to this.)  */
+	 (But we don't want to mark our parent's kids due to this,
+	 unless it is a class.)  */
       if (die->die_parent)
-	prune_unused_types_mark (die->die_parent, 0);
+	prune_unused_types_mark (die->die_parent, 
+				 class_scope_p (die->die_parent));
 
       /* Mark any referenced nodes.  */
       prune_unused_types_walk_attribs (die);
Index: testsuite/g++.dg/debug/dwarf2/pr54508.C
===================================================================
--- testsuite/g++.dg/debug/dwarf2/pr54508.C	(revision 0)
+++ testsuite/g++.dg/debug/dwarf2/pr54508.C	(revision 0)
@@ -0,0 +1,67 @@ 
+// PR debug/54508
+// { dg-do compile }
+// { dg-options "-g2 -dA" }
+
+// { dg-final { scan-assembler "\"cbase\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name\|DW_AT_name: \"cbase\"" } }
+// { dg-final { scan-assembler "\"OPCODE\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name\|DW_AT_name: \"OPCODE\"" } }
+// { dg-final { scan-assembler "\"bi\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name" } }
+// { dg-final { scan-assembler "\"si\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name" } }
+// { dg-final { scan-assembler "\"f1\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name" } }
+// { dg-final { scan-assembler "\"f2\\\\0\"\[ \t\]+\[#;/!|@\]+ DW_AT_name" } }
+// { dg-final { scan-assembler-not "\"nc\\\\0\"\[ \t\]+\# DW_AT_name\|DW_AT_name: \"nc\"" } }
+
+class cbase
+
+{
+public:
+ static int si;
+    int bi;
+};
+
+class c : public cbase
+
+{
+public:
+ enum
+ {
+  OPCODE = 251
+ };
+ int i ;
+ static const char *testc (void) { return "foo"; }
+};
+
+struct s
+{
+    int f1;
+    static const char *tests (void) { return "test"; }
+};
+
+union u
+{
+    int f2;
+    double d;
+    static const char *testu (void) { return "test union"; }
+};
+
+namespace n 
+{
+    const char *ntest (void) { return "test n"; }
+
+    class nc
+    {
+    public:
+        int i;
+        static int sj;
+    };
+}
+
+extern void send (int, int, const void *, int);
+
+void test (int src)
+{
+  int cookie = 1;
+  send(src, c::OPCODE, c::testc (), cookie);
+  send(src, c::OPCODE, s::tests (), cookie);
+  send(src, c::OPCODE, u::testu (), cookie);
+  send(src, c::OPCODE, n::ntest (), cookie);
+}