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 "lldb/API/SBTarget.h"
11 #include "lldb/Target/Target.h"
12 #include "lldb/Utility/Instrumentation.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
26 VariablesOptionsImpl(const VariablesOptionsImpl &) = default;
27
28 ~VariablesOptionsImpl() = default;
29
30 VariablesOptionsImpl &operator=(const VariablesOptionsImpl &) = default;
31
GetIncludeArguments() const32 bool GetIncludeArguments() const { return m_include_arguments; }
33
SetIncludeArguments(bool b)34 void SetIncludeArguments(bool b) { m_include_arguments = b; }
35
GetIncludeRecognizedArguments(const lldb::TargetSP & target_sp) const36 bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const {
37 if (m_include_recognized_arguments != eLazyBoolCalculate)
38 return m_include_recognized_arguments;
39 return target_sp ? target_sp->GetDisplayRecognizedArguments() : false;
40 }
41
SetIncludeRecognizedArguments(bool b)42 void SetIncludeRecognizedArguments(bool b) {
43 m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo;
44 }
45
GetIncludeLocals() const46 bool GetIncludeLocals() const { return m_include_locals; }
47
SetIncludeLocals(bool b)48 void SetIncludeLocals(bool b) { m_include_locals = b; }
49
GetIncludeStatics() const50 bool GetIncludeStatics() const { return m_include_statics; }
51
SetIncludeStatics(bool b)52 void SetIncludeStatics(bool b) { m_include_statics = b; }
53
GetInScopeOnly() const54 bool GetInScopeOnly() const { return m_in_scope_only; }
55
SetInScopeOnly(bool b)56 void SetInScopeOnly(bool b) { m_in_scope_only = b; }
57
GetIncludeRuntimeSupportValues() const58 bool GetIncludeRuntimeSupportValues() const {
59 return m_include_runtime_support_values;
60 }
61
SetIncludeRuntimeSupportValues(bool b)62 void SetIncludeRuntimeSupportValues(bool b) {
63 m_include_runtime_support_values = b;
64 }
65
GetUseDynamic() const66 lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; }
67
SetUseDynamic(lldb::DynamicValueType d)68 void SetUseDynamic(lldb::DynamicValueType d) { m_use_dynamic = d; }
69
70 private:
71 bool m_include_arguments : 1;
72 bool m_include_locals : 1;
73 bool m_include_statics : 1;
74 bool m_in_scope_only : 1;
75 bool m_include_runtime_support_values : 1;
76 LazyBool m_include_recognized_arguments =
77 eLazyBoolCalculate; // can be overridden with a setting
78 lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
79 };
80
SBVariablesOptions()81 SBVariablesOptions::SBVariablesOptions()
82 : m_opaque_up(new VariablesOptionsImpl()) {
83 LLDB_INSTRUMENT_VA(this);
84 }
85
SBVariablesOptions(const SBVariablesOptions & options)86 SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options)
87 : m_opaque_up(new VariablesOptionsImpl(options.ref())) {
88 LLDB_INSTRUMENT_VA(this, options);
89 }
90
91 SBVariablesOptions &SBVariablesOptions::
operator =(const SBVariablesOptions & options)92 operator=(const SBVariablesOptions &options) {
93 LLDB_INSTRUMENT_VA(this, options);
94
95 m_opaque_up = std::make_unique<VariablesOptionsImpl>(options.ref());
96 return *this;
97 }
98
99 SBVariablesOptions::~SBVariablesOptions() = default;
100
IsValid() const101 bool SBVariablesOptions::IsValid() const {
102 LLDB_INSTRUMENT_VA(this);
103 return this->operator bool();
104 }
operator bool() const105 SBVariablesOptions::operator bool() const {
106 LLDB_INSTRUMENT_VA(this);
107
108 return m_opaque_up != nullptr;
109 }
110
GetIncludeArguments() const111 bool SBVariablesOptions::GetIncludeArguments() const {
112 LLDB_INSTRUMENT_VA(this);
113
114 return m_opaque_up->GetIncludeArguments();
115 }
116
SetIncludeArguments(bool arguments)117 void SBVariablesOptions::SetIncludeArguments(bool arguments) {
118 LLDB_INSTRUMENT_VA(this, arguments);
119
120 m_opaque_up->SetIncludeArguments(arguments);
121 }
122
GetIncludeRecognizedArguments(const lldb::SBTarget & target) const123 bool SBVariablesOptions::GetIncludeRecognizedArguments(
124 const lldb::SBTarget &target) const {
125 LLDB_INSTRUMENT_VA(this, target);
126
127 return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP());
128 }
129
SetIncludeRecognizedArguments(bool arguments)130 void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) {
131 LLDB_INSTRUMENT_VA(this, arguments);
132
133 m_opaque_up->SetIncludeRecognizedArguments(arguments);
134 }
135
GetIncludeLocals() const136 bool SBVariablesOptions::GetIncludeLocals() const {
137 LLDB_INSTRUMENT_VA(this);
138
139 return m_opaque_up->GetIncludeLocals();
140 }
141
SetIncludeLocals(bool locals)142 void SBVariablesOptions::SetIncludeLocals(bool locals) {
143 LLDB_INSTRUMENT_VA(this, locals);
144
145 m_opaque_up->SetIncludeLocals(locals);
146 }
147
GetIncludeStatics() const148 bool SBVariablesOptions::GetIncludeStatics() const {
149 LLDB_INSTRUMENT_VA(this);
150
151 return m_opaque_up->GetIncludeStatics();
152 }
153
SetIncludeStatics(bool statics)154 void SBVariablesOptions::SetIncludeStatics(bool statics) {
155 LLDB_INSTRUMENT_VA(this, statics);
156
157 m_opaque_up->SetIncludeStatics(statics);
158 }
159
GetInScopeOnly() const160 bool SBVariablesOptions::GetInScopeOnly() const {
161 LLDB_INSTRUMENT_VA(this);
162
163 return m_opaque_up->GetInScopeOnly();
164 }
165
SetInScopeOnly(bool in_scope_only)166 void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) {
167 LLDB_INSTRUMENT_VA(this, in_scope_only);
168
169 m_opaque_up->SetInScopeOnly(in_scope_only);
170 }
171
GetIncludeRuntimeSupportValues() const172 bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const {
173 LLDB_INSTRUMENT_VA(this);
174
175 return m_opaque_up->GetIncludeRuntimeSupportValues();
176 }
177
SetIncludeRuntimeSupportValues(bool runtime_support_values)178 void SBVariablesOptions::SetIncludeRuntimeSupportValues(
179 bool runtime_support_values) {
180 LLDB_INSTRUMENT_VA(this, runtime_support_values);
181
182 m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values);
183 }
184
GetUseDynamic() const185 lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const {
186 LLDB_INSTRUMENT_VA(this);
187
188 return m_opaque_up->GetUseDynamic();
189 }
190
SetUseDynamic(lldb::DynamicValueType dynamic)191 void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) {
192 LLDB_INSTRUMENT_VA(this, dynamic);
193
194 m_opaque_up->SetUseDynamic(dynamic);
195 }
196
operator ->()197 VariablesOptionsImpl *SBVariablesOptions::operator->() {
198 return m_opaque_up.operator->();
199 }
200
operator ->() const201 const VariablesOptionsImpl *SBVariablesOptions::operator->() const {
202 return m_opaque_up.operator->();
203 }
204
get()205 VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_up.get(); }
206
ref()207 VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_up; }
208
ref() const209 const VariablesOptionsImpl &SBVariablesOptions::ref() const {
210 return *m_opaque_up;
211 }
212
SBVariablesOptions(VariablesOptionsImpl * lldb_object_ptr)213 SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr)
214 : m_opaque_up(std::move(lldb_object_ptr)) {}
215
SetOptions(VariablesOptionsImpl * lldb_object_ptr)216 void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) {
217 m_opaque_up.reset(std::move(lldb_object_ptr));
218 }
219