[debug-early] C++: emit early debug info for all globals, not just statics

Jason Merrill jason@redhat.com
Fri Oct 3 14:12:00 GMT 2014


On 10/02/2014 02:21 PM, Aldy Hernandez wrote:
> Actually, I think we/I need to rethink this whole globals thing.
> Currently we're early dumping global *_DECLs, and hoping dwarf2out
> recursion will also pick up types and any derivatives from the *_DECLs,
> but taking a closer look I've noticed a lot of things are not being
> dumped early.
>
> For instance:
>
>
>      foo()
>      {
>        typedef int ITYPE;
>        ITYPE var = 5;
>      }
>
> For the above code, var's DIE gets outputted _after_ the compilation
> proper has been run here:
>
>    if (! declaration && outer_scope && TREE_CODE (outer_scope) !=
> ERROR_MARK
>        && (!DECL_STRUCT_FUNCTION (decl)
>        || DECL_STRUCT_FUNCTION (decl)->gimple_df))
>      ...
>      ...
>      decls_for_scope (outer_scope, subr_die, 0);
>
> I think we should be outputting DIEs for locals at the end of parsing,
> so my patch going through level->names IMO is wrong.  We should be
> dumping all *_DECLs created by the FE, not just globally scoped ones.

The way to dump locals is by recursion.  If the current process isn't 
hitting these, that's a bug, but I don't think it means we need to 
fundamentally change the approach.  Why aren't we hitting that 
decls_for_scope when we early dump foo?

> Another example currently not being dumped early is...
>
>      function()
>      {
>        class Local {
>        public:
>          void loc_foo (void) { }
>        };
>
>        Local l;
>        l.loc_foo ();
>      }
>
> ...since loc_foo() is not in level->names.

Again, dumping function() should imply dumping Local and its members.

Jason



More information about the Gcc-patches mailing list