1 //===-- DWARFDIE.h ----------------------------------------------*- 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 #ifndef SymbolFileDWARF_DWARFDIE_h_
11 #define SymbolFileDWARF_DWARFDIE_h_
13 #include "lldb/Core/dwarf.h"
14 #include "lldb/lldb-types.h"
18 class DWARFAttributes;
19 class DWARFCompileUnit;
20 class DWARFDebugInfoEntry;
21 class DWARFDeclContext;
22 class DWARFDIECollection;
23 class SymbolFileDWARF;
27 DWARFDIE() : m_cu(nullptr), m_die(nullptr) {}
29 DWARFDIE(DWARFCompileUnit *cu, DWARFDebugInfoEntry *die)
30 : m_cu(cu), m_die(die) {}
32 DWARFDIE(const DWARFCompileUnit *cu, DWARFDebugInfoEntry *die)
33 : m_cu(const_cast<DWARFCompileUnit *>(cu)), m_die(die) {}
35 DWARFDIE(DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die)
36 : m_cu(cu), m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
38 DWARFDIE(const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die)
39 : m_cu(const_cast<DWARFCompileUnit *>(cu)),
40 m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
42 //----------------------------------------------------------------------
44 //----------------------------------------------------------------------
45 explicit operator bool() const { return IsValid(); }
47 bool IsValid() const { return m_cu && m_die; }
49 bool IsStructOrClass() const;
51 bool HasChildren() const;
53 bool Supports_DW_AT_APPLE_objc_complete_type() const;
55 //----------------------------------------------------------------------
57 //----------------------------------------------------------------------
58 SymbolFileDWARF *GetDWARF() const;
60 DWARFCompileUnit *GetCU() const { return m_cu; }
62 DWARFDebugInfoEntry *GetDIE() const { return m_die; }
64 DIERef GetDIERef() const;
66 lldb_private::TypeSystem *GetTypeSystem() const;
68 DWARFASTParser *GetDWARFParser() const;
70 void Set(DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) {
84 lldb::ModuleSP GetContainingDWOModule() const;
87 GetContainingDWOModuleDIE() const;
89 //----------------------------------------------------------------------
90 // Accessing information about a DIE
91 //----------------------------------------------------------------------
94 const char *GetTagAsCString() const;
96 dw_offset_t GetOffset() const;
98 dw_offset_t GetCompileUnitRelativeOffset() const;
100 //----------------------------------------------------------------------
101 // Get the LLDB user ID for this DIE. This is often just the DIE offset,
102 // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
103 // we are doing Darwin DWARF in .o file, or DWARF stand alone debug
105 //----------------------------------------------------------------------
106 lldb::user_id_t GetID() const;
108 const char *GetName() const;
110 const char *GetMangledName() const;
112 const char *GetPubname() const;
114 const char *GetQualifiedName(std::string &storage) const;
116 lldb::LanguageType GetLanguage() const;
118 lldb::ModuleSP GetModule() const;
120 lldb_private::CompileUnit *GetLLDBCompileUnit() const;
122 lldb_private::Type *ResolveType() const;
124 //----------------------------------------------------------------------
125 // Resolve a type by UID using this DIE's DWARF file
126 //----------------------------------------------------------------------
127 lldb_private::Type *ResolveTypeUID(const DIERef &die_ref) const;
129 //----------------------------------------------------------------------
130 // Functions for obtaining DIE relations and references
131 //----------------------------------------------------------------------
137 GetFirstChild() const;
143 GetReferencedDIE(const dw_attr_t attr) const;
145 //----------------------------------------------------------------------
146 // Get a another DIE from the same DWARF file as this DIE. This will
147 // check the current DIE's compile unit first to see if "die_offset" is
148 // in the same compile unit, and fall back to checking the DWARF file.
149 //----------------------------------------------------------------------
151 GetDIE(dw_offset_t die_offset) const;
154 LookupDeepestBlock(lldb::addr_t file_addr) const;
157 GetParentDeclContextDIE() const;
159 //----------------------------------------------------------------------
160 // DeclContext related functions
161 //----------------------------------------------------------------------
162 void GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const;
164 void GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const;
166 void GetDWOContext(std::vector<lldb_private::CompilerContext> &context) const;
168 //----------------------------------------------------------------------
169 // Getting attribute values from the DIE.
171 // GetAttributeValueAsXXX() functions should only be used if you are
172 // looking for one or two attributes on a DIE. If you are trying to
173 // parse all attributes, use GetAttributes (...) instead
174 //----------------------------------------------------------------------
175 const char *GetAttributeValueAsString(const dw_attr_t attr,
176 const char *fail_value) const;
178 uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr,
179 uint64_t fail_value) const;
181 int64_t GetAttributeValueAsSigned(const dw_attr_t attr,
182 int64_t fail_value) const;
184 uint64_t GetAttributeValueAsReference(const dw_attr_t attr,
185 uint64_t fail_value) const;
188 GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const;
190 uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,
191 uint64_t fail_value) const;
193 size_t GetAttributes(DWARFAttributes &attributes, uint32_t depth = 0) const;
195 bool GetDIENamesAndRanges(const char *&name, const char *&mangled,
196 DWARFRangeList &ranges, int &decl_file,
197 int &decl_line, int &decl_column, int &call_file,
198 int &call_line, int &call_column,
199 lldb_private::DWARFExpression *frame_base) const;
201 //----------------------------------------------------------------------
203 //----------------------------------------------------------------------
205 void Dump(lldb_private::Stream *s, const uint32_t recurse_depth) const;
207 lldb_private::CompilerDecl GetDecl() const;
209 lldb_private::CompilerDeclContext GetDeclContext() const;
211 lldb_private::CompilerDeclContext GetContainingDeclContext() const;
214 DWARFCompileUnit *m_cu;
215 DWARFDebugInfoEntry *m_die;
218 bool operator==(const DWARFDIE &lhs, const DWARFDIE &rhs);
219 bool operator!=(const DWARFDIE &lhs, const DWARFDIE &rhs);
221 #endif // SymbolFileDWARF_DWARFDIE_h_