[llvm-dev] [DWARF] De-segregating type units and compile units

via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 24 10:40:18 PDT 2018


Hello DWARF fans,

I've just posted a set of four refactoring patches for DebugInfo/DWARF,
which move in the direction of handling DWARF v4 or v5 type units and
compile units more coherently.

In DWARF v4, type units and compile units are strictly segregated into
the .debug_types and .debug_info sections, respectively.  This division
was pretty ingrained into how DebugInfo/DWARF handled the units.

In DWARF v5, type units and compile units are all in the .debug_info
section, and the .debug_types section is obsolete.  So, we need to have
a container than can handle both kinds of units in a straightforward way.

The refactoring replaces a pair of collections templated on the unit type
with a single collection whose elements are base-class pointers; thus it
can contain elements that are a mix of unit kinds.  Everything that really
mattered was either already virtual or was straightforward to convert to
generic handling.  I think I needed only one type-based conditional, on
top of what already existed.  The code doesn't *quite* support DWARF v5
type units in the .debug_info section, but the new starting point should
make that straightforward.

In a mixed v4/v5 executable, we can pretend the .debug_types sections
are all really .debug_info sections, and tack them onto the end of the
vector of units that already handles a mix of compile and type units.
This is also how the LLDB DWARF parser handles this case, so it's at
least consistent in principle (even if the actual code differs).

The existing distinction between "normal" and split (DWO) units remains;
that has to do with what information exists in which object files, and
is not fundamentally changing in DWARF v5.

Patch 1: De-templatize DWARFUnitSection
         https://reviews.llvm.org/D49741
Patch 2: The TU collection doesn't need to be a deque
         https://reviews.llvm.org/D49742
Patch 3: Rename DWARFUnitSection to DWARFUnitVector
         https://reviews.llvm.org/D49743
Patch 4: Unify handling of type and compile units
         https://reviews.llvm.org/D49744

Thanks,
--paulr



More information about the llvm-dev mailing list