1 //===-- DWARFBaseDIE.h -----------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H
12 #include "lldb/Core/dwarf.h"
13 #include "lldb/lldb-types.h"
15 #include "llvm/Support/Error.h"
19 class DWARFAttributes;
21 class DWARFDebugInfoEntry;
22 class DWARFDeclContext;
23 class SymbolFileDWARF;
27 DWARFBaseDIE() : m_cu(nullptr), m_die(nullptr) {}
29 DWARFBaseDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die)
30 : m_cu(cu), m_die(die) {}
32 DWARFBaseDIE(const DWARFUnit *cu, DWARFDebugInfoEntry *die)
33 : m_cu(const_cast<DWARFUnit *>(cu)), m_die(die) {}
35 DWARFBaseDIE(DWARFUnit *cu, const DWARFDebugInfoEntry *die)
36 : m_cu(cu), m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
38 DWARFBaseDIE(const DWARFUnit *cu, const DWARFDebugInfoEntry *die)
39 : m_cu(const_cast<DWARFUnit *>(cu)),
40 m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
43 explicit operator bool() const { return IsValid(); }
45 bool IsValid() const { return m_cu && m_die; }
47 bool HasChildren() const;
49 bool Supports_DW_AT_APPLE_objc_complete_type() const;
52 SymbolFileDWARF *GetDWARF() const;
54 DWARFUnit *GetCU() const { return m_cu; }
56 DWARFDebugInfoEntry *GetDIE() const { return m_die; }
58 llvm::Optional<DIERef> GetDIERef() const;
60 void Set(DWARFUnit *cu, DWARFDebugInfoEntry *die) {
74 // Get the data that contains the attribute values for this DIE. Support
75 // for .debug_types means that any DIE can have its data either in the
76 // .debug_info or the .debug_types section; this method will return the
77 // correct section data.
79 // Clients must validate that this object is valid before calling this.
80 const lldb_private::DWARFDataExtractor &GetData() const;
82 // Accessing information about a DIE
85 const char *GetTagAsCString() const;
87 dw_offset_t GetOffset() const;
89 // Get the LLDB user ID for this DIE. This is often just the DIE offset,
90 // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
91 // we are doing Darwin DWARF in .o file, or DWARF stand alone debug
93 lldb::user_id_t GetID() const;
95 const char *GetName() const;
97 lldb::ModuleSP GetModule() const;
99 // Getting attribute values from the DIE.
101 // GetAttributeValueAsXXX() functions should only be used if you are
102 // looking for one or two attributes on a DIE. If you are trying to
103 // parse all attributes, use GetAttributes (...) instead
104 const char *GetAttributeValueAsString(const dw_attr_t attr,
105 const char *fail_value) const;
107 uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr,
108 uint64_t fail_value) const;
110 uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,
111 uint64_t fail_value) const;
113 enum class Recurse : bool { no, yes };
114 size_t GetAttributes(DWARFAttributes &attributes,
115 Recurse recurse = Recurse::yes) const;
119 DWARFDebugInfoEntry *m_die;
122 bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);
123 bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);
125 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H