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