This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] Early LTO debug


On 09/06/2016 05:17 AM, Richard Biener wrote:
On Fri, 26 Aug 2016, Richard Biener wrote:


The patch below is my current development state of Early LTO debug lumped
into one big patch (no changelog, sorry).  It contains previously posted

  https://gcc.gnu.org/ml/gcc-patches/2015-08/msg01089.html

which extends dwarf2asm.h and adjusts a target hook which means the
patch carries the usual tm.texi burden.

From previous iterations the patch has removed most of the dwarf2out
refactoring to make it easier to review.  It does get away with
dwarf2out_abstract_function (we have that by means of early debug
for all functions) and it moves quite a bunch of stuff from late
dwarf processing to early.  For actual submission I will try to
factor out parts of the latter at least.


So the main idea is to emit the DWARF tree we have at
dwarf2out_early_finish into "Early LTO DWARF" sections (using
.gnu.debuglto_ section prefixes, not .gnu.lto_ because GNU as
spits out warnings about bogus section flags used for
.gnu.lto_.debug_str).  If we produce fat LTO objects the full
DWARF info will be emit alongside regular assembly again at
dwarf2out_finish time.  When streaming out LTO bytecode we
record for each interesting tree (decls at the moment) a reference
to the "early DIE" generated via a $symbol + offset pair.  There
is a single symbol emitted for each early debug-info section.

At WPA time those references are simply carried through.

At LTRANS time those references are read back in and dwarf2out
is told about the existence of the early DIE for tree X and
it creates a shadow DIE for that, simply refering to the early
DIE via a symbolic reference.  At dwarf2out_finish time we then
annotate the early DIE by means of the shadow DIE which has
a DW_AT_abstract_origin refering to the early DIE.  This mostly
adds location information to DIEs.


On the driver side things get a little complicated as we need to
funnel through the "Early LTO DWARF" sections to the final link,
presenting them as regular debug info sections.  To make a smooth
transition possible I choose to write a Early LTO DWARF copier
in the simple-object framework which basically takes all the
early LTO DWARF sections and writes them into a new object file,
renaming them on-the-fly.  I implemented this for ELF only sofar
and the API needs to be changed to reflect the fact that this is
really only suited for use as LTO early DWARF section copier
(tried to make it a little more generic but that didn't work
out very well).  So for each LTO input file you get a LTO early
debug object which are then partially linked to a single LTO
early debug object (we could simply omit that step, it doesn't
save very much due to the fact that GNU ld with partial linking
doesn't optimize mergeable string sections...).  This object
is then fed back as LTO link output to the linker.

Ideally the linker plugin API would be extended to allow claiming
only a subset of sections and allow telling the linker to rename
sections that we didn't claim.  That would avoid some I/O and
disk-space usage.


The main motivation for this is to increase the quality of
debug information you get when using LTO and the most promising
part of testing is
[ ... ]

[ ... ]


Feedback (and actual experience debugging LTO programs with this
patch) appreciated.
No time to do anything with this directly, but I will say that the work on this is greatly appreciated. Improving the LTO debugging situation is something I know many would like to see happen.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]