]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
Upgrade NetBSD tests to 01.11.2017_23.20 snapshot
[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     explicit 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     //----------------------------------------------------------------------
184     // Resolve a type by UID using this DIE's DWARF file
185     //----------------------------------------------------------------------
186     lldb_private::Type *
187     ResolveTypeUID (const DIERef &die_ref) const;
188
189     //----------------------------------------------------------------------
190     // Functions for obtaining DIE relations and references
191     //----------------------------------------------------------------------
192
193     DWARFDIE
194     GetParent () const;
195
196     DWARFDIE
197     GetFirstChild () const;
198
199     DWARFDIE
200     GetSibling () const;
201
202     DWARFDIE
203     GetReferencedDIE (const dw_attr_t attr) const;
204
205     //----------------------------------------------------------------------
206     // Get a another DIE from the same DWARF file as this DIE. This will
207     // check the current DIE's compile unit first to see if "die_offset" is
208     // in the same compile unit, and fall back to checking the DWARF file.
209     //----------------------------------------------------------------------
210     DWARFDIE
211     GetDIE (dw_offset_t die_offset) const;
212
213     DWARFDIE
214     LookupDeepestBlock (lldb::addr_t file_addr) const;
215
216     DWARFDIE
217     GetParentDeclContextDIE () const;
218
219     //----------------------------------------------------------------------
220     // DeclContext related functions
221     //----------------------------------------------------------------------
222     void
223     GetDeclContextDIEs (DWARFDIECollection &decl_context_dies) const;
224
225     void
226     GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const;
227
228     void
229     GetDWOContext (std::vector<lldb_private::CompilerContext> &context) const;
230
231     //----------------------------------------------------------------------
232     // Getting attribute values from the DIE.
233     //
234     // GetAttributeValueAsXXX() functions should only be used if you are
235     // looking for one or two attributes on a DIE. If you are trying to
236     // parse all attributes, use GetAttributes (...) instead
237     //----------------------------------------------------------------------
238     const char *
239     GetAttributeValueAsString (const dw_attr_t attr, const char *fail_value) const;
240
241     uint64_t
242     GetAttributeValueAsUnsigned (const dw_attr_t attr, uint64_t fail_value) const;
243
244     int64_t
245     GetAttributeValueAsSigned (const dw_attr_t attr, int64_t fail_value) const;
246
247     uint64_t
248     GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const;
249
250     DWARFDIE
251     GetAttributeValueAsReferenceDIE (const dw_attr_t attr) const;
252
253     uint64_t
254     GetAttributeValueAsAddress (const dw_attr_t attr, uint64_t fail_value) const;
255
256     size_t
257     GetAttributes (DWARFAttributes &attributes, uint32_t depth = 0) const;
258
259     bool
260     GetDIENamesAndRanges (const char * &name,
261                           const char * &mangled,
262                           DWARFRangeList& ranges,
263                           int& decl_file,
264                           int& decl_line,
265                           int& decl_column,
266                           int& call_file,
267                           int& call_line,
268                           int& call_column,
269                           lldb_private::DWARFExpression *frame_base) const;
270
271     //----------------------------------------------------------------------
272     // Pretty printing
273     //----------------------------------------------------------------------
274
275     void
276     Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const;
277
278     lldb_private::CompilerDecl
279     GetDecl () const;
280
281     lldb_private::CompilerDeclContext
282     GetDeclContext() const;
283
284     lldb_private::CompilerDeclContext
285     GetContainingDeclContext() const;
286
287 protected:
288     DWARFCompileUnit *m_cu;
289     DWARFDebugInfoEntry *m_die;
290 };
291
292 bool operator == (const DWARFDIE &lhs, const DWARFDIE &rhs);
293 bool operator != (const DWARFDIE &lhs, const DWARFDIE &rhs);
294
295 #endif  // SymbolFileDWARF_DWARFDIE_h_