Skip to content

[lldb] Don't clear a Module's UnwindTable when adding a SymbolFile (#86603) #8479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lldb/include/lldb/Symbol/UnwindTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class UnwindTable {

ArchSpec GetArchitecture();

/// Called after a SymbolFile has been added to a Module to add any new
/// unwind sections that may now be available.
void Update();

private:
void Dump(Stream &s);

Expand Down
9 changes: 3 additions & 6 deletions lldb/source/Core/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,8 @@ SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) {
m_symfile_up.reset(
SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
m_did_load_symfile = true;
if (m_unwind_table)
m_unwind_table->Update();
}
}
}
Expand Down Expand Up @@ -1371,9 +1373,9 @@ void Module::SectionFileAddressesChanged() {

UnwindTable &Module::GetUnwindTable() {
if (!m_unwind_table) {
m_unwind_table.emplace(*this);
if (!m_symfile_spec)
SymbolLocator::DownloadSymbolFileAsync(GetUUID());
m_unwind_table.emplace(*this);
}
return *m_unwind_table;
}
Expand Down Expand Up @@ -1491,15 +1493,10 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
// one
obj_file->ClearSymtab();

// Clear the unwind table too, as that may also be affected by the
// symbol file information.
m_unwind_table.reset();

// The symbol file might be a directory bundle ("/tmp/a.out.dSYM")
// instead of a full path to the symbol file within the bundle
// ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to
// check this

if (FileSystem::Instance().IsDirectory(file)) {
std::string new_path(file.GetPath());
std::string old_path(obj_file->GetFileSpec().GetPath());
Expand Down
45 changes: 45 additions & 0 deletions lldb/source/Symbol/UnwindTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,51 @@ void UnwindTable::Initialize() {
}
}

void UnwindTable::Update() {
if (!m_initialized)
return Initialize();

std::lock_guard<std::mutex> guard(m_mutex);

ObjectFile *object_file = m_module.GetObjectFile();
if (!object_file)
return;

if (!m_object_file_unwind_up)
m_object_file_unwind_up = object_file->CreateCallFrameInfo();

SectionList *sl = m_module.GetSectionList();
if (!sl)
return;

SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true);
if (!m_eh_frame_up && sect) {
m_eh_frame_up = std::make_unique<DWARFCallFrameInfo>(
*object_file, sect, DWARFCallFrameInfo::EH);
}

sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true);
if (!m_debug_frame_up && sect) {
m_debug_frame_up = std::make_unique<DWARFCallFrameInfo>(
*object_file, sect, DWARFCallFrameInfo::DWARF);
}

sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
if (!m_compact_unwind_up && sect) {
m_compact_unwind_up =
std::make_unique<CompactUnwindInfo>(*object_file, sect);
}

sect = sl->FindSectionByType(eSectionTypeARMexidx, true);
if (!m_arm_unwind_up && sect) {
SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true);
if (sect_extab.get()) {
m_arm_unwind_up =
std::make_unique<ArmUnwindInfo>(*object_file, sect, sect_extab);
}
}
}

UnwindTable::~UnwindTable() = default;

std::optional<AddressRange>
Expand Down