[Bug debug/86964] Too many debug symbols included, especially for extern globals

2019-01-15 Thread Johan.karlsson at enea dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86964

Johan.karlsson at enea dot com changed:

   What|Removed |Added

 CC||Johan.karlsson at enea dot com

--- Comment #5 from Johan.karlsson at enea dot com ---
I'm also affected by this "lack of feature" I looked into dwarf2out.c to see
what I could do about it. Unfortunately I quickly noticed that I'm definitely
going to break stuff if I try to tweak the code.

So I'm hoping that some GCC developer can take the time implement
-feliminate-unused-debug-symbols for DWARF.

Right now the ELF file gets so large the my debugger crashes. So I'm stuck
using GCC 4 or 5.

[Bug debug/86964] Too many debug symbols included, especially for extern globals

2019-02-07 Thread Johan.karlsson at enea dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86964

--- Comment #6 from Johan.karlsson at enea dot com ---
Created attachment 45636
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45636&action=edit
Patch to enable skip unused extern variables.

I'm attaching a patch that I've been working on. It loops over the variable
pool that contains the used global variables. It grabs the declaration and
lookup the DIE of the variable and mark it as used.
I've also tweaked the function that loops over all dies so that instead of
marking every DW_TAG_variable it only marks the ones that are not extern.

With this patch we where able to get similar debug information size to GCC
4.9.2. 

Right now the functionality is only enabled by adding
-feliminate-unused-debug-symbols, it could probably always be enable since I
don't think any debug information is lost. -fno-eliminate-unused-debug-types
should not be set, because if it is the the functionality is disabled. A bit
strange but using that in the first place will generate a bunch of extra debug
information anyway.