LLDB  mainline
SymbolFileDWARFDwo.cpp
Go to the documentation of this file.
1 //===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "SymbolFileDWARFDwo.h"
10 
11 #include "lldb/Core/Section.h"
13 #include "lldb/Symbol/ObjectFile.h"
15 
16 #include "DWARFUnit.h"
17 #include "DWARFDebugInfo.h"
18 
19 using namespace lldb;
20 using namespace lldb_private;
21 
23  DWARFUnit *dwarf_cu)
24  : SymbolFileDWARF(objfile.get()), m_obj_file_sp(objfile),
25  m_base_dwarf_cu(dwarf_cu) {
26  SetID(((lldb::user_id_t)dwarf_cu->GetOffset()) << 32);
27 }
28 
30  DWARFDataExtractor &data) {
31  const SectionList *section_list =
32  m_obj_file->GetSectionList(false /* update_module_section_list */);
33  if (section_list) {
34  SectionSP section_sp(section_list->FindSectionByType(sect_type, true));
35  if (section_sp) {
36 
37  if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0)
38  return;
39 
40  data.Clear();
41  }
42  }
43 
44  SymbolFileDWARF::LoadSectionData(sect_type, data);
45 }
46 
47 lldb::CompUnitSP
49  uint32_t cu_idx) {
50  assert(GetCompileUnit() == dwarf_cu && "SymbolFileDWARFDwo::ParseCompileUnit "
51  "called with incompatible compile "
52  "unit");
54 }
55 
57  // Only dwo files with 1 compile unit is supported
58  if (GetNumCompileUnits() == 1)
59  return DebugInfo()->GetCompileUnitAtIndex(0);
60  else
61  return nullptr;
62 }
63 
64 DWARFUnit *
66  return GetCompileUnit();
67 }
68 
70  return GetBaseSymbolFile()->GetDIEToType();
71 }
72 
75 }
76 
80 }
81 
85 }
86 
88  lldb_private::ConstString class_name, DIEArray &method_die_offsets) {
90  class_name, method_die_offsets);
91 }
92 
95 }
96 
98  const DWARFDeclContext &die_decl_ctx) {
100  die_decl_ctx);
101 }
102 
104  const DWARFDIE &die, lldb_private::ConstString type_name,
105  bool must_be_implementation) {
107  die, type_name, must_be_implementation);
108 }
109 
111  return m_base_dwarf_cu;
112 }
113 
117 }
118 
120  // For single file split dwarf case (when we have .dwo sections in a .o),
121  // we do not want to use the .debug_addr section from .o file,
122  // but want to get one from the final executable.
123  // For regular split debug case, .dwo file does not contain the
124  // .debug_addr, so we would always fall back to such lookup anyways.
125  llvm::call_once(m_data_debug_addr.m_flag, [this] {
126  SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr,
127  std::ref(m_data_debug_addr.m_data));
128  });
129  return m_data_debug_addr.m_data;
130 }
131 
134 }
135 
138 }
139 
143 }
144 
147 }
148 
151  return DWARFExpression::SplitDwarfLocationList;
152 }
153 
154 TypeSystem *
156  return GetBaseSymbolFile()->GetTypeSystemForLanguage(language);
157 }
158 
159 DWARFDIE
162  return DebugInfo()->GetDIEForDIEOffset(die_ref.die_offset);
163 }
DWARFUnit * GetBaseCompileUnit() override
virtual DIEToClangType & GetForwardDeclDieToClangType()
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, lldb_private::ConstString type_name, bool must_be_implementation)
virtual lldb::CompUnitSP ParseCompileUnit(DWARFUnit *dwarf_cu, uint32_t cu_idx)
#define lldbassert(x)
Definition: LLDBAssert.h:15
UniqueDWARFASTTypeMap & GetUniqueDWARFASTTypeMap() override
DWARFUnit * GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) override
virtual void LoadSectionData(lldb::SectionType sect_type, lldb_private::DWARFDataExtractor &data)
uint32_t GetNumCompileUnits() override
Definition: DIERef.h:18
lldb_private::TypeSystem * GetTypeSystemForLanguage(lldb::LanguageType language) override
lldb::SectionSP FindSectionByType(lldb::SectionType sect_type, bool check_children, size_t start_idx=0) const
Definition: Section.cpp:545
DWARFUnit * m_base_dwarf_cu
DWARFUnit * GetCompileUnitAtIndex(lldb::user_id_t idx)
A class that describes a compilation unit.
Definition: CompileUnit.h:35
lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, lldb_private::ConstString type_name, bool must_be_implementation) override
DWARFDataSegment m_data_debug_abbrev
std::vector< DIERef > DIEArray
Definition: DIERef.h:51
lldb::CompUnitSP ParseCompileUnit(DWARFUnit *dwarf_cu, uint32_t cu_idx) override
DWARFDataSegment m_data_debug_info
const lldb_private::DWARFDataExtractor & get_debug_str_offsets_data() override
DWARFDataSegment m_data_debug_addr
virtual size_t ReadSectionData(Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len)
Definition: ObjectFile.cpp:488
dw_offset_t die_offset
Definition: DIERef.h:48
#define UINT32_MAX
Definition: lldb-defines.h:31
DWARFDataSegment m_data_debug_str_offsets
DIEToClangType & GetForwardDeclDieToClangType() override
DWARFDataSegment m_data_debug_str
llvm::DenseMap< lldb::opaque_compiler_type_t, DIERef > ClangTypeToDIE
virtual DIEToVariableSP & GetDIEToVariable()
uint64_t user_id_t
Definition: lldb-types.h:84
LanguageType
Programming language type.
void Clear()
Clears the object state.
lldb_private::TypeSystem * GetTypeSystemForLanguage(lldb::LanguageType language) override
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:605
SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFUnit *dwarf_cu)
virtual ClangTypeToDIE & GetForwardDeclClangTypeToDie()
virtual lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx)
llvm::DenseMap< const DWARFDebugInfoEntry *, lldb::opaque_compiler_type_t > DIEToClangType
DWARFDIE GetDIE(const DIERef &die_ref) override
llvm::DenseMap< const DWARFDebugInfoEntry *, lldb::VariableSP > DIEToVariableSP
DIEToVariableSP & GetDIEToVariable() override
const lldb_private::DWARFDataExtractor & get_debug_str_data() override
DWARFDebugInfo * DebugInfo()
lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx) override
dw_offset_t GetOffset() const
Definition: DWARFUnit.h:76
DIEToTypePtr & GetDIEToType() override
const lldb_private::DWARFDataExtractor & get_debug_abbrev_data() override
virtual DIEToTypePtr & GetDIEToType()
const lldb_private::DWARFDataExtractor & get_debug_addr_data() override
ObjectFile * m_obj_file
Definition: SymbolFile.h:231
lldb_private::DWARFExpression::LocationListFormat GetLocationListFormat() const override
DWARFUnit * GetCompileUnit()
dw_offset_t cu_offset
Definition: DIERef.h:47
A uniqued constant string class.
Definition: ConstString.h:38
SymbolFileDWARF * GetBaseSymbolFile()
DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset)
virtual UniqueDWARFASTTypeMap & GetUniqueDWARFASTTypeMap()
SymbolFileDWARF * GetSymbolFileDWARF() const
Definition: DWARFUnit.cpp:590
void SetID(lldb::user_id_t uid)
Set accessor for the user ID.
Definition: UserID.h:55
Definition: SBAddress.h:15
lldb_private::DWARFDataExtractor m_data
const lldb_private::DWARFDataExtractor & get_debug_info_data() override
void LoadSectionData(lldb::SectionType sect_type, lldb_private::DWARFDataExtractor &data) override
ClangTypeToDIE & GetForwardDeclClangTypeToDie() override
virtual size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name, DIEArray &method_die_offsets)
size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name, DIEArray &method_die_offsets) override
const lldb_private::DWARFDataExtractor & GetCachedSectionData(lldb::SectionType sect_type, DWARFDataSegment &data_segment)
llvm::DenseMap< const DWARFDebugInfoEntry *, lldb_private::Type * > DIEToTypePtr