/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/API/SBLineEntry.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- SBLineEntry.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 "lldb/API/SBLineEntry.h" |
10 | | #include "Utils.h" |
11 | | #include "lldb/API/SBStream.h" |
12 | | #include "lldb/Host/PosixApi.h" |
13 | | #include "lldb/Symbol/LineEntry.h" |
14 | | #include "lldb/Utility/Instrumentation.h" |
15 | | #include "lldb/Utility/StreamString.h" |
16 | | |
17 | | #include <climits> |
18 | | |
19 | | using namespace lldb; |
20 | | using namespace lldb_private; |
21 | | |
22 | 2.54k | SBLineEntry::SBLineEntry() { LLDB_INSTRUMENT_VA(this); } |
23 | | |
24 | 1.26k | SBLineEntry::SBLineEntry(const SBLineEntry &rhs) { |
25 | 1.26k | LLDB_INSTRUMENT_VA(this, rhs); |
26 | | |
27 | 1.26k | m_opaque_up = clone(rhs.m_opaque_up); |
28 | 1.26k | } |
29 | | |
30 | 0 | SBLineEntry::SBLineEntry(const lldb_private::LineEntry *lldb_object_ptr) { |
31 | 0 | if (lldb_object_ptr) |
32 | 0 | m_opaque_up = std::make_unique<LineEntry>(*lldb_object_ptr); |
33 | 0 | } |
34 | | |
35 | 1.26k | const SBLineEntry &SBLineEntry::operator=(const SBLineEntry &rhs) { |
36 | 1.26k | LLDB_INSTRUMENT_VA(this, rhs); |
37 | | |
38 | 1.26k | if (this != &rhs) |
39 | 1.26k | m_opaque_up = clone(rhs.m_opaque_up); |
40 | 1.26k | return *this; |
41 | 1.26k | } |
42 | | |
43 | 1.25k | void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) { |
44 | 1.25k | m_opaque_up = std::make_unique<LineEntry>(lldb_object_ref); |
45 | 1.25k | } |
46 | | |
47 | 3.80k | SBLineEntry::~SBLineEntry() = default; |
48 | | |
49 | 184 | SBAddress SBLineEntry::GetStartAddress() const { |
50 | 184 | LLDB_INSTRUMENT_VA(this); |
51 | | |
52 | 184 | SBAddress sb_address; |
53 | 184 | if (m_opaque_up) |
54 | 183 | sb_address.SetAddress(m_opaque_up->range.GetBaseAddress()); |
55 | | |
56 | 184 | return sb_address; |
57 | 184 | } |
58 | | |
59 | 8 | SBAddress SBLineEntry::GetEndAddress() const { |
60 | 8 | LLDB_INSTRUMENT_VA(this); |
61 | | |
62 | 8 | SBAddress sb_address; |
63 | 8 | if (m_opaque_up) { |
64 | 7 | sb_address.SetAddress(m_opaque_up->range.GetBaseAddress()); |
65 | 7 | sb_address.OffsetAddress(m_opaque_up->range.GetByteSize()); |
66 | 7 | } |
67 | 8 | return sb_address; |
68 | 8 | } |
69 | | |
70 | 85 | bool SBLineEntry::IsValid() const { |
71 | 85 | LLDB_INSTRUMENT_VA(this); |
72 | 85 | return this->operator bool(); |
73 | 85 | } |
74 | 109 | SBLineEntry::operator bool() const { |
75 | 109 | LLDB_INSTRUMENT_VA(this); |
76 | | |
77 | 109 | return m_opaque_up.get() && m_opaque_up->IsValid()108 ; |
78 | 109 | } |
79 | | |
80 | 534 | SBFileSpec SBLineEntry::GetFileSpec() const { |
81 | 534 | LLDB_INSTRUMENT_VA(this); |
82 | | |
83 | 534 | SBFileSpec sb_file_spec; |
84 | 534 | if (m_opaque_up.get() && m_opaque_up->file533 ) |
85 | 384 | sb_file_spec.SetFileSpec(m_opaque_up->file); |
86 | | |
87 | 534 | return sb_file_spec; |
88 | 534 | } |
89 | | |
90 | 788 | uint32_t SBLineEntry::GetLine() const { |
91 | 788 | LLDB_INSTRUMENT_VA(this); |
92 | | |
93 | 788 | uint32_t line = 0; |
94 | 788 | if (m_opaque_up) |
95 | 787 | line = m_opaque_up->line; |
96 | | |
97 | 788 | return line; |
98 | 788 | } |
99 | | |
100 | 28 | uint32_t SBLineEntry::GetColumn() const { |
101 | 28 | LLDB_INSTRUMENT_VA(this); |
102 | | |
103 | 28 | if (m_opaque_up) |
104 | 27 | return m_opaque_up->column; |
105 | 1 | return 0; |
106 | 28 | } |
107 | | |
108 | 16 | void SBLineEntry::SetFileSpec(lldb::SBFileSpec filespec) { |
109 | 16 | LLDB_INSTRUMENT_VA(this, filespec); |
110 | | |
111 | 16 | if (filespec.IsValid()) |
112 | 16 | ref().file = filespec.ref(); |
113 | 0 | else |
114 | 0 | ref().file.Clear(); |
115 | 16 | } |
116 | 56 | void SBLineEntry::SetLine(uint32_t line) { |
117 | 56 | LLDB_INSTRUMENT_VA(this, line); |
118 | | |
119 | 56 | ref().line = line; |
120 | 56 | } |
121 | | |
122 | 0 | void SBLineEntry::SetColumn(uint32_t column) { |
123 | 0 | LLDB_INSTRUMENT_VA(this, column); |
124 | |
|
125 | 0 | ref().line = column; |
126 | 0 | } |
127 | | |
128 | 2 | bool SBLineEntry::operator==(const SBLineEntry &rhs) const { |
129 | 2 | LLDB_INSTRUMENT_VA(this, rhs); |
130 | | |
131 | 2 | lldb_private::LineEntry *lhs_ptr = m_opaque_up.get(); |
132 | 2 | lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get(); |
133 | | |
134 | 2 | if (lhs_ptr && rhs_ptr) |
135 | 2 | return lldb_private::LineEntry::Compare(*lhs_ptr, *rhs_ptr) == 0; |
136 | | |
137 | 0 | return lhs_ptr == rhs_ptr; |
138 | 2 | } |
139 | | |
140 | 0 | bool SBLineEntry::operator!=(const SBLineEntry &rhs) const { |
141 | 0 | LLDB_INSTRUMENT_VA(this, rhs); |
142 | |
|
143 | 0 | lldb_private::LineEntry *lhs_ptr = m_opaque_up.get(); |
144 | 0 | lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get(); |
145 | |
|
146 | 0 | if (lhs_ptr && rhs_ptr) |
147 | 0 | return lldb_private::LineEntry::Compare(*lhs_ptr, *rhs_ptr) != 0; |
148 | | |
149 | 0 | return lhs_ptr != rhs_ptr; |
150 | 0 | } |
151 | | |
152 | 0 | const lldb_private::LineEntry *SBLineEntry::operator->() const { |
153 | 0 | return m_opaque_up.get(); |
154 | 0 | } |
155 | | |
156 | 74 | lldb_private::LineEntry &SBLineEntry::ref() { |
157 | 74 | if (m_opaque_up == nullptr) |
158 | 16 | m_opaque_up = std::make_unique<lldb_private::LineEntry>(); |
159 | 74 | return *m_opaque_up; |
160 | 74 | } |
161 | | |
162 | 0 | const lldb_private::LineEntry &SBLineEntry::ref() const { return *m_opaque_up; } |
163 | | |
164 | 2 | bool SBLineEntry::GetDescription(SBStream &description) { |
165 | 2 | LLDB_INSTRUMENT_VA(this, description); |
166 | | |
167 | 2 | Stream &strm = description.ref(); |
168 | | |
169 | 2 | if (m_opaque_up) { |
170 | 0 | char file_path[PATH_MAX * 2]; |
171 | 0 | m_opaque_up->file.GetPath(file_path, sizeof(file_path)); |
172 | 0 | strm.Printf("%s:%u", file_path, GetLine()); |
173 | 0 | if (GetColumn() > 0) |
174 | 0 | strm.Printf(":%u", GetColumn()); |
175 | 0 | } else |
176 | 2 | strm.PutCString("No value"); |
177 | | |
178 | 2 | return true; |
179 | 2 | } |
180 | | |
181 | 0 | lldb_private::LineEntry *SBLineEntry::get() { return m_opaque_up.get(); } |