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