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 "DWARFUnit.h" 17 #include "DWARFDebugInfo.h" 18 19 using namespace lldb; 20 using namespace lldb_private; 21 22 SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile, 23 DWARFUnit *dwarf_cu) 24 : SymbolFileDWARF(objfile.get(), objfile->GetSectionList( 25 /*update_module_section_list*/ false)), 26 m_obj_file_sp(objfile), m_base_dwarf_cu(dwarf_cu) { 27 SetID(((lldb::user_id_t)dwarf_cu->GetID()) << 32); 28 } 29 30 void SymbolFileDWARFDwo::LoadSectionData(lldb::SectionType sect_type, 31 DWARFDataExtractor &data) { 32 const SectionList *section_list = 33 m_obj_file->GetSectionList(false /* update_module_section_list */); 34 if (section_list) { 35 SectionSP section_sp(section_list->FindSectionByType(sect_type, true)); 36 if (section_sp) { 37 38 if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0) 39 return; 40 41 data.Clear(); 42 } 43 } 44 45 SymbolFileDWARF::LoadSectionData(sect_type, data); 46 } 47 48 lldb::CompUnitSP 49 SymbolFileDWARFDwo::ParseCompileUnit(DWARFUnit *dwarf_cu, 50 uint32_t cu_idx) { 51 assert(GetCompileUnit() == dwarf_cu && "SymbolFileDWARFDwo::ParseCompileUnit " 52 "called with incompatible compile " 53 "unit"); 54 return GetBaseSymbolFile()->ParseCompileUnit(m_base_dwarf_cu, UINT32_MAX); 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( 91 class_name, 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 DWARFUnit *SymbolFileDWARFDwo::GetBaseCompileUnit() { 112 return m_base_dwarf_cu; 113 } 114 115 SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() { 116 return m_base_dwarf_cu->GetSymbolFileDWARF(); 117 } 118 119 DWARFExpression::LocationListFormat 120 SymbolFileDWARFDwo::GetLocationListFormat() const { 121 return DWARFExpression::SplitDwarfLocationList; 122 } 123 124 TypeSystem * 125 SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) { 126 return GetBaseSymbolFile()->GetTypeSystemForLanguage(language); 127 } 128 129 DWARFDIE 130 SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) { 131 lldbassert(die_ref.cu_offset == m_base_dwarf_cu->GetOffset() || 132 die_ref.cu_offset == DW_INVALID_OFFSET); 133 return DebugInfo()->GetDIEForDIEOffset(die_ref.section, die_ref.die_offset); 134 } 135