1 //===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "SymbolFileDWARFDwo.h"
12 #include "lldb/Core/Section.h"
13 #include "lldb/Expression/DWARFExpression.h"
14 #include "lldb/Symbol/ObjectFile.h"
15 #include "lldb/Utility/LLDBAssert.h"
17 #include "DWARFCompileUnit.h"
18 #include "DWARFDebugInfo.h"
21 using namespace lldb_private;
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);
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 */);
35 SectionSP section_sp(section_list->FindSectionByType(sect_type, true));
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());
44 if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0)
51 SymbolFileDWARF::LoadSectionData(sect_type, data);
55 SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit *dwarf_cu,
57 assert(GetCompileUnit() == dwarf_cu && "SymbolFileDWARFDwo::ParseCompileUnit "
58 "called with incompatible compile "
60 return GetBaseSymbolFile()->ParseCompileUnit(m_base_dwarf_cu, UINT32_MAX);
63 DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() {
64 // A clang module is found via a skeleton CU, but is not a proper DWO.
65 // Clang modules have a .debug_info section instead of the *_dwo variant.
66 if (auto *section_list = m_obj_file->GetSectionList(false))
68 section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true))
69 if (!section_sp->GetName().GetStringRef().endswith("dwo"))
72 // Only dwo files with 1 compile unit is supported
73 if (GetNumCompileUnits() == 1)
74 return DebugInfo()->GetCompileUnitAtIndex(0);
80 SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
81 return GetCompileUnit();
84 SymbolFileDWARF::DIEToTypePtr &SymbolFileDWARFDwo::GetDIEToType() {
85 return GetBaseSymbolFile()->GetDIEToType();
88 SymbolFileDWARF::DIEToVariableSP &SymbolFileDWARFDwo::GetDIEToVariable() {
89 return GetBaseSymbolFile()->GetDIEToVariable();
92 SymbolFileDWARF::DIEToClangType &
93 SymbolFileDWARFDwo::GetForwardDeclDieToClangType() {
94 return GetBaseSymbolFile()->GetForwardDeclDieToClangType();
97 SymbolFileDWARF::ClangTypeToDIE &
98 SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() {
99 return GetBaseSymbolFile()->GetForwardDeclClangTypeToDie();
102 size_t SymbolFileDWARFDwo::GetObjCMethodDIEOffsets(
103 lldb_private::ConstString class_name, DIEArray &method_die_offsets) {
104 return GetBaseSymbolFile()->GetObjCMethodDIEOffsets(
105 class_name, method_die_offsets);
108 UniqueDWARFASTTypeMap &SymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap() {
109 return GetBaseSymbolFile()->GetUniqueDWARFASTTypeMap();
112 lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
113 const DWARFDeclContext &die_decl_ctx) {
114 return GetBaseSymbolFile()->FindDefinitionTypeForDWARFDeclContext(
118 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
119 const DWARFDIE &die, const lldb_private::ConstString &type_name,
120 bool must_be_implementation) {
121 return GetBaseSymbolFile()->FindCompleteObjCDefinitionTypeForDIE(
122 die, type_name, must_be_implementation);
125 DWARFCompileUnit *SymbolFileDWARFDwo::GetBaseCompileUnit() {
126 return m_base_dwarf_cu;
129 SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
130 return m_base_dwarf_cu->GetSymbolFileDWARF();
133 DWARFExpression::LocationListFormat
134 SymbolFileDWARFDwo::GetLocationListFormat() const {
135 return DWARFExpression::SplitDwarfLocationList;
139 SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) {
140 return GetBaseSymbolFile()->GetTypeSystemForLanguage(language);
144 SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) {
145 lldbassert(m_base_dwarf_cu->GetOffset() == die_ref.cu_offset);
146 return DebugInfo()->GetDIEForDIEOffset(die_ref.die_offset);