Coverage Report

Created: 2023-11-11 10:31

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
Line
Count
Source (jump to first uncovered line)
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
#include <optional>
19
20
using namespace lldb_private;
21
using namespace lldb_private::plugin::dwarf;
22
23
1.63M
std::optional<DIERef> DWARFBaseDIE::GetDIERef() const {
24
1.63M
  if (!IsValid())
25
5.24k
    return std::nullopt;
26
27
1.62M
  return DIERef(m_cu->GetSymbolFileDWARF().GetFileIndex(),
28
1.62M
                m_cu->GetDebugSection(), m_die->GetOffset());
29
1.63M
}
30
31
3.73M
dw_tag_t DWARFBaseDIE::Tag() const {
32
3.73M
  if (m_die)
33
3.73M
    return m_die->Tag();
34
17
  else
35
17
    return llvm::dwarf::DW_TAG_null;
36
3.73M
}
37
38
14
const char *DWARFBaseDIE::GetTagAsCString() const {
39
14
  return DW_TAG_value_to_name(Tag());
40
14
}
41
42
const char *DWARFBaseDIE::GetAttributeValueAsString(const dw_attr_t attr,
43
3.72k
                                                const char *fail_value) const {
44
3.72k
  if (IsValid())
45
3.72k
    return m_die->GetAttributeValueAsString(GetCU(), attr, fail_value);
46
0
  else
47
0
    return fail_value;
48
3.72k
}
49
50
uint64_t DWARFBaseDIE::GetAttributeValueAsUnsigned(const dw_attr_t attr,
51
146k
                                               uint64_t fail_value) const {
52
146k
  if (IsValid())
53
146k
    return m_die->GetAttributeValueAsUnsigned(GetCU(), attr, fail_value);
54
169
  else
55
169
    return fail_value;
56
146k
}
57
58
std::optional<uint64_t>
59
258
DWARFBaseDIE::GetAttributeValueAsOptionalUnsigned(const dw_attr_t attr) const {
60
258
  if (IsValid())
61
258
    return m_die->GetAttributeValueAsOptionalUnsigned(GetCU(), attr);
62
0
  return std::nullopt;
63
258
}
64
65
uint64_t DWARFBaseDIE::GetAttributeValueAsAddress(const dw_attr_t attr,
66
0
                                              uint64_t fail_value) const {
67
0
  if (IsValid())
68
0
    return m_die->GetAttributeValueAsAddress(GetCU(), attr, fail_value);
69
0
  else
70
0
    return fail_value;
71
0
}
72
73
1.42M
lldb::user_id_t DWARFBaseDIE::GetID() const {
74
1.42M
  const std::optional<DIERef> &ref = this->GetDIERef();
75
1.42M
  if (ref)
76
1.41M
    return ref->get_id();
77
78
5.24k
  return LLDB_INVALID_UID;
79
1.42M
}
80
81
56.7k
const char *DWARFBaseDIE::GetName() const {
82
56.7k
  if (IsValid())
83
56.7k
    return m_die->GetName(m_cu);
84
0
  else
85
0
    return nullptr;
86
56.7k
}
87
88
6.52k
lldb::ModuleSP DWARFBaseDIE::GetModule() const {
89
6.52k
  SymbolFileDWARF *dwarf = GetDWARF();
90
6.52k
  if (dwarf)
91
6.52k
    return dwarf->GetObjectFile()->GetModule();
92
0
  else
93
0
    return lldb::ModuleSP();
94
6.52k
}
95
96
777
dw_offset_t DWARFBaseDIE::GetOffset() const {
97
777
  if (IsValid())
98
257
    return m_die->GetOffset();
99
520
  else
100
520
    return DW_INVALID_OFFSET;
101
777
}
102
103
904k
SymbolFileDWARF *DWARFBaseDIE::GetDWARF() const {
104
904k
  if (m_cu)
105
904k
    return &m_cu->GetSymbolFileDWARF();
106
0
  else
107
0
    return nullptr;
108
904k
}
109
110
113k
bool DWARFBaseDIE::HasChildren() const {
111
113k
  return m_die && m_die->HasChildren();
112
113k
}
113
114
738
bool DWARFBaseDIE::Supports_DW_AT_APPLE_objc_complete_type() const {
115
738
  return IsValid() && GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
116
738
}
117
118
335k
DWARFAttributes DWARFBaseDIE::GetAttributes(Recurse recurse) const {
119
335k
  if (IsValid())
120
335k
    return m_die->GetAttributes(m_cu, recurse);
121
0
  return DWARFAttributes();
122
335k
}
123
124
namespace lldb_private::plugin {
125
namespace dwarf {
126
1.96M
bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
127
1.96M
  return lhs.GetDIE() == rhs.GetDIE() && 
lhs.GetCU() == rhs.GetCU()355k
;
128
1.96M
}
129
130
709k
bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
131
709k
  return !(lhs == rhs);
132
709k
}
133
} // namespace dwarf
134
} // namespace lldb_private::plugin
135
136
18.3k
const DWARFDataExtractor &DWARFBaseDIE::GetData() const {
137
  // Clients must check if this DIE is valid before calling this function.
138
18.3k
  assert(IsValid());
139
18.3k
  return m_cu->GetData();
140
18.3k
}