1 //===-- DWARFDebugInfoEntry.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_DWARFDebugInfoEntry_h_
11 #define SymbolFileDWARF_DWARFDebugInfoEntry_h_
13 #include "SymbolFileDWARF.h"
14 #include "llvm/ADT/SmallVector.h"
16 #include "DWARFDebugAbbrev.h"
17 #include "DWARFAbbreviationDeclaration.h"
18 #include "DWARFDebugRanges.h"
23 typedef std::map<const DWARFDebugInfoEntry*, dw_addr_t> DIEToAddressMap;
24 typedef DIEToAddressMap::iterator DIEToAddressMapIter;
25 typedef DIEToAddressMap::const_iterator DIEToAddressMapConstIter;
27 typedef std::map<dw_addr_t, const DWARFDebugInfoEntry*> AddressToDIEMap;
28 typedef AddressToDIEMap::iterator AddressToDIEMapIter;
29 typedef AddressToDIEMap::const_iterator AddressToDIEMapConstIter;
32 typedef std::map<dw_offset_t, dw_offset_t> DIEToDIEMap;
33 typedef DIEToDIEMap::iterator DIEToDIEMapIter;
34 typedef DIEToDIEMap::const_iterator DIEToDIEMapConstIter;
36 typedef std::map<uint32_t, const DWARFDebugInfoEntry*> UInt32ToDIEMap;
37 typedef UInt32ToDIEMap::iterator UInt32ToDIEMapIter;
38 typedef UInt32ToDIEMap::const_iterator UInt32ToDIEMapConstIter;
40 typedef std::multimap<uint32_t, const DWARFDebugInfoEntry*> UInt32ToDIEMMap;
41 typedef UInt32ToDIEMMap::iterator UInt32ToDIEMMapIter;
42 typedef UInt32ToDIEMMap::const_iterator UInt32ToDIEMMapConstIter;
44 class DWARFDeclContext;
46 #define DIE_SIBLING_IDX_BITSIZE 31
47 #define DIE_ABBR_IDX_BITSIZE 15
49 class DWARFDebugInfoEntry
52 typedef std::vector<DWARFDebugInfoEntry> collection;
53 typedef collection::iterator iterator;
54 typedef collection::const_iterator const_iterator;
56 typedef std::vector<dw_offset_t> offset_collection;
57 typedef offset_collection::iterator offset_collection_iterator;
58 typedef offset_collection::const_iterator offset_collection_const_iterator;
60 DWARFDebugInfoEntry():
61 m_offset (DW_INVALID_OFFSET),
64 m_empty_children(false),
66 m_has_children (false),
73 m_offset = DW_INVALID_OFFSET;
76 m_empty_children = false;
78 m_has_children = false;
82 bool Contains (const DWARFDebugInfoEntry *die) const;
84 void BuildAddressRangeTable(
85 SymbolFileDWARF* dwarf2Data,
86 const DWARFCompileUnit* cu,
87 DWARFDebugAranges* debug_aranges) const;
89 void BuildFunctionAddressRangeTable(
90 SymbolFileDWARF* dwarf2Data,
91 const DWARFCompileUnit* cu,
92 DWARFDebugAranges* debug_aranges) const;
95 const lldb_private::DWARFDataExtractor& debug_info_data,
96 const DWARFCompileUnit* cu,
97 const DWARFFormValue::FixedFormSizes& fixed_form_sizes,
98 lldb::offset_t* offset_ptr);
101 SymbolFileDWARF* dwarf2Data,
102 const DWARFCompileUnit* cu,
103 lldb::offset_t* offset_ptr);
106 const dw_addr_t address,
107 SymbolFileDWARF* dwarf2Data,
108 const DWARFCompileUnit* cu,
109 DWARFDebugInfoEntry** function_die,
110 DWARFDebugInfoEntry** block_die);
112 size_t GetAttributes(
113 const DWARFCompileUnit* cu,
114 DWARFFormValue::FixedFormSizes fixed_form_sizes,
115 DWARFAttributes& attrs,
116 uint32_t curr_depth = 0) const; // "curr_depth" for internal use only, don't set this yourself!!!
118 dw_offset_t GetAttributeValue(SymbolFileDWARF* dwarf2Data,
119 const DWARFCompileUnit* cu,
120 const dw_attr_t attr,
121 DWARFFormValue& formValue,
122 dw_offset_t* end_attr_offset_ptr = nullptr,
123 bool check_specification_or_abstract_origin = false) const;
125 const char* GetAttributeValueAsString(
126 SymbolFileDWARF* dwarf2Data,
127 const DWARFCompileUnit* cu,
128 const dw_attr_t attr,
129 const char* fail_value,
130 bool check_specification_or_abstract_origin = false) const;
132 uint64_t GetAttributeValueAsUnsigned(
133 SymbolFileDWARF* dwarf2Data,
134 const DWARFCompileUnit* cu,
135 const dw_attr_t attr,
137 bool check_specification_or_abstract_origin = false) const;
139 uint64_t GetAttributeValueAsReference(
140 SymbolFileDWARF* dwarf2Data,
141 const DWARFCompileUnit* cu,
142 const dw_attr_t attr,
144 bool check_specification_or_abstract_origin = false) const;
146 int64_t GetAttributeValueAsSigned(
147 SymbolFileDWARF* dwarf2Data,
148 const DWARFCompileUnit* cu,
149 const dw_attr_t attr,
151 bool check_specification_or_abstract_origin = false) const;
153 uint64_t GetAttributeValueAsAddress(
154 SymbolFileDWARF* dwarf2Data,
155 const DWARFCompileUnit* cu,
156 const dw_attr_t attr,
158 bool check_specification_or_abstract_origin = false) const;
160 dw_addr_t GetAttributeHighPC(
161 SymbolFileDWARF* dwarf2Data,
162 const DWARFCompileUnit* cu,
165 bool check_specification_or_abstract_origin = false) const;
167 bool GetAttributeAddressRange(
168 SymbolFileDWARF* dwarf2Data,
169 const DWARFCompileUnit* cu,
173 bool check_specification_or_abstract_origin = false) const;
175 size_t GetAttributeAddressRanges (
176 SymbolFileDWARF* dwarf2Data,
177 const DWARFCompileUnit* cu,
178 DWARFRangeList &ranges,
180 bool check_specification_or_abstract_origin = false) const;
183 SymbolFileDWARF* dwarf2Data,
184 const DWARFCompileUnit* cu) const;
186 const char* GetMangledName(
187 SymbolFileDWARF* dwarf2Data,
188 const DWARFCompileUnit* cu,
189 bool substitute_name_allowed = true) const;
191 const char* GetPubname(
192 SymbolFileDWARF* dwarf2Data,
193 const DWARFCompileUnit* cu) const;
196 SymbolFileDWARF* dwarf2Data,
197 const DWARFCompileUnit* cu,
198 const dw_offset_t die_offset,
199 lldb_private::Stream &s);
201 static bool AppendTypeName(
202 SymbolFileDWARF* dwarf2Data,
203 const DWARFCompileUnit* cu,
204 const dw_offset_t die_offset,
205 lldb_private::Stream &s);
207 const char * GetQualifiedName (
208 SymbolFileDWARF* dwarf2Data,
209 DWARFCompileUnit* cu,
210 std::string &storage) const;
212 const char * GetQualifiedName (
213 SymbolFileDWARF* dwarf2Data,
214 DWARFCompileUnit* cu,
215 const DWARFAttributes& attributes,
216 std::string &storage) const;
218 static bool OffsetLessThan (
219 const DWARFDebugInfoEntry& a,
220 const DWARFDebugInfoEntry& b);
223 SymbolFileDWARF* dwarf2Data,
224 const DWARFCompileUnit* cu,
225 lldb_private::Stream &s,
226 uint32_t recurse_depth) const;
229 SymbolFileDWARF* dwarf2Data,
230 const DWARFCompileUnit* cu,
231 const DWARFDebugInfoEntry* oldest,
232 lldb_private::Stream &s,
233 uint32_t recurse_depth) const;
235 static void DumpAttribute(
236 SymbolFileDWARF* dwarf2Data,
237 const DWARFCompileUnit* cu,
238 const lldb_private::DWARFDataExtractor& debug_info_data,
239 lldb::offset_t *offset_ptr,
240 lldb_private::Stream &s,
243 // This one dumps the comp unit name, objfile name and die offset for this die so the stream S.
245 SymbolFileDWARF* dwarf2Data,
246 DWARFCompileUnit* cu,
247 lldb_private::Stream &s) const;
249 bool GetDIENamesAndRanges(
250 SymbolFileDWARF* dwarf2Data,
251 const DWARFCompileUnit* cu,
253 const char * &mangled,
254 DWARFRangeList& rangeList,
261 lldb_private::DWARFExpression *frame_base = NULL) const;
263 const DWARFAbbreviationDeclaration*
264 GetAbbreviationDeclarationPtr (SymbolFileDWARF* dwarf2Data,
265 const DWARFCompileUnit *cu,
266 lldb::offset_t &offset) const;
277 return m_abbr_idx == 0;
287 SetOffset (dw_offset_t offset)
295 return m_has_children;
299 SetHasChildren (bool b)
304 // We know we are kept in a vector of contiguous entries, so we know
305 // our parent will be some index behind "this".
306 DWARFDebugInfoEntry* GetParent() { return m_parent_idx > 0 ? this - m_parent_idx : NULL; }
307 const DWARFDebugInfoEntry* GetParent() const { return m_parent_idx > 0 ? this - m_parent_idx : NULL; }
308 // We know we are kept in a vector of contiguous entries, so we know
309 // our sibling will be some index after "this".
310 DWARFDebugInfoEntry* GetSibling() { return m_sibling_idx > 0 ? this + m_sibling_idx : NULL; }
311 const DWARFDebugInfoEntry* GetSibling() const { return m_sibling_idx > 0 ? this + m_sibling_idx : NULL; }
312 // We know we are kept in a vector of contiguous entries, so we know
313 // we don't need to store our child pointer, if we have a child it will
314 // be the next entry in the list...
315 DWARFDebugInfoEntry* GetFirstChild() { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; }
316 const DWARFDebugInfoEntry* GetFirstChild() const { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; }
319 void GetDeclContextDIEs (DWARFCompileUnit* cu,
320 DWARFDIECollection &decl_context_dies) const;
322 void GetDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
323 DWARFCompileUnit* cu,
324 DWARFDeclContext &dwarf_decl_ctx) const;
327 bool MatchesDWARFDeclContext(SymbolFileDWARF* dwarf2Data,
328 DWARFCompileUnit* cu,
329 const DWARFDeclContext &dwarf_decl_ctx) const;
331 DWARFDIE GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
332 DWARFCompileUnit* cu) const;
333 DWARFDIE GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
334 DWARFCompileUnit* cu,
335 const DWARFAttributes& attributes) const;
338 SetParent (DWARFDebugInfoEntry* parent)
342 // We know we are kept in a vector of contiguous entries, so we know
343 // our parent will be some index behind "this".
344 m_parent_idx = this - parent;
350 SetSibling (DWARFDebugInfoEntry* sibling)
354 // We know we are kept in a vector of contiguous entries, so we know
355 // our sibling will be some index after "this".
356 m_sibling_idx = sibling - this;
357 sibling->SetParent(GetParent());
364 SetSiblingIndex (uint32_t idx)
370 SetParentIndex (uint32_t idx)
376 GetEmptyChildren () const
378 return m_empty_children;
382 SetEmptyChildren (bool b)
384 m_empty_children = b;
388 DumpDIECollection (lldb_private::Stream &strm,
389 DWARFDebugInfoEntry::collection &die_collection);
393 dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry
394 uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. If zero this die has no parent
395 uint32_t m_sibling_idx:31, // How many to add to "this" to get the sibling.
396 m_empty_children:1; // If a DIE says it had children, yet it just contained a NULL tag, this will be set.
397 uint32_t m_abbr_idx:DIE_ABBR_IDX_BITSIZE,
398 m_has_children:1, // Set to 1 if this DIE has children
399 m_tag:16; // A copy of the DW_TAG value so we don't have to go through the compile unit abbrev table
402 #endif // SymbolFileDWARF_DWARFDebugInfoEntry_h_