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, DWARFCompileUnit* dwarf_cu) : 24 SymbolFileDWARF(objfile.get()), 25 m_obj_file_sp(objfile), 26 m_base_dwarf_cu(dwarf_cu) 27 { 28 SetID(((lldb::user_id_t)dwarf_cu->GetOffset())<<32); 29 } 30 31 void 32 SymbolFileDWARFDwo::LoadSectionData (lldb::SectionType sect_type, DWARFDataExtractor& data) 33 { 34 const SectionList* section_list = m_obj_file->GetSectionList(false /* update_module_section_list */); 35 if (section_list) 36 { 37 SectionSP section_sp (section_list->FindSectionByType(sect_type, true)); 38 if (section_sp) 39 { 40 // See if we memory mapped the DWARF segment? 41 if (m_dwarf_data.GetByteSize()) 42 { 43 data.SetData(m_dwarf_data, section_sp->GetOffset(), section_sp->GetFileSize()); 44 return; 45 } 46 47 if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0) 48 return; 49 50 data.Clear(); 51 } 52 } 53 54 SymbolFileDWARF::LoadSectionData(sect_type, data); 55 } 56 57 lldb::CompUnitSP 58 SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx) 59 { 60 assert(GetCompileUnit() == dwarf_cu && "SymbolFileDWARFDwo::ParseCompileUnit called with incompatible compile unit"); 61 return GetBaseSymbolFile()->ParseCompileUnit(m_base_dwarf_cu, UINT32_MAX); 62 } 63 64 DWARFCompileUnit* 65 SymbolFileDWARFDwo::GetCompileUnit() 66 { 67 // Only dwo files with 1 compile unit is supported 68 if (GetNumCompileUnits() == 1) 69 return DebugInfo()->GetCompileUnitAtIndex(0); 70 else 71 return nullptr; 72 } 73 74 DWARFCompileUnit* 75 SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) 76 { 77 return GetCompileUnit(); 78 } 79 80 SymbolFileDWARF::DIEToTypePtr& 81 SymbolFileDWARFDwo::GetDIEToType() 82 { 83 return GetBaseSymbolFile()->GetDIEToType(); 84 } 85 86 SymbolFileDWARF::DIEToVariableSP& 87 SymbolFileDWARFDwo::GetDIEToVariable() 88 { 89 return GetBaseSymbolFile()->GetDIEToVariable(); 90 } 91 92 SymbolFileDWARF::DIEToClangType& 93 SymbolFileDWARFDwo::GetForwardDeclDieToClangType() 94 { 95 return GetBaseSymbolFile()->GetForwardDeclDieToClangType(); 96 } 97 98 SymbolFileDWARF::ClangTypeToDIE& 99 SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() 100 { 101 return GetBaseSymbolFile()->GetForwardDeclClangTypeToDie(); 102 } 103 104 UniqueDWARFASTTypeMap& 105 SymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap() 106 { 107 return GetBaseSymbolFile()->GetUniqueDWARFASTTypeMap(); 108 } 109 110 lldb::TypeSP 111 SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx) 112 { 113 return GetBaseSymbolFile()->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx); 114 } 115 116 SymbolFileDWARF* 117 SymbolFileDWARFDwo::GetBaseSymbolFile() 118 { 119 return m_base_dwarf_cu->GetSymbolFileDWARF(); 120 } 121 122 DWARFExpression::LocationListFormat 123 SymbolFileDWARFDwo::GetLocationListFormat() const 124 { 125 return DWARFExpression::SplitDwarfLocationList; 126 } 127 128 TypeSystem* 129 SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) 130 { 131 return GetBaseSymbolFile()->GetTypeSystemForLanguage(language); 132 } 133 134 DWARFDIE 135 SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) 136 { 137 lldbassert(m_base_dwarf_cu->GetOffset() == die_ref.cu_offset); 138 return DebugInfo()->GetDIEForDIEOffset(die_ref.die_offset); 139 } 140