1 //===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "SymbolFileDWARFDwo.h" 10 11 #include "lldb/Core/Section.h" 12 #include "lldb/Expression/DWARFExpression.h" 13 #include "lldb/Symbol/ObjectFile.h" 14 #include "lldb/Utility/LLDBAssert.h" 15 16 #include "DWARFCompileUnit.h" 17 #include "DWARFDebugInfo.h" 18 #include "DWARFUnit.h" 19 20 using namespace lldb; 21 using namespace lldb_private; 22 23 SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile, 24 DWARFCompileUnit &dwarf_cu) 25 : SymbolFileDWARF(objfile.get(), objfile->GetSectionList( 26 /*update_module_section_list*/ false)), 27 m_obj_file_sp(objfile), m_base_dwarf_cu(dwarf_cu) { 28 SetID(((lldb::user_id_t)dwarf_cu.GetID()) << 32); 29 } 30 31 void SymbolFileDWARFDwo::LoadSectionData(lldb::SectionType sect_type, 32 DWARFDataExtractor &data) { 33 const SectionList *section_list = 34 m_obj_file->GetSectionList(false /* update_module_section_list */); 35 if (section_list) { 36 SectionSP section_sp(section_list->FindSectionByType(sect_type, true)); 37 if (section_sp) { 38 39 if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0) 40 return; 41 42 data.Clear(); 43 } 44 } 45 46 SymbolFileDWARF::LoadSectionData(sect_type, data); 47 } 48 49 lldb::CompUnitSP 50 SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) { 51 assert(GetCompileUnit() == &dwarf_cu && 52 "SymbolFileDWARFDwo::ParseCompileUnit called with incompatible " 53 "compile unit"); 54 return GetBaseSymbolFile().ParseCompileUnit(m_base_dwarf_cu); 55 } 56 57 DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() { 58 // Only dwo files with 1 compile unit is supported 59 if (GetNumCompileUnits() == 1) 60 return DebugInfo()->GetUnitAtIndex(0); 61 else 62 return nullptr; 63 } 64 65 DWARFUnit * 66 SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) { 67 return GetCompileUnit(); 68 } 69 70 SymbolFileDWARF::DIEToTypePtr &SymbolFileDWARFDwo::GetDIEToType() { 71 return GetBaseSymbolFile().GetDIEToType(); 72 } 73 74 SymbolFileDWARF::DIEToVariableSP &SymbolFileDWARFDwo::GetDIEToVariable() { 75 return GetBaseSymbolFile().GetDIEToVariable(); 76 } 77 78 SymbolFileDWARF::DIEToClangType & 79 SymbolFileDWARFDwo::GetForwardDeclDieToClangType() { 80 return GetBaseSymbolFile().GetForwardDeclDieToClangType(); 81 } 82 83 SymbolFileDWARF::ClangTypeToDIE & 84 SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() { 85 return GetBaseSymbolFile().GetForwardDeclClangTypeToDie(); 86 } 87 88 size_t SymbolFileDWARFDwo::GetObjCMethodDIEOffsets( 89 lldb_private::ConstString class_name, DIEArray &method_die_offsets) { 90 return GetBaseSymbolFile().GetObjCMethodDIEOffsets(class_name, 91 method_die_offsets); 92 } 93 94 UniqueDWARFASTTypeMap &SymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap() { 95 return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap(); 96 } 97 98 lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext( 99 const DWARFDeclContext &die_decl_ctx) { 100 return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext( 101 die_decl_ctx); 102 } 103 104 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE( 105 const DWARFDIE &die, lldb_private::ConstString type_name, 106 bool must_be_implementation) { 107 return GetBaseSymbolFile().FindCompleteObjCDefinitionTypeForDIE( 108 die, type_name, must_be_implementation); 109 } 110 111 SymbolFileDWARF &SymbolFileDWARFDwo::GetBaseSymbolFile() { 112 return m_base_dwarf_cu.GetSymbolFileDWARF(); 113 } 114 115 DWARFExpression::LocationListFormat 116 SymbolFileDWARFDwo::GetLocationListFormat() const { 117 return DWARFExpression::SplitDwarfLocationList; 118 } 119 120 TypeSystem * 121 SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) { 122 return GetBaseSymbolFile().GetTypeSystemForLanguage(language); 123 } 124 125 DWARFDIE 126 SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) { 127 lldbassert(die_ref.cu_offset == m_base_dwarf_cu.GetOffset() || 128 die_ref.cu_offset == DW_INVALID_OFFSET); 129 return DebugInfo()->GetDIEForDIEOffset(die_ref.section, die_ref.die_offset); 130 } 131