Skip to content

Commit 5e0ae86

Browse files
authored
Merge pull request #8479 from jasonmolenda/cp/dont-reset-unwindtable-when-adding-symbol-file-6.0
[lldb] Don't clear a Module's UnwindTable when adding a SymbolFile (llvm#86603)
2 parents c4c5ccc + 3fea3a1 commit 5e0ae86

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

lldb/include/lldb/Symbol/UnwindTable.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ class UnwindTable {
5757

5858
ArchSpec GetArchitecture();
5959

60+
/// Called after a SymbolFile has been added to a Module to add any new
61+
/// unwind sections that may now be available.
62+
void Update();
63+
6064
private:
6165
void Dump(Stream &s);
6266

lldb/source/Core/Module.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,8 @@ SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) {
10461046
m_symfile_up.reset(
10471047
SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
10481048
m_did_load_symfile = true;
1049+
if (m_unwind_table)
1050+
m_unwind_table->Update();
10491051
}
10501052
}
10511053
}
@@ -1371,9 +1373,9 @@ void Module::SectionFileAddressesChanged() {
13711373

13721374
UnwindTable &Module::GetUnwindTable() {
13731375
if (!m_unwind_table) {
1374-
m_unwind_table.emplace(*this);
13751376
if (!m_symfile_spec)
13761377
SymbolLocator::DownloadSymbolFileAsync(GetUUID());
1378+
m_unwind_table.emplace(*this);
13771379
}
13781380
return *m_unwind_table;
13791381
}
@@ -1491,15 +1493,10 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
14911493
// one
14921494
obj_file->ClearSymtab();
14931495

1494-
// Clear the unwind table too, as that may also be affected by the
1495-
// symbol file information.
1496-
m_unwind_table.reset();
1497-
14981496
// The symbol file might be a directory bundle ("/tmp/a.out.dSYM")
14991497
// instead of a full path to the symbol file within the bundle
15001498
// ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to
15011499
// check this
1502-
15031500
if (FileSystem::Instance().IsDirectory(file)) {
15041501
std::string new_path(file.GetPath());
15051502
std::string old_path(obj_file->GetFileSpec().GetPath());

lldb/source/Symbol/UnwindTable.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,51 @@ void UnwindTable::Initialize() {
8484
}
8585
}
8686

87+
void UnwindTable::Update() {
88+
if (!m_initialized)
89+
return Initialize();
90+
91+
std::lock_guard<std::mutex> guard(m_mutex);
92+
93+
ObjectFile *object_file = m_module.GetObjectFile();
94+
if (!object_file)
95+
return;
96+
97+
if (!m_object_file_unwind_up)
98+
m_object_file_unwind_up = object_file->CreateCallFrameInfo();
99+
100+
SectionList *sl = m_module.GetSectionList();
101+
if (!sl)
102+
return;
103+
104+
SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true);
105+
if (!m_eh_frame_up && sect) {
106+
m_eh_frame_up = std::make_unique<DWARFCallFrameInfo>(
107+
*object_file, sect, DWARFCallFrameInfo::EH);
108+
}
109+
110+
sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true);
111+
if (!m_debug_frame_up && sect) {
112+
m_debug_frame_up = std::make_unique<DWARFCallFrameInfo>(
113+
*object_file, sect, DWARFCallFrameInfo::DWARF);
114+
}
115+
116+
sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
117+
if (!m_compact_unwind_up && sect) {
118+
m_compact_unwind_up =
119+
std::make_unique<CompactUnwindInfo>(*object_file, sect);
120+
}
121+
122+
sect = sl->FindSectionByType(eSectionTypeARMexidx, true);
123+
if (!m_arm_unwind_up && sect) {
124+
SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true);
125+
if (sect_extab.get()) {
126+
m_arm_unwind_up =
127+
std::make_unique<ArmUnwindInfo>(*object_file, sect, sect_extab);
128+
}
129+
}
130+
}
131+
87132
UnwindTable::~UnwindTable() = default;
88133

89134
std::optional<AddressRange>

0 commit comments

Comments
 (0)