1 //===-- SBVariablesOptions.cpp --------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBVariablesOptions.h"
10 #include "SBReproducerPrivate.h"
11 #include "lldb/API/SBTarget.h"
12 #include "lldb/Target/Target.h"
14 #include "lldb/lldb-private.h"
17 using namespace lldb_private;
19 class 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) {}
28 VariablesOptionsImpl(const VariablesOptionsImpl &) = default;
30 ~VariablesOptionsImpl() = default;
32 VariablesOptionsImpl &operator=(const VariablesOptionsImpl &) = default;
34 bool GetIncludeArguments() const { return m_include_arguments; }
36 void SetIncludeArguments(bool b) { m_include_arguments = b; }
38 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;
44 void SetIncludeRecognizedArguments(bool b) {
45 m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo;
48 bool GetIncludeLocals() const { return m_include_locals; }
50 void SetIncludeLocals(bool b) { m_include_locals = b; }
52 bool GetIncludeStatics() const { return m_include_statics; }
54 void SetIncludeStatics(bool b) { m_include_statics = b; }
56 bool GetInScopeOnly() const { return m_in_scope_only; }
58 void SetInScopeOnly(bool b) { m_in_scope_only = b; }
60 bool GetIncludeRuntimeSupportValues() const {
61 return m_include_runtime_support_values;
64 void SetIncludeRuntimeSupportValues(bool b) {
65 m_include_runtime_support_values = b;
68 lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; }
70 void SetUseDynamic(lldb::DynamicValueType d) { m_use_dynamic = d; }
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;
82 SBVariablesOptions::SBVariablesOptions()
83 : m_opaque_up(new VariablesOptionsImpl()) {
84 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBVariablesOptions);
87 SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options)
88 : m_opaque_up(new VariablesOptionsImpl(options.ref())) {
89 LLDB_RECORD_CONSTRUCTOR(SBVariablesOptions,
90 (const lldb::SBVariablesOptions &), options);
93 SBVariablesOptions &SBVariablesOptions::
94 operator=(const SBVariablesOptions &options) {
96 lldb::SBVariablesOptions &,
97 SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &),
100 m_opaque_up = std::make_unique<VariablesOptionsImpl>(options.ref());
101 return LLDB_RECORD_RESULT(*this);
104 SBVariablesOptions::~SBVariablesOptions() = default;
106 bool SBVariablesOptions::IsValid() const {
107 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, IsValid);
108 return this->operator bool();
110 SBVariablesOptions::operator bool() const {
111 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, operator bool);
113 return m_opaque_up != nullptr;
116 bool SBVariablesOptions::GetIncludeArguments() const {
117 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions,
118 GetIncludeArguments);
120 return m_opaque_up->GetIncludeArguments();
123 void SBVariablesOptions::SetIncludeArguments(bool arguments) {
124 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool),
127 m_opaque_up->SetIncludeArguments(arguments);
130 bool SBVariablesOptions::GetIncludeRecognizedArguments(
131 const lldb::SBTarget &target) const {
132 LLDB_RECORD_METHOD_CONST(bool, SBVariablesOptions,
133 GetIncludeRecognizedArguments,
134 (const lldb::SBTarget &), target);
136 return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP());
139 void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) {
140 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRecognizedArguments,
143 m_opaque_up->SetIncludeRecognizedArguments(arguments);
146 bool SBVariablesOptions::GetIncludeLocals() const {
147 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeLocals);
149 return m_opaque_up->GetIncludeLocals();
152 void SBVariablesOptions::SetIncludeLocals(bool locals) {
153 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool),
156 m_opaque_up->SetIncludeLocals(locals);
159 bool SBVariablesOptions::GetIncludeStatics() const {
160 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeStatics);
162 return m_opaque_up->GetIncludeStatics();
165 void SBVariablesOptions::SetIncludeStatics(bool statics) {
166 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool),
169 m_opaque_up->SetIncludeStatics(statics);
172 bool SBVariablesOptions::GetInScopeOnly() const {
173 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetInScopeOnly);
175 return m_opaque_up->GetInScopeOnly();
178 void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) {
179 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool),
182 m_opaque_up->SetInScopeOnly(in_scope_only);
185 bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const {
186 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions,
187 GetIncludeRuntimeSupportValues);
189 return m_opaque_up->GetIncludeRuntimeSupportValues();
192 void SBVariablesOptions::SetIncludeRuntimeSupportValues(
193 bool runtime_support_values) {
194 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRuntimeSupportValues,
195 (bool), runtime_support_values);
197 m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values);
200 lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const {
201 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBVariablesOptions,
204 return m_opaque_up->GetUseDynamic();
207 void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) {
208 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetUseDynamic,
209 (lldb::DynamicValueType), dynamic);
211 m_opaque_up->SetUseDynamic(dynamic);
214 VariablesOptionsImpl *SBVariablesOptions::operator->() {
215 return m_opaque_up.operator->();
218 const VariablesOptionsImpl *SBVariablesOptions::operator->() const {
219 return m_opaque_up.operator->();
222 VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_up.get(); }
224 VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_up; }
226 const VariablesOptionsImpl &SBVariablesOptions::ref() const {
230 SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr)
231 : m_opaque_up(std::move(lldb_object_ptr)) {}
233 void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) {
234 m_opaque_up.reset(std::move(lldb_object_ptr));
237 namespace lldb_private {
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,
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,
270 LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetUseDynamic,
271 (lldb::DynamicValueType));