[PATCHES, PING*5] Enhance standard DWARF for Ada

Pierre-Marie de Rodat derodat@adacore.com
Thu Feb 25 15:54:00 GMT 2016

On 02/25/2016 10:48 AM, Jakub Jelinek wrote:
> The first one just fixes what I mainly care about, the committed patch
> assumed that DW_TAG_dwarf_procedure is always only created for the Ada
> variable sized structures or whatever it was meant for, which is not the
> case, and thus if we emit DW_TAG_dwarf_procedure for some other reason,
> it would be pruned as unused even when it is actually used (and result in
> a DIE reference to the compilation unit header, which is always invalid).

This first patch looks good to me, as a good enough and simple fix.

> But, looking at the points where you use DW_TAG_dwarf_procedure for the Ada
> things, I can't see how it can actually work at all, though there is no
> testsuite coverage, so it is hard to find out for real.
> The thing is, current code sets die_perennial_p on type DIEs and their
> parents, but nothing else.  In particular, type DIEs are identified by
> being returned from lookup_type_die, thus earlier passed to
> equate_type_number_to_die.  I don't see that this would ever be the case
> of DW_TAG_dwarf_procedure though, I see the return of
> function_to_dwarf_procedure being used as dw_loc_oprnd1.v.val_die_ref.die
> of a DW_OP_call4 that is somewhere used in some location description that is
> perhaps used somewhere in some type DIE computation.

I introduced a DW_OP_call* traversal for this:

   * prune_unused_types_mark traverses attributes using

   * …_walk_attribs walks location descriptions and location lists using

   * …_walk_loc_descr marks DWARF procedures referenced by DW_OP_call*

So all DWARF procedures referenced this way are not supposed to be 
pruned (I checked: no problem for the Ada types I tested). As you 
noticed, I did not realize that there were other DWARF procedure 
producers, hence the assumption that this was enought to mark all DWARF 

> So IMHO the second patch
> makes more sense, and if you (for GCC 7?) want to prune really unused
> DW_TAG_dwarf_procedure, you need to add code that will really walk all of
> the debuginfo, rather than just type DIEs themselves, and look if location
> descriptions (in .debug_info or .debug_loc) reference those
> DW_TAG_dwarf_procedure and mark the DW_TAG_dwarf_procedure.

I just had a look: the prune_unused_type_mark pass already reaches the 
DW_OP_GNU_implicit_pointer operation, it’s just that 
prune_unused_types_walk_loc_descr does not know about this kind of 
operation. I think the attached patch is a more general fix for that. 
What do you think?

(bootstrapped and regtested on x86_64-linux)

Pierre-Marie de Rodat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-DWARF-fix-debug-info-for-implicit-pointers-to-string.patch
Type: text/x-diff
Size: 2396 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160225/70f0ef20/attachment.bin>

More information about the Gcc-patches mailing list