LLDB  mainline
DWARFBaseDIE.cpp
Go to the documentation of this file.
1 //===-- DWARFBaseDIE.cpp ---------------------------------------*- C++ -*-===//
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 
18 using namespace lldb_private;
19 
21  if (!IsValid())
22  return DIERef();
23 
24  dw_offset_t cu_offset = m_cu->GetOffset();
25  if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
26  cu_offset = m_cu->GetBaseObjOffset();
27  return DIERef(cu_offset, m_die->GetOffset());
28 }
29 
31  if (m_die)
32  return m_die->Tag();
33  else
34  return 0;
35 }
36 
37 const char *DWARFBaseDIE::GetTagAsCString() const {
39 }
40 
42  const char *fail_value) const {
43  if (IsValid())
44  return m_die->GetAttributeValueAsString(GetDWARF(), GetCU(), attr,
45  fail_value);
46  else
47  return fail_value;
48 }
49 
51  uint64_t fail_value) const {
52  if (IsValid())
53  return m_die->GetAttributeValueAsUnsigned(GetDWARF(), GetCU(), attr,
54  fail_value);
55  else
56  return fail_value;
57 }
58 
60  uint64_t fail_value) const {
61  if (IsValid())
62  return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr,
63  fail_value);
64  else
65  return fail_value;
66 }
67 
69  uint64_t fail_value) const {
70  if (IsValid())
71  return m_die->GetAttributeValueAsAddress(GetDWARF(), GetCU(), attr,
72  fail_value);
73  else
74  return fail_value;
75 }
76 
78  return GetDIERef().GetUID(GetDWARF());
79 }
80 
81 const char *DWARFBaseDIE::GetName() const {
82  if (IsValid())
83  return m_die->GetName(GetDWARF(), m_cu);
84  else
85  return nullptr;
86 }
87 
89  if (IsValid())
90  return m_cu->GetLanguageType();
91  else
93 }
94 
95 lldb::ModuleSP DWARFBaseDIE::GetModule() const {
96  SymbolFileDWARF *dwarf = GetDWARF();
97  if (dwarf)
98  return dwarf->GetObjectFile()->GetModule();
99  else
100  return lldb::ModuleSP();
101 }
102 
104  if (IsValid())
105  return GetDWARF()->GetCompUnitForDWARFCompUnit(GetCU());
106  else
107  return nullptr;
108 }
109 
111  if (IsValid())
112  return m_die->GetOffset();
113  else
114  return DW_INVALID_OFFSET;
115 }
116 
118  if (m_cu)
119  return m_cu->GetSymbolFileDWARF();
120  else
121  return nullptr;
122 }
123 
125  if (m_cu)
126  return m_cu->GetTypeSystem();
127  else
128  return nullptr;
129 }
130 
132  lldb_private::TypeSystem *type_system = GetTypeSystem();
133  if (type_system)
134  return type_system->GetDWARFParser();
135  else
136  return nullptr;
137 }
138 
140  return m_die && m_die->HasChildren();
141 }
142 
144  return IsValid() && GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
145 }
146 
148  uint32_t depth) const {
149  if (IsValid()) {
150  return m_die->GetAttributes(m_cu, m_cu->GetFixedFormSizes(), attributes,
151  depth);
152  }
153  if (depth == 0)
154  attributes.Clear();
155  return 0;
156 }
157 
158 bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
159  return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
160 }
161 
162 bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
163  return !(lhs == rhs);
164 }
165 
167  // Clients must check if this DIE is valid before calling this function.
168  assert(IsValid());
169  return m_cu->GetData();
170 }
lldb::ModuleSP GetModule() const
DWARFASTParser * GetDWARFParser() const
lldb::LanguageType GetLanguage() const
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
SymbolFileDWARF * GetDWARF() const
size_t GetAttributes(DWARFAttributes &attributes, uint32_t depth=0) const
DWARFUnit * GetCU() const
Definition: DWARFBaseDIE.h:52
uint64_t GetAttributeValueAsReference(const dw_attr_t attr, uint64_t fail_value) const
uint64_t GetAttributeValueAsAddress(const dw_attr_t attr, uint64_t fail_value) const
Definition: DIERef.h:18
const char * GetTagAsCString() const
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:27
A class that describes a compilation unit.
Definition: CompileUnit.h:35
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:973
const char * GetAttributeValueAsString(const dw_attr_t attr, const char *fail_value) const
uint64_t user_id_t
Definition: lldb-types.h:84
LanguageType
Programming language type.
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const
DIERef GetDIERef() const
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:979
DWARFDebugInfoEntry * GetDIE() const
Definition: DWARFBaseDIE.h:54
virtual DWARFASTParser * GetDWARFParser()
Definition: TypeSystem.h:88
Unknown or invalid language value.
dw_tag_t Tag() const
ObjectFile * GetObjectFile()
Definition: SymbolFile.h:213
bool HasChildren() const
#define DW_INVALID_OFFSET
Definition: dwarf.h:34
lldb_private::TypeSystem * GetTypeSystem() const
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)
lldb_private::CompileUnit * GetLLDBCompileUnit() const