This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Symtab::SectionFileAddressesChanged should clear the file address map instead of name map
ClosedPublic

Authored by bulbazord on Jun 9 2023, 12:40 PM.

Details

Summary

Currently, SectionFileAddressesChanged clears out the name_to_index
map and sets m_file_addr_to_index_compute to false. This is strange,
as these two fields are used for different purposes. What we should be
doing is clearing the file address to index mapping.

There are 2 bugs here:

  1. If we call SectionFileAddressesChanged after the name indexes have been computed, we end up with an empty name to index map, so lookups will fail. This doesn't happen today because we don't initialize the name indexes before calling this, but this is a refactor away from failing in this way.
  2. Because we don't clear m_file_addr_to_index but still set it's computed flag to false, it ends up with twice the amount of information. One entry will be correct (since it was recalculated), one entry will be outdated.

rdar://110192434

Diff Detail

Event Timeline

bulbazord created this revision.Jun 9 2023, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 12:40 PM
bulbazord requested review of this revision.Jun 9 2023, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 12:40 PM
jingham accepted this revision.Jun 13 2023, 10:33 AM

That does look like a thinko. Nothing about a file's section addresses changing will change the name to symbol map as that isn't dependent on load addresses.

This revision is now accepted and ready to land.Jun 13 2023, 10:33 AM