LLDB  mainline
DWARFBaseDIE.cpp
Go to the documentation of this file.
1 //===-- DWARFBaseDIE.cpp --------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "DWARFBaseDIE.h"
10 
11 #include "DWARFUnit.h"
12 #include "DWARFDebugInfoEntry.h"
13 #include "SymbolFileDWARF.h"
14 
15 #include "lldb/Core/Module.h"
16 #include "lldb/Symbol/ObjectFile.h"
17 #include "lldb/Utility/Log.h"
18 
19 using namespace lldb_private;
20 
21 llvm::Optional<DIERef> DWARFBaseDIE::GetDIERef() const {
22  if (!IsValid())
23  return llvm::None;
24 
25  return DIERef(m_cu->GetSymbolFileDWARF().GetDwoNum(), m_cu->GetDebugSection(),
26  m_die->GetOffset());
27 }
28 
30  if (m_die)
31  return m_die->Tag();
32  else
33  return llvm::dwarf::DW_TAG_null;
34 }
35 
36 const char *DWARFBaseDIE::GetTagAsCString() const {
38 }
39 
41  const char *fail_value) const {
42  if (IsValid())
43  return m_die->GetAttributeValueAsString(GetCU(), attr, fail_value);
44  else
45  return fail_value;
46 }
47 
49  uint64_t fail_value) const {
50  if (IsValid())
51  return m_die->GetAttributeValueAsUnsigned(GetCU(), attr, fail_value);
52  else
53  return fail_value;
54 }
55 
57  uint64_t fail_value) const {
58  if (IsValid())
59  return m_die->GetAttributeValueAsAddress(GetCU(), attr, fail_value);
60  else
61  return fail_value;
62 }
63 
65  if (IsValid())
66  return GetDWARF()->GetUID(*this);
67  return LLDB_INVALID_UID;
68 }
69 
70 const char *DWARFBaseDIE::GetName() const {
71  if (IsValid())
72  return m_die->GetName(m_cu);
73  else
74  return nullptr;
75 }
76 
77 lldb::ModuleSP DWARFBaseDIE::GetModule() const {
78  SymbolFileDWARF *dwarf = GetDWARF();
79  if (dwarf)
80  return dwarf->GetObjectFile()->GetModule();
81  else
82  return lldb::ModuleSP();
83 }
84 
86  if (IsValid())
87  return m_die->GetOffset();
88  else
89  return DW_INVALID_OFFSET;
90 }
91 
93  if (m_cu)
94  return &m_cu->GetSymbolFileDWARF();
95  else
96  return nullptr;
97 }
98 
100  return m_die && m_die->HasChildren();
101 }
102 
104  return IsValid() && GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
105 }
106 
108  Recurse recurse) const {
109  if (IsValid())
110  return m_die->GetAttributes(m_cu, attributes, recurse);
111  attributes.Clear();
112  return 0;
113 }
114 
115 bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
116  return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
117 }
118 
119 bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
120  return !(lhs == rhs);
121 }
122 
124  // Clients must check if this DIE is valid before calling this function.
125  assert(IsValid());
126  return m_cu->GetData();
127 }
lldb::ModuleSP GetModule() const
A class that represents a running process on the host machine.
SymbolFileDWARF * GetDWARF() const
DWARFUnit * GetCU() const
Definition: DWARFBaseDIE.h:54
Identifies a DWARF debug info entry within a given Module.
Definition: DIERef.h:26
uint64_t GetAttributeValueAsAddress(const dw_attr_t attr, uint64_t fail_value) const
#define LLDB_INVALID_UID
Definition: lldb-defines.h:91
const char * GetTagAsCString() const
llvm::Optional< DIERef > GetDIERef() const
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
size_t GetAttributes(DWARFAttributes &attributes, Recurse recurse=Recurse::yes) const
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:986
const char * GetAttributeValueAsString(const dw_attr_t attr, const char *fail_value) const
uint64_t user_id_t
Definition: lldb-types.h:84
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const
llvm::dwarf::Tag dw_tag_t
Definition: dwarf.h:25
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:992
DWARFDebugInfoEntry * GetDIE() const
Definition: DWARFBaseDIE.h:56
dw_tag_t Tag() const
ObjectFile * GetObjectFile()
Definition: SymbolFile.h:265
bool HasChildren() const
#define DW_INVALID_OFFSET
Definition: dwarf.h:34
dw_offset_t GetOffset() const
const char * GetName() const
bool Supports_DW_AT_APPLE_objc_complete_type() const
const lldb_private::DWARFDataExtractor & GetData() const
lldb::user_id_t GetID() const
const char * DW_TAG_value_to_name(uint32_t val)