]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
Merge ^/head r296369 through r296409.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / SymbolFile / DWARF / DWARFDIE.h
1 //===-- DWARFDIE.h ----------------------------------------------*- 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 #ifndef SymbolFileDWARF_DWARFDIE_h_
11 #define SymbolFileDWARF_DWARFDIE_h_
12
13 #include "lldb/lldb-types.h"
14 #include "lldb/Core/dwarf.h"
15
16 struct DIERef;
17 class DWARFASTParser;
18 class DWARFAttributes;
19 class DWARFCompileUnit;
20 class DWARFDebugInfoEntry;
21 class DWARFDeclContext;
22 class DWARFDIECollection;
23 class SymbolFileDWARF;
24
25 class DWARFDIE
26 {
27 public:
28     DWARFDIE () :
29         m_cu (nullptr),
30         m_die (nullptr)
31     {
32     }
33
34     DWARFDIE (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) :
35         m_cu (cu),
36         m_die (die)
37     {
38     }
39
40     DWARFDIE (const DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) :
41         m_cu (const_cast<DWARFCompileUnit *>(cu)),
42         m_die (die)
43     {
44     }
45
46     DWARFDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) :
47         m_cu (cu),
48         m_die (const_cast<DWARFDebugInfoEntry *>(die))
49     {
50     }
51
52     DWARFDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) :
53         m_cu (const_cast<DWARFCompileUnit *>(cu)),
54         m_die (const_cast<DWARFDebugInfoEntry *>(die))
55     {
56     }
57
58     //----------------------------------------------------------------------
59     // Tests
60     //----------------------------------------------------------------------
61     operator bool () const
62     {
63         return IsValid();
64     }
65
66     bool
67     IsValid() const
68     {
69         return m_cu && m_die;
70     }
71
72     bool
73     IsStructOrClass () const;
74
75     bool
76     HasChildren () const;
77
78     bool
79     Supports_DW_AT_APPLE_objc_complete_type () const;
80
81     //----------------------------------------------------------------------
82     // Accessors
83     //----------------------------------------------------------------------
84     SymbolFileDWARF *
85     GetDWARF () const;
86
87     DWARFCompileUnit *
88     GetCU() const
89     {
90         return m_cu;
91     }
92
93     DWARFDebugInfoEntry *
94     GetDIE() const
95     {
96         return m_die;
97     }
98
99     DIERef
100     GetDIERef() const;
101
102     lldb_private::TypeSystem *
103     GetTypeSystem () const;
104
105     DWARFASTParser *
106     GetDWARFParser () const;
107
108     void
109     Set (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die)
110     {
111         if (cu && die)
112         {
113             m_cu = cu;
114             m_die = die;
115         }
116         else
117         {
118             Clear();
119         }
120     }
121
122     void
123     Clear ()
124     {
125         m_cu = nullptr;
126         m_die = nullptr;
127     }
128
129     lldb::ModuleSP
130     GetContainingDWOModule () const;
131
132     DWARFDIE
133     GetContainingDWOModuleDIE () const;
134
135     //----------------------------------------------------------------------
136     // Accessing information about a DIE
137     //----------------------------------------------------------------------
138     dw_tag_t
139     Tag() const;
140
141     const char *
142     GetTagAsCString () const;
143
144     dw_offset_t
145     GetOffset () const;
146
147     dw_offset_t
148     GetCompileUnitRelativeOffset () const;
149
150     //----------------------------------------------------------------------
151     // Get the LLDB user ID for this DIE. This is often just the DIE offset,
152     // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
153     // we are doing Darwin DWARF in .o file, or DWARF stand alone debug
154     // info.
155     //----------------------------------------------------------------------
156     lldb::user_id_t
157     GetID() const;
158
159     const char *
160     GetName () const;
161
162     const char *
163     GetMangledName () const;
164
165     const char *
166     GetPubname () const;
167
168     const char *
169     GetQualifiedName (std::string &storage) const;
170
171     lldb::LanguageType
172     GetLanguage () const;
173
174     lldb::ModuleSP
175     GetModule () const;
176
177     lldb_private::CompileUnit *
178     GetLLDBCompileUnit () const;
179
180     lldb_private::Type *
181     ResolveType () const;
182
183     // Resolve a type by UID using this DIE's DWARF file
184     lldb_private::Type *
185     ResolveTypeUID (lldb::user_id_t uid) const;
186
187     //----------------------------------------------------------------------
188     // Functions for obtaining DIE relations and references
189     //----------------------------------------------------------------------
190
191     DWARFDIE
192     GetParent () const;
193
194     DWARFDIE
195     GetFirstChild () const;
196
197     DWARFDIE
198     GetSibling () const;
199
200     DWARFDIE
201     GetReferencedDIE (const dw_attr_t attr) const;
202
203     //----------------------------------------------------------------------
204     // Get a another DIE from the same DWARF file as this DIE. This will
205     // check the current DIE's compile unit first to see if "die_offset" is
206     // in the same compile unit, and fall back to checking the DWARF file.
207     //----------------------------------------------------------------------
208     DWARFDIE
209     GetDIE (dw_offset_t die_offset) const;
210
211     DWARFDIE
212     LookupDeepestBlock (lldb::addr_t file_addr) const;
213
214     DWARFDIE
215     GetParentDeclContextDIE () const;
216
217     //----------------------------------------------------------------------
218     // DeclContext related functions
219     //----------------------------------------------------------------------
220     void
221     GetDeclContextDIEs (DWARFDIECollection &decl_context_dies) const;
222
223     void
224     GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const;
225
226     void
227     GetDWOContext (std::vector<lldb_private::CompilerContext> &context) const;
228
229     //----------------------------------------------------------------------
230     // Getting attribute values from the DIE.
231     //
232     // GetAttributeValueAsXXX() functions should only be used if you are
233     // looking for one or two attributes on a DIE. If you are trying to
234     // parse all attributes, use GetAttributes (...) instead
235     //----------------------------------------------------------------------
236     const char *
237     GetAttributeValueAsString (const dw_attr_t attr, const char *fail_value) const;
238
239     uint64_t
240     GetAttributeValueAsUnsigned (const dw_attr_t attr, uint64_t fail_value) const;
241
242     int64_t
243     GetAttributeValueAsSigned (const dw_attr_t attr, int64_t fail_value) const;
244
245     uint64_t
246     GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const;
247
248     uint64_t
249     GetAttributeValueAsAddress (const dw_attr_t attr, uint64_t fail_value) const;
250
251     size_t
252     GetAttributes (DWARFAttributes &attributes, uint32_t depth = 0) const;
253
254     bool
255     GetDIENamesAndRanges (const char * &name,
256                           const char * &mangled,
257                           DWARFRangeList& ranges,
258                           int& decl_file,
259                           int& decl_line,
260                           int& decl_column,
261                           int& call_file,
262                           int& call_line,
263                           int& call_column,
264                           lldb_private::DWARFExpression *frame_base) const;
265
266     //----------------------------------------------------------------------
267     // Pretty printing
268     //----------------------------------------------------------------------
269
270     void
271     Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const;
272
273 protected:
274     DWARFCompileUnit *m_cu;
275     DWARFDebugInfoEntry *m_die;
276 };
277
278 bool operator == (const DWARFDIE &lhs, const DWARFDIE &rhs);
279 bool operator != (const DWARFDIE &lhs, const DWARFDIE &rhs);
280
281 #endif  // SymbolFileDWARF_DWARFDIE_h_