Index: include/lldb/Core/Module.h =================================================================== --- include/lldb/Core/Module.h +++ include/lldb/Core/Module.h @@ -693,6 +693,21 @@ //------------------------------------------------------------------ virtual void SectionFileAddressesChanged(); + //------------------------------------------------------------------ + /// Returns a reference to the UnwindTable for this Module + /// + /// The UnwindTable contains FuncUnwinders objects for any function in this + /// Module. If a FuncUnwinders object hasn't been created yet (i.e. the + /// function has yet to be unwound in a stack walk), it will be created when + /// requested. Specifically, we do not create FuncUnwinders objects for + /// functions until they are needed. + /// + /// @return + /// Returns the unwind table for this module. Nullptr is returned only if + /// this object has no associated object file. + //------------------------------------------------------------------ + UnwindTable *GetUnwindTable(); + llvm::VersionTuple GetVersion(); //------------------------------------------------------------------ @@ -1090,6 +1105,9 @@ lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file ///parser for this module as it may or may ///not be shared with the SymbolFile + llvm::Optional m_unwind_table; /// < Table of FuncUnwinders + /// objects created for this + /// Module's functions lldb::SymbolVendorUP m_symfile_ap; ///< A pointer to the symbol vendor for this module. std::vector Index: include/lldb/Symbol/ObjectFile.h =================================================================== --- include/lldb/Symbol/ObjectFile.h +++ include/lldb/Symbol/ObjectFile.h @@ -477,20 +477,6 @@ //------------------------------------------------------------------ virtual bool ParseHeader() = 0; - //------------------------------------------------------------------ - /// Returns a reference to the UnwindTable for this ObjectFile - /// - /// The UnwindTable contains FuncUnwinders objects for any function in this - /// ObjectFile. If a FuncUnwinders object hasn't been created yet (i.e. the - /// function has yet to be unwound in a stack walk), it will be created when - /// requested. Specifically, we do not create FuncUnwinders objects for - /// functions until they are needed. - /// - /// @return - /// Returns the unwind table for this object file. - //------------------------------------------------------------------ - virtual lldb_private::UnwindTable &GetUnwindTable() { return m_unwind_table; } - //------------------------------------------------------------------ /// Returns if the function bounds for symbols in this symbol file are /// likely accurate. @@ -774,9 +760,6 @@ ///determined). DataExtractor m_data; ///< The data for this object file so things can be parsed lazily. - lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects - /// created for this ObjectFile's - /// functions lldb::ProcessWP m_process_wp; const lldb::addr_t m_memory_addr; std::unique_ptr m_sections_ap; Index: source/Commands/CommandObjectTarget.cpp =================================================================== --- source/Commands/CommandObjectTarget.cpp +++ source/Commands/CommandObjectTarget.cpp @@ -3533,9 +3533,8 @@ start_addr = abi->FixCodeAddress(start_addr); FuncUnwindersSP func_unwinders_sp( - sc.module_sp->GetObjectFile() - ->GetUnwindTable() - .GetUncachedFuncUnwindersContainingAddress(start_addr, sc)); + sc.module_sp->GetUnwindTable() + ->GetUncachedFuncUnwindersContainingAddress(start_addr, sc)); if (!func_unwinders_sp) continue; Index: source/Core/Module.cpp =================================================================== --- source/Core/Module.cpp +++ source/Core/Module.cpp @@ -1296,6 +1296,14 @@ sym_vendor->SectionFileAddressesChanged(); } +UnwindTable *Module::GetUnwindTable() { + if (!m_unwind_table) { + if (ObjectFile *obj_file = GetObjectFile()) + m_unwind_table.emplace(*obj_file); + } + return m_unwind_table ? m_unwind_table.getPointer() : nullptr; +} + SectionList *Module::GetUnifiedSectionList() { if (!m_sections_ap) m_sections_ap = llvm::make_unique(); Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2862,8 +2862,8 @@ } } - DWARFCallFrameInfo *eh_frame = GetUnwindTable().GetEHFrameInfo(); - if (eh_frame) { + if (DWARFCallFrameInfo *eh_frame = + GetModule()->GetUnwindTable()->GetEHFrameInfo()) { if (m_symtab_ap == nullptr) m_symtab_ap.reset(new Symtab(this)); ParseUnwindSymbols(m_symtab_ap.get(), eh_frame); Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -239,9 +239,8 @@ if (m_sym_ctx_valid) { func_unwinders_sp = - pc_module_sp->GetObjectFile() - ->GetUnwindTable() - .GetFuncUnwindersContainingAddress(m_current_pc, m_sym_ctx); + pc_module_sp->GetUnwindTable()->GetFuncUnwindersContainingAddress( + m_current_pc, m_sym_ctx); } if (func_unwinders_sp.get() != nullptr) @@ -672,9 +671,8 @@ return unwind_plan_sp; FuncUnwindersSP func_unwinders_sp( - pc_module_sp->GetObjectFile() - ->GetUnwindTable() - .GetFuncUnwindersContainingAddress(m_current_pc, m_sym_ctx)); + pc_module_sp->GetUnwindTable()->GetFuncUnwindersContainingAddress( + m_current_pc, m_sym_ctx)); if (!func_unwinders_sp) return unwind_plan_sp; @@ -775,9 +773,8 @@ FuncUnwindersSP func_unwinders_sp; if (m_sym_ctx_valid) { func_unwinders_sp = - pc_module_sp->GetObjectFile() - ->GetUnwindTable() - .GetFuncUnwindersContainingAddress(m_current_pc, m_sym_ctx); + pc_module_sp->GetUnwindTable()->GetFuncUnwindersContainingAddress( + m_current_pc, m_sym_ctx); } // No FuncUnwinders available for this pc (stripped function symbols, lldb @@ -795,7 +792,7 @@ // Even with -fomit-frame-pointer, we can try eh_frame to get back on // track. DWARFCallFrameInfo *eh_frame = - pc_module_sp->GetObjectFile()->GetUnwindTable().GetEHFrameInfo(); + pc_module_sp->GetUnwindTable()->GetEHFrameInfo(); if (eh_frame) { unwind_plan_sp = std::make_shared(lldb::eRegisterKindGeneric); if (eh_frame->GetUnwindPlan(m_current_pc, *unwind_plan_sp)) @@ -805,7 +802,7 @@ } ArmUnwindInfo *arm_exidx = - pc_module_sp->GetObjectFile()->GetUnwindTable().GetArmUnwindInfo(); + pc_module_sp->GetUnwindTable()->GetArmUnwindInfo(); if (arm_exidx) { unwind_plan_sp = std::make_shared(lldb::eRegisterKindGeneric); if (arm_exidx->GetUnwindPlan(exe_ctx.GetTargetRef(), m_current_pc, Index: source/Symbol/ObjectFile.cpp =================================================================== --- source/Symbol/ObjectFile.cpp +++ 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_ap(), m_symtab_ap(), 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_ap(), m_symtab_ap(), - m_synthetic_symbol_idx(0) { + m_process_wp(process_sp), m_memory_addr(header_addr), m_sections_ap(), + m_symtab_ap(), 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));