SymbolFileDWARFDwo.cpp revision 309124
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 20using namespace lldb; 21using namespace lldb_private; 22 23SymbolFileDWARFDwo::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 31void 32SymbolFileDWARFDwo::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 57lldb::CompUnitSP 58SymbolFileDWARFDwo::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 64DWARFCompileUnit* 65SymbolFileDWARFDwo::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 74DWARFCompileUnit* 75SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) 76{ 77 return GetCompileUnit(); 78} 79 80SymbolFileDWARF::DIEToTypePtr& 81SymbolFileDWARFDwo::GetDIEToType() 82{ 83 return GetBaseSymbolFile()->GetDIEToType(); 84} 85 86SymbolFileDWARF::DIEToVariableSP& 87SymbolFileDWARFDwo::GetDIEToVariable() 88{ 89 return GetBaseSymbolFile()->GetDIEToVariable(); 90} 91 92SymbolFileDWARF::DIEToClangType& 93SymbolFileDWARFDwo::GetForwardDeclDieToClangType() 94{ 95 return GetBaseSymbolFile()->GetForwardDeclDieToClangType(); 96} 97 98SymbolFileDWARF::ClangTypeToDIE& 99SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() 100{ 101 return GetBaseSymbolFile()->GetForwardDeclClangTypeToDie(); 102} 103 104UniqueDWARFASTTypeMap& 105SymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap() 106{ 107 return GetBaseSymbolFile()->GetUniqueDWARFASTTypeMap(); 108} 109 110lldb::TypeSP 111SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx) 112{ 113 return GetBaseSymbolFile()->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx); 114} 115 116SymbolFileDWARF* 117SymbolFileDWARFDwo::GetBaseSymbolFile() 118{ 119 return m_base_dwarf_cu->GetSymbolFileDWARF(); 120} 121 122DWARFExpression::LocationListFormat 123SymbolFileDWARFDwo::GetLocationListFormat() const 124{ 125 return DWARFExpression::SplitDwarfLocationList; 126} 127 128TypeSystem* 129SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) 130{ 131 return GetBaseSymbolFile()->GetTypeSystemForLanguage(language); 132} 133 134DWARFDIE 135SymbolFileDWARFDwo::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