@@ -30,70 +30,27 @@ using namespace lldb;
3030using namespace lldb_private ;
3131
3232UnwindTable::UnwindTable (Module &module )
33- : m_module(module ), m_unwinds(), m_initialized (false ), m_mutex( ),
34- m_object_file_unwind_up (), m_eh_frame_up (), m_compact_unwind_up (),
35- m_arm_unwind_up() {}
33+ : m_module(module ), m_unwinds(), m_scanned_all_unwind_sources (false ),
34+ m_mutex (), m_object_file_unwind_up (), m_eh_frame_up (),
35+ m_compact_unwind_up(), m_arm_unwind_up() {}
3636
3737// We can't do some of this initialization when the ObjectFile is running its
3838// ctor; delay doing it until needed for something.
39-
4039void UnwindTable::Initialize () {
41- if (m_initialized )
40+ if (m_scanned_all_unwind_sources )
4241 return ;
4342
4443 std::lock_guard<std::mutex> guard (m_mutex);
4544
46- if (m_initialized) // check again once we've acquired the lock
47- return ;
48- m_initialized = true ;
49- ObjectFile *object_file = m_module.GetObjectFile ();
50- if (!object_file)
45+ if (m_scanned_all_unwind_sources) // check again once we've acquired the lock
5146 return ;
5247
53- m_object_file_unwind_up = object_file->CreateCallFrameInfo ();
54-
55- SectionList *sl = m_module.GetSectionList ();
56- if (!sl)
57- return ;
58-
59- SectionSP sect = sl->FindSectionByType (eSectionTypeEHFrame, true );
60- if (sect.get ()) {
61- m_eh_frame_up = std::make_unique<DWARFCallFrameInfo>(
62- *object_file, sect, DWARFCallFrameInfo::EH);
63- }
64-
65- sect = sl->FindSectionByType (eSectionTypeDWARFDebugFrame, true );
66- if (sect) {
67- m_debug_frame_up = std::make_unique<DWARFCallFrameInfo>(
68- *object_file, sect, DWARFCallFrameInfo::DWARF);
69- }
70-
71- sect = sl->FindSectionByType (eSectionTypeCompactUnwind, true );
72- if (sect) {
73- m_compact_unwind_up =
74- std::make_unique<CompactUnwindInfo>(*object_file, sect);
75- }
76-
77- sect = sl->FindSectionByType (eSectionTypeARMexidx, true );
78- if (sect) {
79- SectionSP sect_extab = sl->FindSectionByType (eSectionTypeARMextab, true );
80- if (sect_extab.get ()) {
81- m_arm_unwind_up =
82- std::make_unique<ArmUnwindInfo>(*object_file, sect, sect_extab);
83- }
84- }
85- }
86-
87- void UnwindTable::Update () {
88- if (!m_initialized)
89- return Initialize ();
90-
91- std::lock_guard<std::mutex> guard (m_mutex);
92-
9348 ObjectFile *object_file = m_module.GetObjectFile ();
9449 if (!object_file)
9550 return ;
9651
52+ m_scanned_all_unwind_sources = true ;
53+
9754 if (!m_object_file_unwind_up)
9855 m_object_file_unwind_up = object_file->CreateCallFrameInfo ();
9956
@@ -102,22 +59,19 @@ void UnwindTable::Update() {
10259 return ;
10360
10461 SectionSP sect = sl->FindSectionByType (eSectionTypeEHFrame, true );
105- if (!m_eh_frame_up && sect) {
62+ if (!m_eh_frame_up && sect)
10663 m_eh_frame_up = std::make_unique<DWARFCallFrameInfo>(
10764 *object_file, sect, DWARFCallFrameInfo::EH);
108- }
10965
11066 sect = sl->FindSectionByType (eSectionTypeDWARFDebugFrame, true );
111- if (!m_debug_frame_up && sect) {
67+ if (!m_debug_frame_up && sect)
11268 m_debug_frame_up = std::make_unique<DWARFCallFrameInfo>(
11369 *object_file, sect, DWARFCallFrameInfo::DWARF);
114- }
11570
11671 sect = sl->FindSectionByType (eSectionTypeCompactUnwind, true );
117- if (!m_compact_unwind_up && sect) {
72+ if (!m_compact_unwind_up && sect)
11873 m_compact_unwind_up =
11974 std::make_unique<CompactUnwindInfo>(*object_file, sect);
120- }
12175
12276 sect = sl->FindSectionByType (eSectionTypeARMexidx, true );
12377 if (!m_arm_unwind_up && sect) {
@@ -129,6 +83,11 @@ void UnwindTable::Update() {
12983 }
13084}
13185
86+ void UnwindTable::ModuleWasUpdated () {
87+ std::lock_guard<std::mutex> guard (m_mutex);
88+ m_scanned_all_unwind_sources = false ;
89+ }
90+
13291UnwindTable::~UnwindTable () = default ;
13392
13493std::optional<AddressRange>
0 commit comments