This is an archive of the discontinued LLVM Phabricator instance.

[lldb][NFC] Factor out code from SymbolFileDWARF::ParseVariableDIE
ClosedPublic

Authored by fdeazeve on Jul 5 2023, 8:26 AM.

Details

Summary

This function does a _lot_ of different things:

  1. Parses a DIE,
  2. Builds an ExpressionList
  3. Figures out lifetime of variable
  4. Remaps addresses for debug maps
  5. Handles external variables
  6. Figures out scope of variables

A lot of this functionality is coded in a complex nest of conditions, variables
that are declared and then initialized much later, variables that are updated in
multiple code paths. All of this makes the code really hard to follow.

This commit attempts to improve the state of things by factoring out (3), adding
documentation on how the expression list is built, and by reducing the scope of
variables.

Diff Detail

Event Timeline

fdeazeve created this revision.Jul 5 2023, 8:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2023, 8:26 AM
fdeazeve requested review of this revision.Jul 5 2023, 8:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2023, 8:26 AM
fdeazeve added inline comments.Jul 5 2023, 8:29 AM
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
3272

FWIW all this code was just moved outside the main function.

fdeazeve added a reviewer: Restricted Project.Jul 5 2023, 8:29 AM
bulbazord accepted this revision.Jul 6 2023, 9:15 AM

Makes sense to me. There are some potential improvements we could make to this code (which I'm sure you can already identify), but to keep this change relatively risk-free we should probably stick to just shifting things around. Thanks for doing this!

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
3414–3420

Not related to the review itself, but this makes me wish C++ had "if expressions" from Rust...

This revision is now accepted and ready to land.Jul 6 2023, 9:15 AM

There are some potential improvements we could make to this code

Yup, there's a lot I want to change here, but I am taking it slowly in the interest of making each change easier to verify