This is an archive of the discontinued LLVM Phabricator instance.

DWARF: Add ability to reference debug info coming from multiple sections
ClosedPublic

Authored by labath on May 14 2019, 8:41 AM.

Details

Summary

This patch adds the ability to precisely address debug info in
situations when a single file can have more than one debug-info-bearing
sections (as is the case with type units in DWARF v4).

The changes here can be classified into roughly three categories:

  • the code which addresses a debug info by offset gets an additional argument, which specifies the section one should look into.
  • the DIERef class also gets an additional member variable specifying the section. This way, code dealing with DIERefs can know which section is the object referring to.
  • the user_id_t encoding steals one bit from the dwarf_id field to store the section. This means the total number of separate object files (apple .o, or normal .dwo) is limited to 2 billion, but that is fine as it's not possible to hit that number without switching to DWARF64 anyway.

This patch is functionally equivalent to (and inspired by) the two
patches (D61503 and D61504) by Jan Kratochvil, but there are differences
in the implementation:

  • it uses an enum instead of a bool flag to differentiate the sections
  • it increases the size of DIERef struct instead of reducing the amount of addressable debug info
  • it sets up DWARFDebugInfo to store the units in a single vector instead of two. This sets us up for the future in which type units can also live in the debug_info section, and I believe it's cleaner because there's no need for unit index remapping

There are no tests with this patch as this is essentially NFC until
we start parsing type units from the debug_types section.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.May 14 2019, 8:41 AM

See inline comments. Nice patch overall though, real close.

source/Plugins/SymbolFile/DWARF/DIERef.cpp
18 ↗(On Diff #199462)

We should maybe rename DWARFFormValue::GetCompileUnit() to DWARFFormValue::GetUnit()? Also we might use "unit" instead of "dwarf_cu" here?

source/Plugins/SymbolFile/DWARF/DIERef.h
19 ↗(On Diff #199462)

Use enum class?

enum class Section : uint8_t { DebugInfo, DebugTypes };
source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
141 ↗(On Diff #199462)

Does the "GetUnitAtIndex" call need to take "section" to get the right unit?

162 ↗(On Diff #199462)

Does the "GetUnitAtIndex" call need to take "section" to get the right unit?

source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
51–52 ↗(On Diff #199462)

Should we use a DIERef here instead of these two members?

61 ↗(On Diff #199462)

just return the DIERef member variable if we switch according to above inline comment

labath marked 10 inline comments as done.May 15 2019, 1:25 AM
labath added inline comments.
source/Plugins/SymbolFile/DWARF/DIERef.cpp
18 ↗(On Diff #199462)

Done in r360754.

source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
141 ↗(On Diff #199462)

No, the idea is that the unit index will still uniquely determine the DWARFUnit, regardless of the section it is in (so the sections will still be kind of concatenated, but only at the index level). This makes it easy to convert back and forth between DWARFUnits and lldb_private::CompileUnits.

162 ↗(On Diff #199462)

Same comment as above.

source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
51–52 ↗(On Diff #199462)

Sounds like a good idea. I'll update the patch accordingly.

61 ↗(On Diff #199462)

Done. I'm not sure the operator makes that much sense now as one can just access the contained DIERef directly. I've kept it for now to avoid needing to update all callsites, but I can also delete it if you prefer.

labath updated this revision to Diff 199562.May 15 2019, 1:26 AM
labath marked 4 inline comments as done.
  • use enum class for the section type
  • put DIERef as a member of HashedNameToDie::DIEInfo
clayborg accepted this revision.May 15 2019, 9:04 AM
This revision is now accepted and ready to land.May 15 2019, 9:04 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2019, 4:05 AM