1 //===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "SymbolFileDWARFDwo.h" 11 12 #include "lldb/Core/Section.h" 13 #include "lldb/Expression/DWARFExpression.h" 14 #include "lldb/Symbol/ObjectFile.h" 15 #include "lldb/Utility/LLDBAssert.h" 16 17 #include "DWARFCompileUnit.h" 18 #include "DWARFDebugInfo.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()), m_obj_file_sp(objfile), 26 m_base_dwarf_cu(dwarf_cu) { 27 SetID(((lldb::user_id_t)dwarf_cu->GetOffset()) << 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 // See if we memory mapped the DWARF segment? 38 if (m_dwarf_data.GetByteSize()) { 39 data.SetData(m_dwarf_data, section_sp->GetOffset(), 40 section_sp->GetFileSize()); 41 return; 42 } 43 44 if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0) 45 return; 46 47 data.Clear(); 48 } 49 } 50 51 SymbolFileDWARF::LoadSectionData(sect_type, data); 52 } 53 54 lldb::CompUnitSP 55 SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit *dwarf_cu, 56 uint32_t cu_idx) { 57 assert(GetCompileUnit() == dwarf_cu && "SymbolFileDWARFDwo::ParseCompileUnit " 58 "called with incompatible compile " 59 "unit"); 60 return GetBaseSymbolFile()->ParseCompileUnit(m_base_dwarf_cu, UINT32_MAX); 61 } 62 63 DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() { 64 // Only dwo files with 1 compile unit is supported 65 if (GetNumCompileUnits() == 1) 66 return DebugInfo()->GetCompileUnitAtIndex(0); 67 else 68 return nullptr; 69 } 70 71 DWARFCompileUnit * 72 SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) { 73 return GetCompileUnit(); 74 } 75 76 SymbolFileDWARF::DIEToTypePtr &SymbolFileDWARFDwo::GetDIEToType() { 77 return GetBaseSymbolFile()->GetDIEToType(); 78 } 79 80 SymbolFileDWARF::DIEToVariableSP &SymbolFileDWARFDwo::GetDIEToVariable() { 81 return GetBaseSymbolFile()->GetDIEToVariable(); 82 } 83 84 SymbolFileDWARF::DIEToClangType & 85 SymbolFileDWARFDwo::GetForwardDeclDieToClangType() { 86 return GetBaseSymbolFile()->GetForwardDeclDieToClangType(); 87 } 88 89 SymbolFileDWARF::ClangTypeToDIE & 90 SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() { 91 return GetBaseSymbolFile()->GetForwardDeclClangTypeToDie(); 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 SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() { 105 return m_base_dwarf_cu->GetSymbolFileDWARF(); 106 } 107 108 DWARFExpression::LocationListFormat 109 SymbolFileDWARFDwo::GetLocationListFormat() const { 110 return DWARFExpression::SplitDwarfLocationList; 111 } 112 113 TypeSystem * 114 SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) { 115 return GetBaseSymbolFile()->GetTypeSystemForLanguage(language); 116 } 117 118 DWARFDIE 119 SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) { 120 lldbassert(m_base_dwarf_cu->GetOffset() == die_ref.cu_offset); 121 return DebugInfo()->GetDIEForDIEOffset(die_ref.die_offset); 122 } 123