------- Additional Comments From bonzini at gcc dot gnu dot org  2005-05-31 
13:11 -------
Ulrich Weigand wrote:

When building with -funit-at-a-time (which is on by default with -O2), *no*
debug info for global variables appears to be emitted at all.

The problem appears to be this piece of code in check_global_declarations:

      /* Do not emit debug information about variables that are in
         static storage, but not defined.  */
      if (TREE_CODE (decl) == VAR_DECL
          && TREE_STATIC (decl)
          && !TREE_ASM_WRITTEN (decl))
        DECL_IGNORED_P (decl) = 1;

which was added by:
http://gcc.gnu.org/ml/gcc-cvs/2004-11/msg01250.html

2004-11-25  Mark Mitchell  <[EMAIL PROTECTED]>

        PR c++/18556
        * toplev.c (check_global_declarations): Set DECL_IGNORED_P on
        unemitted variables with static storage duration.


However, check_global_declarations is called (by the C front-end at least)
*before* the call to cgraph_optimize.  At this time, when -funit-at-a-time
is in effect, *no* variables have been emitted to assembler as far as I
can tell, and thus all global variables get the DECL_IGNORED_P flag.

Interestingly enough, when building with the C++ front-end, the debug
info is properly emitted.  I'm not sure where exactly the difference is ...

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |uweigand at de dot ibm dot
                   |                            |com, mark at codesourcery
                   |                            |dot com
           Severity|normal                      |critical
 GCC target triplet|powerpc-apple-darwin7.9.0   |
           Priority|P2                          |P1
            Summary|[4.1 Regression] stabs debug|[4.0/4.1 Regression] debug
                   |info completely broken?     |info omitted for global
                   |                            |variables
   Target Milestone|---                         |4.0.1
            Version|4.1.0                       |4.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21828

Reply via email to