1 //===-- SBVariablesOptions.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/SBVariablesOptions.h"
10 #include "SBReproducerPrivate.h"
11 #include "lldb/API/SBTarget.h"
12 #include "lldb/Target/Target.h"
13
14 #include "lldb/lldb-private.h"
15
16 using namespace lldb;
17 using namespace lldb_private;
18
19 class VariablesOptionsImpl {
20 public:
VariablesOptionsImpl()21 VariablesOptionsImpl()
22 : m_include_arguments(false), m_include_locals(false),
23 m_include_statics(false), m_in_scope_only(false),
24 m_include_runtime_support_values(false),
25 m_include_recognized_arguments(eLazyBoolCalculate),
26 m_use_dynamic(lldb::eNoDynamicValues) {}
27
28 VariablesOptionsImpl(const VariablesOptionsImpl &) = default;
29
30 ~VariablesOptionsImpl() = default;
31
32 VariablesOptionsImpl &operator=(const VariablesOptionsImpl &) = default;
33
GetIncludeArguments() const34 bool GetIncludeArguments() const { return m_include_arguments; }
35
SetIncludeArguments(bool b)36 void SetIncludeArguments(bool b) { m_include_arguments = b; }
37
GetIncludeRecognizedArguments(const lldb::TargetSP & target_sp) const38 bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const {
39 if (m_include_recognized_arguments != eLazyBoolCalculate)
40 return m_include_recognized_arguments;
41 return target_sp ? target_sp->GetDisplayRecognizedArguments() : false;
42 }
43
SetIncludeRecognizedArguments(bool b)44 void SetIncludeRecognizedArguments(bool b) {
45 m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo;
46 }
47
GetIncludeLocals() const48 bool GetIncludeLocals() const { return m_include_locals; }
49
SetIncludeLocals(bool b)50 void SetIncludeLocals(bool b) { m_include_locals = b; }
51
GetIncludeStatics() const52 bool GetIncludeStatics() const { return m_include_statics; }
53
SetIncludeStatics(bool b)54 void SetIncludeStatics(bool b) { m_include_statics = b; }
55
GetInScopeOnly() const56 bool GetInScopeOnly() const { return m_in_scope_only; }
57
SetInScopeOnly(bool b)58 void SetInScopeOnly(bool b) { m_in_scope_only = b; }
59
GetIncludeRuntimeSupportValues() const60 bool GetIncludeRuntimeSupportValues() const {
61 return m_include_runtime_support_values;
62 }
63
SetIncludeRuntimeSupportValues(bool b)64 void SetIncludeRuntimeSupportValues(bool b) {
65 m_include_runtime_support_values = b;
66 }
67
GetUseDynamic() const68 lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; }
69
SetUseDynamic(lldb::DynamicValueType d)70 void SetUseDynamic(lldb::DynamicValueType d) { m_use_dynamic = d; }
71
72 private:
73 bool m_include_arguments : 1;
74 bool m_include_locals : 1;
75 bool m_include_statics : 1;
76 bool m_in_scope_only : 1;
77 bool m_include_runtime_support_values : 1;
78 LazyBool m_include_recognized_arguments; // can be overridden with a setting
79 lldb::DynamicValueType m_use_dynamic;
80 };
81
SBVariablesOptions()82 SBVariablesOptions::SBVariablesOptions()
83 : m_opaque_up(new VariablesOptionsImpl()) {
84 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBVariablesOptions);
85 }
86
SBVariablesOptions(const SBVariablesOptions & options)87 SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options)
88 : m_opaque_up(new VariablesOptionsImpl(options.ref())) {
89 LLDB_RECORD_CONSTRUCTOR(SBVariablesOptions,
90 (const lldb::SBVariablesOptions &), options);
91 }
92
93 SBVariablesOptions &SBVariablesOptions::
operator =(const SBVariablesOptions & options)94 operator=(const SBVariablesOptions &options) {
95 LLDB_RECORD_METHOD(
96 lldb::SBVariablesOptions &,
97 SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &),
98 options);
99
100 m_opaque_up = std::make_unique<VariablesOptionsImpl>(options.ref());
101 return LLDB_RECORD_RESULT(*this);
102 }
103
104 SBVariablesOptions::~SBVariablesOptions() = default;
105
IsValid() const106 bool SBVariablesOptions::IsValid() const {
107 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, IsValid);
108 return this->operator bool();
109 }
operator bool() const110 SBVariablesOptions::operator bool() const {
111 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, operator bool);
112
113 return m_opaque_up != nullptr;
114 }
115
GetIncludeArguments() const116 bool SBVariablesOptions::GetIncludeArguments() const {
117 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions,
118 GetIncludeArguments);
119
120 return m_opaque_up->GetIncludeArguments();
121 }
122
SetIncludeArguments(bool arguments)123 void SBVariablesOptions::SetIncludeArguments(bool arguments) {
124 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool),
125 arguments);
126
127 m_opaque_up->SetIncludeArguments(arguments);
128 }
129
GetIncludeRecognizedArguments(const lldb::SBTarget & target) const130 bool SBVariablesOptions::GetIncludeRecognizedArguments(
131 const lldb::SBTarget &target) const {
132 LLDB_RECORD_METHOD_CONST(bool, SBVariablesOptions,
133 GetIncludeRecognizedArguments,
134 (const lldb::SBTarget &), target);
135
136 return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP());
137 }
138
SetIncludeRecognizedArguments(bool arguments)139 void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) {
140 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRecognizedArguments,
141 (bool), arguments);
142
143 m_opaque_up->SetIncludeRecognizedArguments(arguments);
144 }
145
GetIncludeLocals() const146 bool SBVariablesOptions::GetIncludeLocals() const {
147 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeLocals);
148
149 return m_opaque_up->GetIncludeLocals();
150 }
151
SetIncludeLocals(bool locals)152 void SBVariablesOptions::SetIncludeLocals(bool locals) {
153 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool),
154 locals);
155
156 m_opaque_up->SetIncludeLocals(locals);
157 }
158
GetIncludeStatics() const159 bool SBVariablesOptions::GetIncludeStatics() const {
160 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeStatics);
161
162 return m_opaque_up->GetIncludeStatics();
163 }
164
SetIncludeStatics(bool statics)165 void SBVariablesOptions::SetIncludeStatics(bool statics) {
166 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool),
167 statics);
168
169 m_opaque_up->SetIncludeStatics(statics);
170 }
171
GetInScopeOnly() const172 bool SBVariablesOptions::GetInScopeOnly() const {
173 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetInScopeOnly);
174
175 return m_opaque_up->GetInScopeOnly();
176 }
177
SetInScopeOnly(bool in_scope_only)178 void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) {
179 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool),
180 in_scope_only);
181
182 m_opaque_up->SetInScopeOnly(in_scope_only);
183 }
184
GetIncludeRuntimeSupportValues() const185 bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const {
186 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions,
187 GetIncludeRuntimeSupportValues);
188
189 return m_opaque_up->GetIncludeRuntimeSupportValues();
190 }
191
SetIncludeRuntimeSupportValues(bool runtime_support_values)192 void SBVariablesOptions::SetIncludeRuntimeSupportValues(
193 bool runtime_support_values) {
194 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRuntimeSupportValues,
195 (bool), runtime_support_values);
196
197 m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values);
198 }
199
GetUseDynamic() const200 lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const {
201 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBVariablesOptions,
202 GetUseDynamic);
203
204 return m_opaque_up->GetUseDynamic();
205 }
206
SetUseDynamic(lldb::DynamicValueType dynamic)207 void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) {
208 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetUseDynamic,
209 (lldb::DynamicValueType), dynamic);
210
211 m_opaque_up->SetUseDynamic(dynamic);
212 }
213
operator ->()214 VariablesOptionsImpl *SBVariablesOptions::operator->() {
215 return m_opaque_up.operator->();
216 }
217
operator ->() const218 const VariablesOptionsImpl *SBVariablesOptions::operator->() const {
219 return m_opaque_up.operator->();
220 }
221
get()222 VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_up.get(); }
223
ref()224 VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_up; }
225
ref() const226 const VariablesOptionsImpl &SBVariablesOptions::ref() const {
227 return *m_opaque_up;
228 }
229
SBVariablesOptions(VariablesOptionsImpl * lldb_object_ptr)230 SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr)
231 : m_opaque_up(std::move(lldb_object_ptr)) {}
232
SetOptions(VariablesOptionsImpl * lldb_object_ptr)233 void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) {
234 m_opaque_up.reset(std::move(lldb_object_ptr));
235 }
236
237 namespace lldb_private {
238 namespace repro {
239
240 template <>
RegisterMethods(Registry & R)241 void RegisterMethods<SBVariablesOptions>(Registry &R) {
242 LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions, ());
243 LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions,
244 (const lldb::SBVariablesOptions &));
245 LLDB_REGISTER_METHOD(
246 lldb::SBVariablesOptions &,
247 SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &));
248 LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, IsValid, ());
249 LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, operator bool, ());
250 LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeArguments,
251 ());
252 LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool));
253 LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions,
254 GetIncludeRecognizedArguments,
255 (const lldb::SBTarget &));
256 LLDB_REGISTER_METHOD(void, SBVariablesOptions,
257 SetIncludeRecognizedArguments, (bool));
258 LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeLocals, ());
259 LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool));
260 LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeStatics, ());
261 LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool));
262 LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetInScopeOnly, ());
263 LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool));
264 LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions,
265 GetIncludeRuntimeSupportValues, ());
266 LLDB_REGISTER_METHOD(void, SBVariablesOptions,
267 SetIncludeRuntimeSupportValues, (bool));
268 LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBVariablesOptions,
269 GetUseDynamic, ());
270 LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetUseDynamic,
271 (lldb::DynamicValueType));
272 }
273
274 }
275 }
276