diff options
author | Pavel Labath <pavel@labath.sk> | 2019-05-20 08:38:47 +0000 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2019-05-20 08:38:47 +0000 |
commit | 0261b9498b89aeeffc93e307d548bbfff5d90b2a (patch) | |
tree | 4bcae413f0c652fcb7a622d3d132cb0b615cbefe /lldb | |
parent | 64b846d58801c9b3834c8364118564178437c97d (diff) | |
download | bcm5719-llvm-0261b9498b89aeeffc93e307d548bbfff5d90b2a.tar.gz bcm5719-llvm-0261b9498b89aeeffc93e307d548bbfff5d90b2a.zip |
DWARF: Port most of other sections over to DWARFContext
This moves the sections from SymbolFileDWARF to DWARFContext, where it
was trivial to do so. A couple of sections are still left in
SymbolFileDWARF. These will be handled by separate patches.
llvm-svn: 361127
Diffstat (limited to 'lldb')
9 files changed, 80 insertions, 126 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index ac429cacbeb..1c05608e4c0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -55,7 +55,8 @@ llvm::Expected<DWARFUnitSP> DWARFCompileUnit::extract( bool length_OK = debug_info.ValidOffset(cu_sp->GetNextUnitOffset() - 1); bool version_OK = SymbolFileDWARF::SupportedVersion(cu_sp->m_version); bool abbr_offset_OK = - dwarf2Data->get_debug_abbrev_data().ValidOffset(abbr_offset); + dwarf2Data->GetDWARFContext().getOrLoadAbbrevData().ValidOffset( + abbr_offset); bool addr_size_OK = (cu_sp->m_addr_size == 4) || (cu_sp->m_addr_size == 8); if (!length_OK) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp index 425d6e296d6..8681447fcb4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp @@ -35,6 +35,14 @@ LoadOrGetSection(SectionList *section_list, SectionType section_type, return *extractor; } +const DWARFDataExtractor &DWARFContext::getOrLoadAbbrevData() { + if (isDwo()) + return LoadOrGetSection(m_dwo_section_list, eSectionTypeDWARFDebugAbbrevDwo, + m_data_debug_abbrev); + return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugAbbrev, + m_data_debug_abbrev); +} + const DWARFDataExtractor &DWARFContext::getOrLoadArangesData() { return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugAranges, m_data_debug_aranges); @@ -47,3 +55,34 @@ const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() { return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugInfo, m_data_debug_info); } + +const DWARFDataExtractor &DWARFContext::getOrLoadLineData() { + return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugLine, + m_data_debug_line); +} + +const DWARFDataExtractor &DWARFContext::getOrLoadLineStrData() { + return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugLineStr, + m_data_debug_line_str); +} + +const DWARFDataExtractor &DWARFContext::getOrLoadMacroData() { + return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugMacro, + m_data_debug_macro); +} + +const DWARFDataExtractor &DWARFContext::getOrLoadStrData() { + if (isDwo()) + return LoadOrGetSection(m_dwo_section_list, eSectionTypeDWARFDebugStrDwo, + m_data_debug_str); + return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugStr, + m_data_debug_str); +} + +const DWARFDataExtractor &DWARFContext::getOrLoadStrOffsetsData() { + if (isDwo()) + return LoadOrGetSection(m_dwo_section_list, eSectionTypeDWARFDebugStrOffsetsDwo, + m_data_debug_str_offsets); + return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugStrOffsets, + m_data_debug_str_offsets); +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h index 89f4994fa5c..879344c69f8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h @@ -20,8 +20,14 @@ private: SectionList *m_main_section_list; SectionList *m_dwo_section_list; + llvm::Optional<DWARFDataExtractor> m_data_debug_abbrev; llvm::Optional<DWARFDataExtractor> m_data_debug_aranges; llvm::Optional<DWARFDataExtractor> m_data_debug_info; + llvm::Optional<DWARFDataExtractor> m_data_debug_line; + llvm::Optional<DWARFDataExtractor> m_data_debug_line_str; + llvm::Optional<DWARFDataExtractor> m_data_debug_macro; + llvm::Optional<DWARFDataExtractor> m_data_debug_str; + llvm::Optional<DWARFDataExtractor> m_data_debug_str_offsets; bool isDwo() { return m_dwo_section_list != nullptr; } @@ -31,8 +37,14 @@ public: : m_main_section_list(main_section_list), m_dwo_section_list(dwo_section_list) {} + const DWARFDataExtractor &getOrLoadAbbrevData(); const DWARFDataExtractor &getOrLoadArangesData(); const DWARFDataExtractor &getOrLoadDebugInfoData(); + const DWARFDataExtractor &getOrLoadLineData(); + const DWARFDataExtractor &getOrLoadLineStrData(); + const DWARFDataExtractor &getOrLoadMacroData(); + const DWARFDataExtractor &getOrLoadStrData(); + const DWARFDataExtractor &getOrLoadStrOffsetsData(); }; } // namespace lldb_private diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 0452c722717..a4caa05b945 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -492,7 +492,8 @@ const char *DWARFFormValue::AsCString() const { if (!symbol_file) return nullptr; - return symbol_file->get_debug_str_data().PeekCStr(m_value.value.uval); + return symbol_file->GetDWARFContext().getOrLoadStrData().PeekCStr( + m_value.value.uval); } else if (m_form == DW_FORM_GNU_str_index) { if (!symbol_file) return nullptr; @@ -500,9 +501,10 @@ const char *DWARFFormValue::AsCString() const { uint32_t index_size = 4; lldb::offset_t offset = m_value.value.uval * index_size; dw_offset_t str_offset = - symbol_file->get_debug_str_offsets_data().GetMaxU64(&offset, - index_size); - return symbol_file->get_debug_str_data().PeekCStr(str_offset); + symbol_file->GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64( + &offset, index_size); + return symbol_file->GetDWARFContext().getOrLoadStrData().PeekCStr( + str_offset); } if (m_form == DW_FORM_strx || m_form == DW_FORM_strx1 || @@ -517,12 +519,15 @@ const char *DWARFFormValue::AsCString() const { lldb::offset_t offset = m_unit->GetStrOffsetsBase() + m_value.value.uval * indexSize; dw_offset_t strOffset = - symbol_file->get_debug_str_offsets_data().GetMaxU64(&offset, indexSize); - return symbol_file->get_debug_str_data().PeekCStr(strOffset); + symbol_file->GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64( + &offset, indexSize); + return symbol_file->GetDWARFContext().getOrLoadStrData().PeekCStr( + strOffset); } if (m_form == DW_FORM_line_strp) - return symbol_file->get_debug_line_str_data().PeekCStr(m_value.value.uval); + return symbol_file->GetDWARFContext().getOrLoadLineStrData().PeekCStr( + m_value.value.uval); return nullptr; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index 101873cf826..ac640285fc3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -256,7 +256,7 @@ static void SetDwoStrOffsetsBase(DWARFUnit *dwo_cu) { lldb::offset_t baseOffset = 0; const DWARFDataExtractor &strOffsets = - dwo_cu->GetSymbolFileDWARF()->get_debug_str_offsets_data(); + dwo_cu->GetSymbolFileDWARF()->GetDWARFContext().getOrLoadStrOffsetsData(); uint64_t length = strOffsets.GetU32(&baseOffset); if (length == 0xffffffff) length = strOffsets.GetU64(&baseOffset); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 5d9b1080607..bc447574ead 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -357,10 +357,7 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFile *objfile, // contain the .o file index/ID m_debug_map_module_wp(), m_debug_map_symfile(NULL), 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_data_debug_loc(), m_data_debug_ranges(), m_data_debug_rnglists(), 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() {} @@ -405,7 +402,7 @@ void SymbolFileDWARF::InitializeObject() { m_index = AppleDWARFIndex::Create( *GetObjectFile()->GetModule(), apple_names, apple_namespaces, - apple_types, apple_objc, get_debug_str_data()); + apple_types, apple_objc, m_context.getOrLoadStrData()); if (m_index) return; @@ -414,9 +411,9 @@ void SymbolFileDWARF::InitializeObject() { LoadSectionData(eSectionTypeDWARFDebugNames, debug_names); if (debug_names.GetByteSize() > 0) { llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> index_or = - DebugNamesDWARFIndex::Create(*GetObjectFile()->GetModule(), - debug_names, get_debug_str_data(), - DebugInfo()); + DebugNamesDWARFIndex::Create( + *GetObjectFile()->GetModule(), debug_names, + m_context.getOrLoadStrData(), DebugInfo()); if (index_or) { m_index = std::move(*index_or); return; @@ -552,31 +549,10 @@ void SymbolFileDWARF::LoadSectionData(lldb::SectionType sect_type, m_obj_file->ReadSectionData(section_sp.get(), data); } -const DWARFDataExtractor &SymbolFileDWARF::get_debug_abbrev_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugAbbrev, - m_data_debug_abbrev); -} - const DWARFDataExtractor &SymbolFileDWARF::get_debug_addr_data() { return GetCachedSectionData(eSectionTypeDWARFDebugAddr, m_data_debug_addr); } -const DWARFDataExtractor &SymbolFileDWARF::get_debug_frame_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugFrame, m_data_debug_frame); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugLine, m_data_debug_line); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_str_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugLineStr, m_data_debug_line_str); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_debug_macro_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro); -} - const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() { const DWARFDataExtractor &debugLocData = get_debug_loc_data(); if (debugLocData.GetByteSize() > 0) @@ -603,46 +579,11 @@ const DWARFDataExtractor &SymbolFileDWARF::get_debug_rnglists_data() { m_data_debug_rnglists); } -const DWARFDataExtractor &SymbolFileDWARF::get_debug_str_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugStr, m_data_debug_str); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_debug_str_offsets_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugStrOffsets, - m_data_debug_str_offsets); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_debug_types_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugTypes, m_data_debug_types); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_apple_names_data() { - return GetCachedSectionData(eSectionTypeDWARFAppleNames, m_data_apple_names); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_apple_types_data() { - return GetCachedSectionData(eSectionTypeDWARFAppleTypes, m_data_apple_types); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_apple_namespaces_data() { - return GetCachedSectionData(eSectionTypeDWARFAppleNamespaces, - m_data_apple_namespaces); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_apple_objc_data() { - return GetCachedSectionData(eSectionTypeDWARFAppleObjC, m_data_apple_objc); -} - -const DWARFDataExtractor &SymbolFileDWARF::get_gnu_debugaltlink() { - return GetCachedSectionData(eSectionTypeDWARFGNUDebugAltLink, - m_data_gnu_debugaltlink); -} - DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() { if (m_abbr) return m_abbr.get(); - const DWARFDataExtractor &debug_abbrev_data = get_debug_abbrev_data(); + const DWARFDataExtractor &debug_abbrev_data = m_context.getOrLoadAbbrevData(); if (debug_abbrev_data.GetByteSize() == 0) return nullptr; @@ -875,7 +816,7 @@ bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit, // supposed to be the compile unit itself. support_files.Append(comp_unit); return DWARFDebugLine::ParseSupportFiles( - comp_unit.GetModule(), get_debug_line_data(), stmt_list, + comp_unit.GetModule(), m_context.getOrLoadLineData(), stmt_list, support_files, dwarf_cu); } } @@ -1019,9 +960,9 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) { } lldb::offset_t offset = cu_line_offset; - DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset, - ParseDWARFLineTableCallback, - &info, dwarf_cu); + DWARFDebugLine::ParseStatementTable( + m_context.getOrLoadLineData(), &offset, + ParseDWARFLineTableCallback, &info, dwarf_cu); SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile(); if (debug_map_symfile) { // We have an object file that has a line table with addresses that @@ -1047,7 +988,7 @@ SymbolFileDWARF::ParseDebugMacros(lldb::offset_t *offset) { if (iter != m_debug_macros_map.end()) return iter->second; - const DWARFDataExtractor &debug_macro_data = get_debug_macro_data(); + const DWARFDataExtractor &debug_macro_data = m_context.getOrLoadMacroData(); if (debug_macro_data.GetByteSize() == 0) return DebugMacrosSP(); @@ -1056,9 +997,9 @@ SymbolFileDWARF::ParseDebugMacros(lldb::offset_t *offset) { const DWARFDebugMacroHeader &header = DWARFDebugMacroHeader::ParseHeader(debug_macro_data, offset); - DWARFDebugMacroEntry::ReadMacroEntries(debug_macro_data, get_debug_str_data(), - header.OffsetIs64Bit(), offset, this, - debug_macros_sp); + DWARFDebugMacroEntry::ReadMacroEntries( + debug_macro_data, m_context.getOrLoadStrData(), header.OffsetIs64Bit(), + offset, this, debug_macros_sp); return debug_macros_sp; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 384e42a8022..5017e50b02d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -212,24 +212,11 @@ public: uint32_t GetPluginVersion() override; - 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(); - 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(); const lldb_private::DWARFDataExtractor &get_debug_loc_data(); const lldb_private::DWARFDataExtractor &get_debug_loclists_data(); const lldb_private::DWARFDataExtractor &get_debug_ranges_data(); const lldb_private::DWARFDataExtractor &get_debug_rnglists_data(); - virtual const lldb_private::DWARFDataExtractor &get_debug_str_data(); - virtual const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data(); - const lldb_private::DWARFDataExtractor &get_debug_types_data(); - const lldb_private::DWARFDataExtractor &get_apple_names_data(); - const lldb_private::DWARFDataExtractor &get_apple_types_data(); - const lldb_private::DWARFDataExtractor &get_apple_namespaces_data(); - const lldb_private::DWARFDataExtractor &get_apple_objc_data(); - const lldb_private::DWARFDataExtractor &get_gnu_debugaltlink(); DWARFDebugAbbrev *DebugAbbrev(); @@ -464,25 +451,11 @@ protected: lldb_private::DWARFContext m_context; - DWARFDataSegment m_data_debug_abbrev; DWARFDataSegment m_data_debug_addr; - DWARFDataSegment m_data_debug_frame; - DWARFDataSegment m_data_debug_info; - DWARFDataSegment m_data_debug_line; - DWARFDataSegment m_data_debug_line_str; - DWARFDataSegment m_data_debug_macro; DWARFDataSegment m_data_debug_loc; DWARFDataSegment m_data_debug_loclists; DWARFDataSegment m_data_debug_ranges; DWARFDataSegment m_data_debug_rnglists; - DWARFDataSegment m_data_debug_str; - DWARFDataSegment m_data_debug_str_offsets; - DWARFDataSegment m_data_debug_types; - DWARFDataSegment m_data_apple_names; - DWARFDataSegment m_data_apple_types; - DWARFDataSegment m_data_apple_namespaces; - DWARFDataSegment m_data_apple_objc; - DWARFDataSegment m_data_gnu_debugaltlink; // The unique pointer items below are generated on demand if and when someone // accesses diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp index 79969a5cc40..be8cdc521c3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -112,11 +112,6 @@ DWARFUnit *SymbolFileDWARFDwo::GetBaseCompileUnit() { return m_base_dwarf_cu; } -const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_abbrev_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugAbbrevDwo, - m_data_debug_abbrev); -} - const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() { // For single file split dwarf case (when we have .dwo sections in a .o), // we do not want to use the .debug_addr section from .o file, @@ -130,15 +125,6 @@ const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() { return m_data_debug_addr.m_data; } -const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugStrDwo, m_data_debug_str); -} - -const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_offsets_data() { - return GetCachedSectionData(eSectionTypeDWARFDebugStrOffsetsDwo, - m_data_debug_str_offsets); -} - SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() { return m_base_dwarf_cu->GetSymbolFileDWARF(); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h index 8444704059f..8edad7d94b7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -45,10 +45,7 @@ public: DWARFUnit *GetBaseCompileUnit() override; - const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override; const lldb_private::DWARFDataExtractor &get_debug_addr_data() override; - const lldb_private::DWARFDataExtractor &get_debug_str_data() override; - const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override; protected: void LoadSectionData(lldb::SectionType sect_type, |