This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Reimplement/simplify DWARFUnit::GetID
ClosedPublic

Authored by labath on May 3 2019, 2:04 AM.

Details

Summary

The implementation of GetID used a relatively complicated algorithm,
which returned some kind of an offset of the unit in some file
(depending on the debug info flavour). The only thing this ID was used
for was to enable subseqent retrieval of the unit from the SymbolFile.

This can be made simpler if we just make the "ID" of the unit an index
into the list of the units belonging to the symbol file. We already
support indexed access to the units, so each unit already has a well
"index" -- this just makes it accessible from within the unit.

To make the distincion between "id" and "offset" clearer (and help catch
any misuses), I also rename DWARFDebugInfo::GetCompileUnit (which
accesses by offset) into DWARFDebugInfo::GetCompileUnitAtOffset.

On its own, this only brings a minor simplification, but it enables
further simplifications in the DIERef class (coming in a follow-up
patch).

Event Timeline

labath created this revision.May 3 2019, 2:04 AM
JDevlieghere accepted this revision.May 3 2019, 9:04 AM

LGTM with one inline comment.

source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
43

This should probably take a lldb::user_id_t then?

This revision is now accepted and ready to land.May 3 2019, 9:04 AM
labath marked 2 inline comments as done.May 6 2019, 12:35 AM
labath added inline comments.
source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
43

Yep, I guess it should.

This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2019, 12:43 AM
Herald added a subscriber: abidh. · View Herald Transcript