Page MenuHomePhabricator

WIP: DebugInfo: Use base address and offset pairs in debug_loc.dwo to reduce required relocations
Needs ReviewPublic

Authored by dblaikie on Aug 3 2017, 7:38 PM.

Details

Summary

This isn't quite finished, but a prototype that reduces the number of
debug_addr relocs in a large internal optimized binary by 40% substantially
reducing total object file size, which would be nice.

  1. Needs testing (updating existing test cases, maybe adding more - could check

about the number of relocations, etc)

  1. Needs work either way once determined if a debug location address range

could start at the very beginning of a function (then a range might be shorter
using startx_length than base_address+offset_pair)

  1. Maybe it's simpler to have two separate implementations rather than

generalizing the debug_ranges handling (especially if there's currently no
debug_loc generated for global variables (or no other way a variable could have
live ranges in more than one section))

  1. Comments
  1. Should DwarfDebug use MCStreamer directly for the ULEB label difference

(that's what it's doing in this version) or should it use an
AsmPrinter/MCStreamer API to match the non-ULEB label difference (I've
prototyped the MCStreamer/AsmPrinter APIs in this change - though they're not
wired up to DwarfDebug - just to show the rough scale of the code, mostly it's
just copy/pasted from the non-ULEB label difference codepath)

Oh, and Paul: This'll probably come in handy/can be reused for the rnglist
support (& generalized further for all the DWARF5 forms for use in loclist -
though I imagine we'll still only need to generate a subset of the forms -
maybe still only these 2 or 3 depending on what's being proritized (object
size, executable size, number of relocations)

Event Timeline

dblaikie created this revision.Aug 3 2017, 7:38 PM

(oh, bother - looks like GDB can't parse this, even if it were in debug_loclists.dwo (but it could handle it in debug_loclists) :/ - so this might be a bit before its time & have to wait... still wouldn't mind figuring out the right design)

tberghammer edited edge metadata.Aug 5 2017, 8:34 AM

I checked LLDB and it doesn't have support for base address entries neither in .debug_loc nor in .debug_loc.dwo sections and it doesn't support reading .debug_loclists or .debug_loclists.dwo entries either. I will try to add support for them but it will require some refactoring so it will take some time.

Well... guess I don't learn from the past sometimes.

I reimplemented this a slightly different way (patch attached) only to
learn, again, that GDB doesn't support this... which makes me sad.

Sent email to the gdb development list because weirdly the DWARFv5 support
in GDB currently seems to /only/ support the base+offset_pair form -
strangely mutually exclusive. Would be great to have more full support in
both the DWARF 4/pre-standard Fission, and the v5 standardized loclists.

Added a better comment in r345326 so hopefully I don't try to fix this
again only to learn the same thing...

  • Dave