17#include "llvm/ADT/iterator.h"
29class ElaboratingDIEIterator
30 :
public llvm::iterator_facade_base<
31 ElaboratingDIEIterator, std::input_iterator_tag, DWARFDIE,
32 std::ptrdiff_t, DWARFDIE *, DWARFDIE *> {
40 llvm::SmallVector<DWARFDIE, 2> m_worklist;
41 llvm::SmallSet<DWARFDebugInfoEntry *, 3> m_seen;
44 assert(!m_worklist.empty() &&
"Incrementing end iterator?");
48 m_worklist.pop_back();
51 for (
dw_attr_t attr : {DW_AT_specification, DW_AT_abstract_origin}) {
53 if (m_seen.insert(die.
GetDIE()).second)
54 m_worklist.push_back(d);
60 explicit ElaboratingDIEIterator(
DWARFDIE d) : m_worklist(1, d) {}
63 ElaboratingDIEIterator() =
default;
66 ElaboratingDIEIterator &operator++() {
71 friend bool operator==(
const ElaboratingDIEIterator &a,
72 const ElaboratingDIEIterator &b) {
73 if (a.m_worklist.empty() || b.m_worklist.empty())
74 return a.m_worklist.empty() == b.m_worklist.empty();
75 return a.m_worklist.back() == b.m_worklist.back();
79llvm::iterator_range<ElaboratingDIEIterator>
80elaborating_dies(
const DWARFDIE &die) {
81 return llvm::make_range(ElaboratingDIEIterator(die),
82 ElaboratingDIEIterator());
130 const bool check_specification_or_abstract_origin =
true;
133 check_specification_or_abstract_origin))
145 bool check_children =
false;
146 bool match_addr_range =
false;
148 case DW_TAG_class_type:
149 case DW_TAG_namespace:
150 case DW_TAG_structure_type:
151 case DW_TAG_common_block:
152 check_children =
true;
154 case DW_TAG_compile_unit:
156 case DW_TAG_catch_block:
157 case DW_TAG_subprogram:
158 case DW_TAG_try_block:
159 case DW_TAG_partial_unit:
160 match_addr_range =
true;
162 case DW_TAG_lexical_block:
163 case DW_TAG_inlined_subroutine:
164 check_children =
true;
165 match_addr_range =
true;
171 if (match_addr_range) {
175 check_children =
true;
180 case DW_TAG_inlined_subroutine:
181 case DW_TAG_lexical_block:
186 check_children =
false;
190 if (check_children) {
248 case DW_TAG_array_type:
251 case DW_TAG_base_type:
254 case DW_TAG_class_type:
257 case DW_TAG_const_type:
260 case DW_TAG_enumeration_type:
263 case DW_TAG_file_type:
266 case DW_TAG_interface_type:
269 case DW_TAG_packed_type:
272 case DW_TAG_pointer_type:
274 case DW_TAG_ptr_to_member_type:
276 case DW_TAG_reference_type:
278 case DW_TAG_restrict_type:
281 case DW_TAG_set_type:
284 case DW_TAG_shared_type:
287 case DW_TAG_string_type:
290 case DW_TAG_structure_type:
293 case DW_TAG_subrange_type:
296 case DW_TAG_subroutine_type:
299 case DW_TAG_thrown_type:
302 case DW_TAG_union_type:
305 case DW_TAG_unspecified_type:
308 case DW_TAG_volatile_type:
311 case DW_TAG_LLVM_ptrauth_type: {
314 DW_AT_LLVM_ptrauth_address_discriminated, 0);
315 unsigned extraDiscriminator =
320 DW_AT_LLVM_ptrauth_authenticates_null_values, 0);
321 unsigned authenticationMode =
324 s.
Printf(
"__ptrauth(%d, %d, 0x0%x, %d, %d, %d)", key,
325 isAddressDiscriminated, extraDiscriminator, isaPointer,
326 authenticatesNullValues, authenticationMode);
335 next_die.AppendTypeName(s);
338 case DW_TAG_array_type:
341 case DW_TAG_pointer_type:
344 case DW_TAG_ptr_to_member_type:
347 case DW_TAG_reference_type:
364 return dwarf->ResolveTypeUID(die,
true);
372 std::vector<DWARFDIE> result;
375 result.push_back(std::move(parent));
382static std::vector<lldb_private::CompilerContext>
384 std::vector<lldb_private::CompilerContext> context;
386 if (!die || !seen.insert(die.
GetID()).second)
404 case DW_TAG_namespace:
407 case DW_TAG_structure_type:
410 case DW_TAG_union_type:
413 case DW_TAG_class_type:
416 case DW_TAG_enumeration_type:
419 case DW_TAG_subprogram:
422 case DW_TAG_variable:
435 llvm::SmallSet<lldb::user_id_t, 4> seen;
439std::vector<lldb_private::CompilerContext>
441 std::vector<lldb_private::CompilerContext> context;
445 if (!name || !name[0])
448 if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
457 case DW_TAG_namespace:
460 case DW_TAG_structure_type:
463 case DW_TAG_union_type:
466 case DW_TAG_class_type:
469 case DW_TAG_enumeration_type:
472 case DW_TAG_variable:
478 case DW_TAG_base_type:
497 return tag == DW_TAG_class_type || tag == DW_TAG_structure_type ||
498 tag == DW_TAG_union_type;
502 for (
DWARFDIE d : elaborating_dies(*
this))
503 if (d.GetParent().IsStructUnionOrClass())
510 std::optional<int> &decl_file, std::optional<int> &decl_line,
511 std::optional<int> &decl_column, std::optional<int> &call_file,
512 std::optional<int> &call_line, std::optional<int> &call_column,
516 GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column,
517 call_file, call_line, call_column, frame_base);
static std::vector< lldb_private::CompilerContext > GetDeclContextImpl(llvm::SmallSet< lldb::user_id_t, 4 > &seen, DWARFDIE die)
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.
SymbolFileDWARF * GetDWARF() const
DWARFDebugInfoEntry * m_die
DWARFUnit * GetCU() const
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const
lldb::user_id_t GetID() const
void GetName(Stream &s) const
std::vector< DWARFDIE > GetDeclContextDIEs() const
std::vector< CompilerContext > GetTypeLookupContext() const
Get a context to a type so it can be looked up.
DWARFDIE GetFirstChild() const
DWARFDIE GetParent() const
const char * GetMangledName() const
std::vector< CompilerContext > GetDeclContext() const
Return this DIE's decl context as it is needed to look up types in Clang modules.
DWARFDIE GetDIE(dw_offset_t die_offset) const
llvm::iterator_range< child_iterator > children() const
The range of all the children of this DIE.
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, DWARFExpressionList *frame_base) const
DWARFDIE GetParentDeclContextDIE() const
bool IsStructUnionOrClass() const
Type * ResolveTypeUID(const DWARFDIE &die) const
DWARFDIE LookupDeepestBlock(lldb::addr_t file_addr) const
DWARFDIE GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const
DWARFDebugInfoEntry * GetDIE() const
void AppendTypeName(Stream &s) const
DWARFDIE GetReferencedDIE(const dw_attr_t attr) const
Type * ResolveType() const
const char * GetName() 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
const char * GetMangledName(const DWARFUnit *cu, bool substitute_name_allowed=true) const
DWARFDebugInfoEntry * GetSibling()
DWARFDebugInfoEntry * GetParent()
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
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, DWARFExpressionList *frame_base=nullptr) const
DWARFDebugInfoEntry * GetFirstChild()
DWARFRangeList GetAttributeAddressRanges(DWARFUnit *cu, bool check_hi_lo_pc, bool check_specification_or_abstract_origin=false) const
DWARFDIE GetDIE(dw_offset_t die_offset)
Type * ResolveType(const DWARFDIE &die, bool assert_not_being_parsed=true, bool resolve_function_context=false)
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)