1 //===-- DWARFBaseDIE.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_DWARFBaseDIE_h_
11 #define SymbolFileDWARF_DWARFBaseDIE_h_
13 #include "lldb/Core/dwarf.h"
14 #include "lldb/lldb-types.h"
18 class DWARFAttributes;
20 class DWARFDebugInfoEntry;
21 class DWARFDeclContext;
22 class DWARFDIECollection;
23 class SymbolFileDWARF;
27 DWARFBaseDIE() : m_cu(nullptr), m_die(nullptr) {}
29 DWARFBaseDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die)
30 : m_cu(cu), m_die(die) {}
32 DWARFBaseDIE(const DWARFUnit *cu, DWARFDebugInfoEntry *die)
33 : m_cu(const_cast<DWARFUnit *>(cu)), m_die(die) {}
35 DWARFBaseDIE(DWARFUnit *cu, const DWARFDebugInfoEntry *die)
36 : m_cu(cu), m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
38 DWARFBaseDIE(const DWARFUnit *cu, const DWARFDebugInfoEntry *die)
39 : m_cu(const_cast<DWARFUnit *>(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 HasChildren() const;
51 bool Supports_DW_AT_APPLE_objc_complete_type() const;
53 //----------------------------------------------------------------------
55 //----------------------------------------------------------------------
56 SymbolFileDWARF *GetDWARF() const;
58 DWARFUnit *GetCU() const { return m_cu; }
60 DWARFDebugInfoEntry *GetDIE() const { return m_die; }
62 DIERef GetDIERef() const;
64 lldb_private::TypeSystem *GetTypeSystem() const;
66 DWARFASTParser *GetDWARFParser() const;
68 void Set(DWARFUnit *cu, DWARFDebugInfoEntry *die) {
82 //----------------------------------------------------------------------
83 // Get the data that contains the attribute values for this DIE. Support
84 // for .debug_types means that any DIE can have its data either in the
85 // .debug_info or the .debug_types section; this method will return the
86 // correct section data.
88 // Clients must validate that this object is valid before calling this.
89 //----------------------------------------------------------------------
90 const lldb_private::DWARFDataExtractor &GetData() const;
92 //----------------------------------------------------------------------
93 // Accessing information about a DIE
94 //----------------------------------------------------------------------
97 const char *GetTagAsCString() const;
99 dw_offset_t GetOffset() const;
101 dw_offset_t GetCompileUnitRelativeOffset() const;
103 //----------------------------------------------------------------------
104 // Get the LLDB user ID for this DIE. This is often just the DIE offset,
105 // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
106 // we are doing Darwin DWARF in .o file, or DWARF stand alone debug
108 //----------------------------------------------------------------------
109 lldb::user_id_t GetID() const;
111 const char *GetName() const;
113 lldb::LanguageType GetLanguage() const;
115 lldb::ModuleSP GetModule() const;
117 lldb_private::CompileUnit *GetLLDBCompileUnit() const;
119 //----------------------------------------------------------------------
120 // Getting attribute values from the DIE.
122 // GetAttributeValueAsXXX() functions should only be used if you are
123 // looking for one or two attributes on a DIE. If you are trying to
124 // parse all attributes, use GetAttributes (...) instead
125 //----------------------------------------------------------------------
126 const char *GetAttributeValueAsString(const dw_attr_t attr,
127 const char *fail_value) const;
129 uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr,
130 uint64_t fail_value) const;
132 int64_t GetAttributeValueAsSigned(const dw_attr_t attr,
133 int64_t fail_value) const;
135 uint64_t GetAttributeValueAsReference(const dw_attr_t attr,
136 uint64_t fail_value) const;
138 uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,
139 uint64_t fail_value) const;
141 size_t GetAttributes(DWARFAttributes &attributes, uint32_t depth = 0) const;
143 //----------------------------------------------------------------------
145 //----------------------------------------------------------------------
147 void Dump(lldb_private::Stream *s, const uint32_t recurse_depth) const;
151 DWARFDebugInfoEntry *m_die;
154 bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);
155 bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);
157 #endif // SymbolFileDWARF_DWARFBaseDIE_h_