Move UnwindTable from ObjectFile to Module
Summary:
This is a preparatory step to enable adding extra unwind strategies by
symbol file plugins. This has been discussed on the lldb-dev mailing
list: <http://lists.llvm.org/pipermail/lldb-dev/2019-February/014703.html>.
Reviewers: jasonmolenda, clayborg, espindola
Subscribers: lemo, emaste, lldb-commits, arichardson
Differential Revision: https://reviews.llvm.org/D58129
llvm-svn: 354033
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp
index 5c7c1b7..211b96f 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -263,8 +263,7 @@
: ModuleChild(module_sp),
m_file(), // This file could be different from the original module's file
m_type(eTypeInvalid), m_strata(eStrataInvalid),
- m_file_offset(file_offset), m_length(length), m_data(),
- m_unwind_table(*this), m_process_wp(),
+ m_file_offset(file_offset), m_length(length), m_data(), m_process_wp(),
m_memory_addr(LLDB_INVALID_ADDRESS), m_sections_up(), m_symtab_up(),
m_synthetic_symbol_idx(0) {
if (file_spec_ptr)
@@ -286,9 +285,8 @@
DataBufferSP &header_data_sp)
: ModuleChild(module_sp), m_file(), m_type(eTypeInvalid),
m_strata(eStrataInvalid), m_file_offset(0), m_length(0), m_data(),
- m_unwind_table(*this), m_process_wp(process_sp),
- m_memory_addr(header_addr), m_sections_up(), m_symtab_up(),
- m_synthetic_symbol_idx(0) {
+ m_process_wp(process_sp), m_memory_addr(header_addr), m_sections_up(),
+ m_symtab_up(), m_synthetic_symbol_idx(0) {
if (header_data_sp)
m_data.SetData(header_data_sp, 0, header_data_sp->GetByteSize());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
diff --git a/lldb/source/Symbol/UnwindTable.cpp b/lldb/source/Symbol/UnwindTable.cpp
index cacbdb1..dde31fb 100644
--- a/lldb/source/Symbol/UnwindTable.cpp
+++ b/lldb/source/Symbol/UnwindTable.cpp
@@ -26,8 +26,8 @@
using namespace lldb;
using namespace lldb_private;
-UnwindTable::UnwindTable(ObjectFile &objfile)
- : m_object_file(objfile), m_unwinds(), m_initialized(false), m_mutex(),
+UnwindTable::UnwindTable(Module &module)
+ : m_module(module), m_unwinds(), m_initialized(false), m_mutex(),
m_eh_frame_up(), m_compact_unwind_up(), m_arm_unwind_up() {}
// We can't do some of this initialization when the ObjectFile is running its
@@ -42,33 +42,36 @@
if (m_initialized) // check again once we've acquired the lock
return;
m_initialized = true;
+ ObjectFile *object_file = m_module.GetObjectFile();
+ if (!object_file)
+ return;
- SectionList *sl = m_object_file.GetSectionList();
+ SectionList *sl = object_file->GetSectionList();
if (!sl)
return;
SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true);
if (sect.get()) {
m_eh_frame_up.reset(
- new DWARFCallFrameInfo(m_object_file, sect, DWARFCallFrameInfo::EH));
+ new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::EH));
}
sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true);
if (sect) {
m_debug_frame_up.reset(
- new DWARFCallFrameInfo(m_object_file, sect, DWARFCallFrameInfo::DWARF));
+ new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::DWARF));
}
sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
if (sect) {
- m_compact_unwind_up.reset(new CompactUnwindInfo(m_object_file, sect));
+ m_compact_unwind_up.reset(new CompactUnwindInfo(*object_file, sect));
}
sect = sl->FindSectionByType(eSectionTypeARMexidx, true);
if (sect) {
SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true);
if (sect_extab.get()) {
- m_arm_unwind_up.reset(new ArmUnwindInfo(m_object_file, sect, sect_extab));
+ m_arm_unwind_up.reset(new ArmUnwindInfo(*object_file, sect, sect_extab));
}
}
}
@@ -148,8 +151,7 @@
void UnwindTable::Dump(Stream &s) {
std::lock_guard<std::mutex> guard(m_mutex);
- s.Printf("UnwindTable for '%s':\n",
- m_object_file.GetFileSpec().GetPath().c_str());
+ s.Format("UnwindTable for '{0}':\n", m_module.GetFileSpec());
const_iterator begin = m_unwinds.begin();
const_iterator end = m_unwinds.end();
for (const_iterator pos = begin; pos != end; ++pos) {
@@ -179,10 +181,10 @@
return m_arm_unwind_up.get();
}
-ArchSpec UnwindTable::GetArchitecture() {
- return m_object_file.GetArchitecture();
-}
+ArchSpec UnwindTable::GetArchitecture() { return m_module.GetArchitecture(); }
bool UnwindTable::GetAllowAssemblyEmulationUnwindPlans() {
- return m_object_file.AllowAssemblyEmulationUnwindPlans();
+ if (ObjectFile *object_file = m_module.GetObjectFile())
+ return object_file->AllowAssemblyEmulationUnwindPlans();
+ return false;
}