Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -106,5 +106,5 @@ } const lldb_private::DWARFDataExtractor &DWARFCompileUnit::GetData() const { - return m_dwarf->get_debug_info_data(); + return m_dwarf->GetDWARFContext().getOrLoadDebugInfoData(); } Index: source/Plugins/SymbolFile/DWARF/DWARFContext.h =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFContext.h +++ source/Plugins/SymbolFile/DWARF/DWARFContext.h @@ -10,20 +10,29 @@ #define LLDB_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H #include "DWARFDataExtractor.h" -#include "lldb/Core/Module.h" +#include "lldb/Core/Section.h" #include "llvm/ADT/Optional.h" #include namespace lldb_private { class DWARFContext { private: - Module &m_module; + SectionList *m_main_section_list; + SectionList *m_dwo_section_list; + llvm::Optional m_data_debug_aranges; + llvm::Optional m_data_debug_info; + + bool isDwo() { return m_dwo_section_list != nullptr; } public: - explicit DWARFContext(Module &module); + explicit DWARFContext(SectionList *main_section_list, + SectionList *dwo_section_list) + : m_main_section_list(main_section_list), + m_dwo_section_list(dwo_section_list) {} const DWARFDataExtractor &getOrLoadArangesData(); + const DWARFDataExtractor &getOrLoadDebugInfoData(); }; } // namespace lldb_private Index: source/Plugins/SymbolFile/DWARF/DWARFContext.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFContext.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFContext.cpp @@ -13,9 +13,8 @@ using namespace lldb; using namespace lldb_private; -static DWARFDataExtractor LoadSection(Module &module, +static DWARFDataExtractor LoadSection(SectionList *section_list, SectionType section_type) { - SectionList *section_list = module.GetSectionList(); if (!section_list) return DWARFDataExtractor(); @@ -29,16 +28,23 @@ } static const DWARFDataExtractor & -LoadOrGetSection(Module &module, SectionType section_type, +LoadOrGetSection(SectionList *section_list, SectionType section_type, llvm::Optional &extractor) { if (!extractor) - extractor = LoadSection(module, section_type); + extractor = LoadSection(section_list, section_type); return *extractor; } -DWARFContext::DWARFContext(Module &module) : m_module(module) {} - const DWARFDataExtractor &DWARFContext::getOrLoadArangesData() { - return LoadOrGetSection(m_module, eSectionTypeDWARFDebugAranges, + return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugAranges, m_data_debug_aranges); } + +const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() { + if (isDwo()) + return LoadOrGetSection(m_dwo_section_list, eSectionTypeDWARFDebugInfoDwo, + m_data_debug_info); + else + return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugInfo, + m_data_debug_info); +} Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -80,7 +80,7 @@ return; lldb::offset_t offset = 0; - const auto &debug_info_data = m_dwarf2Data->get_debug_info_data(); + const auto &debug_info_data = m_context.getOrLoadDebugInfoData(); while (debug_info_data.ValidOffset(offset)) { llvm::Expected cu_sp = DWARFCompileUnit::extract( Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -8,7 +8,9 @@ #include +#include "lldb/Core/Module.h" #include "lldb/Core/dwarf.h" +#include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/Stream.h" #include "DWARFDebugInfo.h" Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -84,7 +84,8 @@ // Constructors and Destructors - SymbolFileDWARF(lldb_private::ObjectFile *ofile); + SymbolFileDWARF(lldb_private::ObjectFile *ofile, + lldb_private::SectionList *dwo_section_list); ~SymbolFileDWARF() override; @@ -214,7 +215,6 @@ virtual const lldb_private::DWARFDataExtractor &get_debug_abbrev_data(); virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data(); const lldb_private::DWARFDataExtractor &get_debug_frame_data(); - virtual const lldb_private::DWARFDataExtractor &get_debug_info_data(); const lldb_private::DWARFDataExtractor &get_debug_line_data(); const lldb_private::DWARFDataExtractor &get_debug_line_str_data(); const lldb_private::DWARFDataExtractor &get_debug_macro_data(); @@ -315,6 +315,8 @@ void DumpClangAST(lldb_private::Stream &s) override; + lldb_private::DWARFContext &GetDWARFContext() { return m_context; } + protected: typedef llvm::DenseMap DIEToTypePtr; Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -200,7 +200,8 @@ } SymbolFile *SymbolFileDWARF::CreateInstance(ObjectFile *obj_file) { - return new SymbolFileDWARF(obj_file); + return new SymbolFileDWARF(obj_file, + /*dwo_section_list*/ nullptr); } TypeList *SymbolFileDWARF::GetTypeList() { @@ -348,18 +349,19 @@ return DWARFDIE(); } -SymbolFileDWARF::SymbolFileDWARF(ObjectFile *objfile) +SymbolFileDWARF::SymbolFileDWARF(ObjectFile *objfile, + SectionList *dwo_section_list) : SymbolFile(objfile), UserID(0x7fffffff00000000), // Used by SymbolFileDWARFDebugMap to // when this class parses .o files to // contain the .o file index/ID m_debug_map_module_wp(), m_debug_map_symfile(NULL), - m_context(*objfile->GetModule()), m_data_debug_abbrev(), - m_data_debug_frame(), m_data_debug_info(), m_data_debug_line(), - m_data_debug_macro(), m_data_debug_loc(), m_data_debug_ranges(), - m_data_debug_rnglists(), m_data_debug_str(), m_data_apple_names(), - m_data_apple_types(), m_data_apple_namespaces(), m_abbr(), m_info(), - m_line(), m_fetched_external_modules(false), + m_context(objfile->GetModule()->GetSectionList(), dwo_section_list), + m_data_debug_abbrev(), m_data_debug_frame(), m_data_debug_info(), + m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(), + m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(), + m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(), + m_abbr(), m_info(), m_line(), m_fetched_external_modules(false), m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(), m_unique_ast_type_map() {} @@ -563,10 +565,6 @@ return GetCachedSectionData(eSectionTypeDWARFDebugFrame, m_data_debug_frame); } -const DWARFDataExtractor &SymbolFileDWARF::get_debug_info_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugInfo, m_data_debug_info); -} - const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_data() { return GetCachedSectionData(eSectionTypeDWARFDebugLine, m_data_debug_line); } @@ -670,7 +668,7 @@ static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION, static_cast(this)); - if (get_debug_info_data().GetByteSize() > 0) { + if (m_context.getOrLoadDebugInfoData().GetByteSize() > 0) { m_info = llvm::make_unique(m_context); m_info->SetDwarfData(this); } Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -47,7 +47,6 @@ const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override; const lldb_private::DWARFDataExtractor &get_debug_addr_data() override; - const lldb_private::DWARFDataExtractor &get_debug_info_data() override; const lldb_private::DWARFDataExtractor &get_debug_str_data() override; const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override; Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -21,8 +21,9 @@ SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile, DWARFUnit *dwarf_cu) - : SymbolFileDWARF(objfile.get()), m_obj_file_sp(objfile), - m_base_dwarf_cu(dwarf_cu) { + : SymbolFileDWARF(objfile.get(), objfile->GetSectionList( + /*update_module_section_list*/ false)), + m_obj_file_sp(objfile), m_base_dwarf_cu(dwarf_cu) { SetID(((lldb::user_id_t)dwarf_cu->GetID()) << 32); } @@ -129,10 +130,6 @@ return m_data_debug_addr.m_data; } -const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info); -} - const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() { return GetCachedSectionData(eSectionTypeDWARFDebugStrDwo, m_data_debug_str); }