17#include "llvm/ADT/iterator.h"
28class ElaboratingDIEIterator
29 :
public llvm::iterator_facade_base<
30 ElaboratingDIEIterator, std::input_iterator_tag, DWARFDIE,
31 std::ptrdiff_t, DWARFDIE *, DWARFDIE *> {
39 llvm::SmallVector<DWARFDIE, 2> m_worklist;
40 llvm::SmallSet<DWARFDebugInfoEntry *, 3> m_seen;
43 assert(!m_worklist.empty() &&
"Incrementing end iterator?");
47 m_worklist.pop_back();
50 for (
dw_attr_t attr : {DW_AT_specification, DW_AT_abstract_origin}) {
52 if (m_seen.insert(die.
GetDIE()).second)
53 m_worklist.push_back(d);
59 explicit ElaboratingDIEIterator(
DWARFDIE d) : m_worklist(1, d) {}
62 ElaboratingDIEIterator() =
default;
65 ElaboratingDIEIterator &operator++() {
70 friend bool operator==(
const ElaboratingDIEIterator &a,
71 const ElaboratingDIEIterator &b) {
72 if (a.m_worklist.empty() || b.m_worklist.empty())
73 return a.m_worklist.empty() == b.m_worklist.empty();
74 return a.m_worklist.back() == b.m_worklist.back();
78llvm::iterator_range<ElaboratingDIEIterator>
79elaborating_dies(
const DWARFDIE &die) {
80 return llvm::make_range(ElaboratingDIEIterator(die),
81 ElaboratingDIEIterator());
129 const bool check_specification_or_abstract_origin =
true;
132 check_specification_or_abstract_origin))
144 bool check_children =
false;
145 bool match_addr_range =
false;
147 case DW_TAG_class_type:
148 case DW_TAG_namespace:
149 case DW_TAG_structure_type:
150 case DW_TAG_common_block:
151 check_children =
true;
153 case DW_TAG_compile_unit:
155 case DW_TAG_catch_block:
156 case DW_TAG_subprogram:
157 case DW_TAG_try_block:
158 case DW_TAG_partial_unit:
159 match_addr_range =
true;
161 case DW_TAG_lexical_block:
162 case DW_TAG_inlined_subroutine:
163 check_children =
true;
164 match_addr_range =
true;
170 if (match_addr_range) {
174 check_children =
true;
179 case DW_TAG_inlined_subroutine:
180 case DW_TAG_lexical_block:
185 check_children =
false;
189 if (check_children) {
247 case DW_TAG_array_type:
250 case DW_TAG_base_type:
253 case DW_TAG_class_type:
256 case DW_TAG_const_type:
259 case DW_TAG_enumeration_type:
262 case DW_TAG_file_type:
265 case DW_TAG_interface_type:
268 case DW_TAG_packed_type:
271 case DW_TAG_pointer_type:
273 case DW_TAG_ptr_to_member_type:
275 case DW_TAG_reference_type:
277 case DW_TAG_restrict_type:
280 case DW_TAG_set_type:
283 case DW_TAG_shared_type:
286 case DW_TAG_string_type:
289 case DW_TAG_structure_type:
292 case DW_TAG_subrange_type:
295 case DW_TAG_subroutine_type:
298 case DW_TAG_thrown_type:
301 case DW_TAG_union_type:
304 case DW_TAG_unspecified_type:
307 case DW_TAG_volatile_type:
310 case DW_TAG_LLVM_ptrauth_type: {
313 DW_AT_LLVM_ptrauth_address_discriminated, 0);
314 unsigned extraDiscriminator =
318 s.
Printf(
"__ptrauth(%d, %d, 0x0%x, %d)", key, isAddressDiscriminated,
319 extraDiscriminator, isaPointer);
328 next_die.AppendTypeName(s);
331 case DW_TAG_array_type:
334 case DW_TAG_pointer_type:
337 case DW_TAG_ptr_to_member_type:
340 case DW_TAG_reference_type:
357 return dwarf->ResolveTypeUID(die,
true);
365 std::vector<DWARFDIE> result;
368 result.push_back(std::move(parent));
378 if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
387 case DW_TAG_namespace:
390 case DW_TAG_structure_type:
393 case DW_TAG_union_type:
396 case DW_TAG_class_type:
399 case DW_TAG_enumeration_type:
402 case DW_TAG_subprogram:
406 case DW_TAG_variable:
428 return tag == DW_TAG_class_type || tag == DW_TAG_structure_type ||
429 tag == DW_TAG_union_type;
433 for (
DWARFDIE d : elaborating_dies(*
this))
434 if (d.GetParent().IsStructUnionOrClass())
441 std::optional<int> &decl_file, std::optional<int> &decl_line,
442 std::optional<int> &decl_column, std::optional<int> &call_file,
443 std::optional<int> &call_line, std::optional<int> &call_column,
447 GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column,
448 call_file, call_line, call_column, frame_base);
DWARFDebugInfoEntry * m_die
DWARFUnit * GetCU() const
SymbolFileDWARF * GetDWARF() const
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const
std::vector< DWARFDIE > GetDeclContextDIEs() const
DWARFDebugInfoEntry * GetDIE() const
DWARFDIE GetFirstChild() const
DWARFDIE GetParent() const
void GetDeclContext(llvm::SmallVectorImpl< lldb_private::CompilerContext > &context) const
Return this DIE's decl context as it is needed to look up types in Clang's -gmodules debug info forma...
const char * GetMangledName() const
DWARFDIE GetDIE(dw_offset_t die_offset) const
llvm::iterator_range< child_iterator > children() const
The range of all the children of this DIE.
DWARFDIE GetParentDeclContextDIE() const
bool IsStructUnionOrClass() const
lldb_private::Type * ResolveTypeUID(const DWARFDIE &die) const
DWARFDIE LookupDeepestBlock(lldb::addr_t file_addr) const
DWARFDIE GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const
DWARFDIE GetReferencedDIE(const dw_attr_t attr) const
lldb_private::Type * ResolveType() const
const char * GetName() const
bool GetDIENamesAndRanges(const char *&name, const char *&mangled, DWARFRangeList &ranges, std::optional< int > &decl_file, std::optional< int > &decl_line, std::optional< int > &decl_column, std::optional< int > &call_file, std::optional< int > &call_line, std::optional< int > &call_column, lldb_private::DWARFExpressionList *frame_base) const
void AppendTypeName(lldb_private::Stream &s) const
const char * GetPubname() const
DWARFDIE GetSibling() const
const char * GetAttributeValueAsString(const DWARFUnit *cu, const dw_attr_t attr, const char *fail_value, bool check_specification_or_abstract_origin=false) const
dw_offset_t GetAttributeValue(const DWARFUnit *cu, const dw_attr_t attr, DWARFFormValue &formValue, dw_offset_t *end_attr_offset_ptr=nullptr, bool check_specification_or_abstract_origin=false) const
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const
bool GetDIENamesAndRanges(DWARFUnit *cu, const char *&name, const char *&mangled, DWARFRangeList &rangeList, std::optional< int > &decl_file, std::optional< int > &decl_line, std::optional< int > &decl_column, std::optional< int > &call_file, std::optional< int > &call_line, std::optional< int > &call_column, lldb_private::DWARFExpressionList *frame_base=nullptr) const
const char * GetMangledName(const DWARFUnit *cu, bool substitute_name_allowed=true) const
DWARFDIE GetAttributeValueAsReference(const DWARFUnit *cu, const dw_attr_t attr, bool check_specification_or_abstract_origin=false) const
const char * GetPubname(const DWARFUnit *cu) const
DWARFDebugInfoEntry * GetFirstChild()
DWARFDebugInfoEntry * GetSibling()
DWARFRangeList GetAttributeAddressRanges(DWARFUnit *cu, bool check_hi_lo_pc, bool check_specification_or_abstract_origin=false) const
DWARFDebugInfoEntry * GetParent()
DWARFDIE GetDIE(dw_offset_t die_offset)
lldb_private::Type * ResolveType(const DWARFDIE &die, bool assert_not_being_parsed=true, bool resolve_function_context=false)
A uniqued constant string class.
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
const Entry * FindEntryThatContains(B addr) const
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
llvm::dwarf::Tag dw_tag_t
llvm::dwarf::Attribute dw_attr_t
A class that represents a running process on the host machine.
const Scalar operator*(Scalar lhs, Scalar rhs)
bool operator==(const Address &lhs, const Address &rhs)