First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 27574
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Dodji Seketeli <dodji@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Jorn Wolfgang Rennecke <amylaar@gcc.gnu.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
25795.ii test case text/plain 2006-05-12 16:58 94 bytes Edit
25795-m.ii With the translation result for this file, the testcase can be linked text/plain 2006-05-12 17:02 89 bytes Edit
pr27574.C g++.dg/debug test case text/plain 2006-07-25 20:43 185 bytes Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 27574 depends on: Show dependency tree
Show dependency graph
Bug 27574 blocks: 29842

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2008-10-07 20:51 Opened: 2006-05-12 16:53
Compilation with -O0 -g no longer creates debug information for all variables.

------- Comment #1 From Jorn Wolfgang Rennecke 2006-05-12 16:58 -------
Created an attachment (id=11447) [edit]
test case

Compiled for either sh-elf or i686-pc-linux-gnu, currrent mainline cc1plus does
not generate any debug information for the variable 'problem'.

------- Comment #2 From Jorn Wolfgang Rennecke 2006-05-12 17:02 -------
Created an attachment (id=11448) [edit]
With the translation result for this file, the testcase can be linked

This file provides a definition of main and f so that when this file and
the test case are translated to an object file, they can be linked together
so that you can observe gdb showing - or rather not showing - the variable
named "problem".

------- Comment #3 From Andrew Pinski 2006-05-12 17:11 -------
Confirmed.

------- Comment #4 From Mark Mitchell 2006-05-25 02:34 -------
Will not be fixed in 4.1.1; adjust target milestone to 4.1.2.

------- Comment #5 From Daniel Jacobowitz 2006-07-22 20:05 -------
I am not going to track down what did it, but something has fixed this on the
4.2 branch.  I can reproduce it on Debian's 4.1 branch snapshot.  If someone
wants to fix it on 4.1, it should probably be easy to use the regression hunter
to identify what patch caused the string "problem" to appear in the assembly
output.  It is probably something in the last two and a half months, since the
bug was reported, but I do not see any obvious candidates.

------- Comment #6 From Jorn Wolfgang Rennecke 2006-07-25 12:14 -------
(In reply to comment #5)
> I am not going to track down what did it, but something has fixed this on the
> 4.2 branch.  I can reproduce it on Debian's 4.1 branch snapshot.  If someone
> wants to fix it on 4.1, it should probably be easy to use the regression hunter
> to identify what patch caused the string "problem" to appear in the assembly
> output.  It is probably something in the last two and a half months, since the
> bug was reported, but I do not see any obvious candidates.
> 
If this is fixed on mainline, the fix must be rather recent; I see this still
failing with
r115417: GNU C++ version 4.2.0 20060713 (experimental).
What is the oldest gcc 4.2 version where you saw this work?

------- Comment #7 From Daniel Jacobowitz 2006-07-25 13:27 -------
Subject: Re:  [4.1 Regression] MIssing debug info at -O0 for a local variable
in a C++ constructor

On Tue, Jul 25, 2006 at 12:14:46PM -0000, amylaar at gcc dot gnu dot org wrote:
> If this is fixed on mainline, the fix must be rather recent; I see this still
> failing with
> r115417: GNU C++ version 4.2.0 20060713 (experimental).
> What is the oldest gcc 4.2 version where you saw this work?

I tested it on HEAD on the day I posted (2006-07-22).  Could you check
whether that works for you, or it's something environmental?

------- Comment #8 From joern.rennecke@st.com 2006-07-25 17:08 -------
Subject: Re:  [4.1 Regression] MIssing debug info at -O0 for a local variable
in a C++ constructor

drow at false dot org wrote:

>------- Comment #7 from drow at gcc dot gnu dot org  2006-07-25 13:27 -------
>Subject: Re:  [4.1 Regression] MIssing debug info at -O0 for a local variable
>in a C++ constructor
>
>On Tue, Jul 25, 2006 at 12:14:46PM -0000, amylaar at gcc dot gnu dot org wrote:
>  
>
>>If this is fixed on mainline, the fix must be rather recent; I see this still
>>failing with
>>r115417: GNU C++ version 4.2.0 20060713 (experimental).
>>What is the oldest gcc 4.2 version where you saw this work?
>>    
>>
>
>I tested it on HEAD on the day I posted (2006-07-22).  Could you check
>whether that works for you, or it's something environmental?
>  
>
When I compile the testcase (using -g -O0) with a cc1plus built from todays
sources (r115734), a test search for "problem" in the .s file comes up 
empty.
OTOH, both a native and a cross build eventually failed.

Can you find out the exact version of gcc that you tested?

------- Comment #9 From Jorn Wolfgang Rennecke 2006-07-25 20:43 -------
Created an attachment (id=11938) [edit]
g++.dg/debug test case

As far as I can tell, as a g++.dg/debug test case, this passes for stabs, but
fails for dwarf.

------- Comment #10 From Daniel Jacobowitz 2006-07-26 03:52 -------
Subject: Re:  [4.1 Regression] MIssing debug info at -O0 for a local variable
in a C++ constructor

On Tue, Jul 25, 2006 at 05:08:18PM -0000, joern dot rennecke at st dot com
wrote:
> When I compile the testcase (using -g -O0) with a cc1plus built from todays
> sources (r115734), a test search for "problem" in the .s file comes up 
> empty.
> OTOH, both a native and a cross build eventually failed.
> 
> Can you find out the exact version of gcc that you tested?

Now it fails.  What the heck?

The problem is that an abstract instance of 'problem' is never emitted. 
For the two concrete instances we try to reference the abstract copy
but there isn't one.  The variable is emitted, but without a name.

The first abstract instance of A::A is a declaration.  Later a
"definition" (still abstract) is seen.  But its DECL_INITIAL is
error_mark_node!

If I had to guess I'd say that this was a C++ front end problem, or
maybe a recent change in cgraph.  I don't have time to debug it further
right now.  The abstract copy of the function has to have a body, or
dwarf2out has no structure with which to describe the local variables.

------- Comment #11 From Jorn Wolfgang Rennecke 2006-07-26 12:30 -------
(In reply to comment #10)
 > If I had to guess I'd say that this was a C++ front end problem, or
> maybe a recent change in cgraph.

It can't have been a particularly recent change, since it already failed
with GNU C++ version 4.1.0 20050323 (experimental) (sh-elf) .
It worked with GNU C++ version 4.1.0 20050314 (experimental) (sh-elf) .

------- Comment #12 From Daniel Jacobowitz 2006-07-26 13:59 -------
It is a cgraph change.  There were several patches affecting cgraph_remove_node
during this time period; it was probably one of those.  The problem is that we
throw away the body of the abstract copy of the constructor, before we get
around to emitting debug information for it.

There's already a debug hook at what looks like the right time.  It's just not
used for dwarf2: deferred_inline_function.  It was replaced by
outlining_inline_function, which is called only when we know we'll generate a
concrete instance.

There's a couple of things we could do:
  - Not throw away the body.
  - Try to generate the debug info earlier, and then prune it if it isn't
needed.
  - Try to treat one of the concrete clones (whose bodies we need) as the
origin.

I think the first one is going to be safest for now.

I don't really see how to do it.  Jan, do you have a suggestion?

------- Comment #13 From Jorn Wolfgang Rennecke 2006-07-27 17:29 -------
(In reply to comment #12)
> It is a cgraph change.  There were several patches affecting cgraph_remove_node
> during this time period; it was probably one of those.

The problem appeared from r96653 to r96654; AFAICT this is the gcc-patches
posting for the associated patch:
http://gcc.gnu.org/ml/gcc-patches/2005-03/msg01709.html

------- Comment #14 From Daniel Jacobowitz 2006-07-27 20:12 -------
Subject: Re:  [4.1/4.2 Regression] MIssing debug info at -O0 for a local
variable in a C++ constructor

On Thu, Jul 27, 2006 at 05:29:38PM -0000, amylaar at gcc dot gnu dot org wrote:
> The problem appeared from r96653 to r96654; AFAICT this is the gcc-patches
> posting for the associated patch:
> http://gcc.gnu.org/ml/gcc-patches/2005-03/msg01709.html

Jan and Dan Berlin suggested that the right fix for this bug might be
to not register the uncloned constructor with cgraph, only the clones.

------- Comment #15 From Daniel Jacobowitz 2006-08-25 18:57 -------
I don't think I can sort this one out.  I think the easiest solution will be to
check when marking a function as reachable whether it has an abstract origin,
and if so set a flag in the abstract origin preventing its body from being
killed, but I can't keep track of all the other similar-but-not-quite-the-same
flags in cgraph.

------- Comment #16 From Andrew Pinski 2008-01-13 13:02 -------
*** Bug 34767 has been marked as a duplicate of this bug. ***

------- Comment #17 From Richard Guenther 2008-01-13 14:04 -------
Honza, can you have a look here?

------- Comment #18 From Andrew Pinski 2008-02-15 21:27 -------
*** Bug 35212 has been marked as a duplicate of this bug. ***

------- Comment #19 From Andrew Pinski 2008-02-15 21:29 -------
I don't know if this is the correct patch but we made this for the PS3
toolchain:
Index: gcc/cgraph.c
===================================================================
--- gcc/cgraph.c        (revision 2280)
+++ gcc/cgraph.c        (working copy)
@@ -476,14 +476,16 @@
       if (!n->next_clone && !n->global.inlined_to
          && (cgraph_global_info_ready
              && (TREE_ASM_WRITTEN (n->decl) || DECL_EXTERNAL (n->decl))))
-       kill_body = true;
+       {
+         DECL_INITIAL (node->decl) = error_mark_node;
+         kill_body = true;
+       }
     }

   if (kill_body && !dump_enabled_p (TDI_tree_all) && flag_unit_at_a_time)
     {
       DECL_SAVED_TREE (node->decl) = NULL;
       DECL_STRUCT_FUNCTION (node->decl) = NULL;
-      DECL_INITIAL (node->decl) = error_mark_node;
     }
   cgraph_n_nodes--;
   /* Do not free the structure itself so the walk over chain can continue.  */

------- Comment #20 From Andrew Pinski 2008-04-01 07:11 -------
I am just going to test this patch and relook at it when the test is finished
but I can see what the issue is.  at -O0 we have unit-at-a-time on.  Though
there is still an issue if we don't have any clones, I think.  I will relook
more into it after the bootstrap/test finishes.

------- Comment #21 From Ian Lance Taylor 2008-04-23 22:33 -------
A patch like this seems like a decent workaround to me.

Honza, any opinions on this approach?

Ian

Index: cgraph.c
===================================================================
--- cgraph.c    (revision 134283)
+++ cgraph.c    (working copy)
@@ -615,6 +615,14 @@ cgraph_remove_node (struct cgraph_node *
        kill_body = true;
     }

+  /* We don't release the body of abstract functions, because they may
+     be needed when emitting debugging information.  In particular
+     this will happen for C++ constructors/destructors.  FIXME:
+     Ideally we would check to see whether there are any reachable
+     functions whose DECL_ABSTRACT_ORIGIN points to this decl.  */
+  if (DECL_ABSTRACT (node->decl))
+    kill_body = false;
+
   if (kill_body && flag_unit_at_a_time)
     cgraph_release_function_body (node);
   node->decl = NULL;

------- Comment #22 From Andrew Pinski 2008-04-23 23:08 -------
(In reply to comment #21)
> A patch like this seems like a decent workaround to me.
> 
> Honza, any opinions on this approach?

This looks good to me also.

------- Comment #23 From Joseph S. Myers 2008-07-04 21:22 -------
Closing 4.1 branch.

------- Comment #24 From Dodji Seketeli 2008-11-06 10:24 -------
So the patch http://gcc.gnu.org/ml/gcc-patches/2008-11/msg00133.html that fixes
this got accepted. So this might end up in trunk soon.

For 4.3 and 4.2 we might want to apply Ian's patch as it is less disruptive.

See http://gcc.gnu.org/ml/gcc-patches/2008-09/msg01981.html .

------- Comment #25 From Dodji Seketeli 2008-11-12 21:59 -------
Subject: Bug 27574

Author: dodji
Date: Wed Nov 12 21:57:44 2008
New Revision: 141807

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141807
Log:
gcc/ChangeLog:
2008-11-12  Dodji Seketeli  <dodji@redhat.com>

        PR debug/27574
        * cgraph.h: New abstract_and_needed member to struct cgraph_node.
        * cgraphunit.c (cgraph_analyze_functions): Flag abstract functions
        - which clones are reachable - as "abstract and needed".
        * cgraph.c (cgraph_release_function_body):  If a node is "abstract and
needed",
        do not release its DECL_INITIAL() content because that will be needed
to emit
        debug info.

gcc/testsuite/ChangeLog:
2008-11-12  Dodji Seketeli  <dodji@redhat.com>

        PR debug/27574
        * g++.dg/debug/dwarf2/local-var-in-contructor.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/local-var-in-contructor.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraph.c
    trunk/gcc/cgraph.h
    trunk/gcc/cgraphunit.c
    trunk/gcc/final.c
    trunk/gcc/testsuite/ChangeLog

------- Comment #26 From Dodji Seketeli 2008-11-13 10:56 -------
Subject: Bug 27574

Author: dodji
Date: Thu Nov 13 10:55:01 2008
New Revision: 141819

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141819
Log:
Fix ChangeLog entry:
        PR debug/27574
        * cgraph.h: New abstract_and_needed member to struct cgraph_node.
        * cgraphunit.c (cgraph_analyze_functions): Flag abstract functions
        - which clones are reachable - as "abstract and needed".
        * cgraph.c (cgraph_release_function_body):  If a node is
        "abstract and needed", do not release its DECL_INITIAL() content
        that will be needed to emit debug info.


Modified:
    trunk/gcc/ChangeLog

------- Comment #27 From Dodji Seketeli 2008-11-14 13:28 -------
Subject: Bug 27574

Author: dodji
Date: Fri Nov 14 13:26:59 2008
New Revision: 141858

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141858
Log:
gcc/ChangeLog:
        PR debug/27574
        * cgraph.h: New abstract_and_needed member to struct cgraph_node.
        * cgraphunit.c (cgraph_analyze_functions): Flag abstract functions
        -which clones are reachable - as "abstract and needed".
        * cgraph.c (cgraph_release_function_body):  If a node is
        "abstract and needed", do not release its DECL_INITIAL() content
        will be needed to emit debug info.

gcc/testsuite/ChangeLog:
        PR debug/27574
        * g++.dg/debug/dwarf2/local-var-in-contructor.C: New test.


Added:
   
branches/gcc-4_3-branch/gcc/testsuite/g++.dg/debug/dwarf2/local-var-in-contructor.C
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/cgraph.c
    branches/gcc-4_3-branch/gcc/cgraph.h
    branches/gcc-4_3-branch/gcc/cgraphunit.c
    branches/gcc-4_3-branch/gcc/final.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

------- Comment #28 From Dodji Seketeli 2008-11-19 00:17 -------
Subject: Bug 27574

Author: dodji
Date: Wed Nov 19 00:15:52 2008
New Revision: 141984

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141984
Log:
gcc/ChangeLog:
2008-11-14  Dodji Seketeli  <dodji@redhat.com>

        PR c++/27574
        * gcc/cgraph.c (cgraph_remove_node): Do not remove the body of
          abstract functions. It might be useful to emit debugging
          information. This is a patch from Ian Lance Taylor.
        * cgraphunit.c (cgraph_optimize): Do not cry when bodies of abstract
          functions are still around. They are useful to output debug info.

gcc/testsuite/ChangeLog
2008-11-14  Dodji Seketeli  <dodji@redhat.com>

        PR c++/27574
        * testsuite/g++.dg/debug/dwarf2/dwarf2.exp: Backport this here from
        gcc-4_3-branch.
        * g++.dg/debug/dwarf2/local-var-in-contructor.C: New testcase.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/debug/dwarf2/
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp
   
branches/gcc-4_2-branch/gcc/testsuite/g++.dg/debug/dwarf2/local-var-in-contructor.C
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/cgraph.c
    branches/gcc-4_2-branch/gcc/cgraphunit.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

------- Comment #29 From Dodji Seketeli 2008-11-19 00:21 -------
Fixed in trunk, 4.3 and 4.2 branch.

------- Comment #30 From Jorn Wolfgang Rennecke 2008-12-09 18:22 -------
I think the testcase pr27574.C should be added to the testsuite before
closing this bug.

------- Comment #31 From Jorn Wolfgang Rennecke 2008-12-09 18:48 -------
Sorry, I only checked for the presence of the original testcase name in
the testsuite, and thus missed the fact that there is a new test called
local-var-in-contructor.C [sic] .

------- Comment #32 From Andrew Pinski 2009-04-29 15:09 -------
*** Bug 39961 has been marked as a duplicate of this bug. ***

First Last Prev Next    No search results available      Search page      Enter new bug