This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Centralize user_id <-> DWARFDIE conversions
ClosedPublic

Authored by labath on May 7 2019, 12:31 PM.

Details

Summary

The logic for translating a user_id into a DWARFDIE was replicated in
several places. This removes that redundancy and settles on a single
implementation in SymbolFileDWARF.

The reason for choosing that instead of DIERef was that we were
always immediately converting the returned DIERef into a DWARFDIE
anyway, which meant that one had to specify the SymbolFileDWARF argument
twice (once to get the DIERef, and once to get the actual DIE). Also,
passing a higher-level object (SymbolFileDWARF) into a lower-level one
(DIERef) seemed like a less intuitive arrangement than doing things the
other way around.

Event Timeline

labath created this revision.May 7 2019, 12:31 PM
clayborg added inline comments.May 7 2019, 1:53 PM
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
137

Maybe just overload?:

DWARFDIE GetDIE(lldb::user_id_t uid);
138–139

Maybe just overload these?:

lldb::user_id_t GetUID(DWARFBaseDIE die);
lldb::user_id_t GetUID(DIERef ref);
JDevlieghere accepted this revision.May 7 2019, 6:31 PM

Greg's suggestion for an overload seems reasonable. Otherwise LGTM.

This revision is now accepted and ready to land.May 7 2019, 6:31 PM
labath marked 3 inline comments as done.May 8 2019, 4:40 AM
labath added inline comments.
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
138–139

Sounds good.

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 8 2019, 4:41 AM