1 //===-- SBExpressionOptions.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/SBExpressionOptions.h"
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/Target/Target.h"
14
15 using namespace lldb;
16 using namespace lldb_private;
17
SBExpressionOptions()18 SBExpressionOptions::SBExpressionOptions()
19 : m_opaque_up(new EvaluateExpressionOptions()) {
20 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExpressionOptions);
21 }
22
SBExpressionOptions(const SBExpressionOptions & rhs)23 SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs)
24 : m_opaque_up() {
25 LLDB_RECORD_CONSTRUCTOR(SBExpressionOptions,
26 (const lldb::SBExpressionOptions &), rhs);
27
28 m_opaque_up = clone(rhs.m_opaque_up);
29 }
30
31 const SBExpressionOptions &SBExpressionOptions::
operator =(const SBExpressionOptions & rhs)32 operator=(const SBExpressionOptions &rhs) {
33 LLDB_RECORD_METHOD(
34 const lldb::SBExpressionOptions &,
35 SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &), rhs);
36
37 if (this != &rhs)
38 m_opaque_up = clone(rhs.m_opaque_up);
39 return LLDB_RECORD_RESULT(*this);
40 }
41
42 SBExpressionOptions::~SBExpressionOptions() = default;
43
GetCoerceResultToId() const44 bool SBExpressionOptions::GetCoerceResultToId() const {
45 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
46 GetCoerceResultToId);
47
48 return m_opaque_up->DoesCoerceToId();
49 }
50
SetCoerceResultToId(bool coerce)51 void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
52 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetCoerceResultToId, (bool),
53 coerce);
54
55 m_opaque_up->SetCoerceToId(coerce);
56 }
57
GetUnwindOnError() const58 bool SBExpressionOptions::GetUnwindOnError() const {
59 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetUnwindOnError);
60
61 return m_opaque_up->DoesUnwindOnError();
62 }
63
SetUnwindOnError(bool unwind)64 void SBExpressionOptions::SetUnwindOnError(bool unwind) {
65 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool),
66 unwind);
67
68 m_opaque_up->SetUnwindOnError(unwind);
69 }
70
GetIgnoreBreakpoints() const71 bool SBExpressionOptions::GetIgnoreBreakpoints() const {
72 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
73 GetIgnoreBreakpoints);
74
75 return m_opaque_up->DoesIgnoreBreakpoints();
76 }
77
SetIgnoreBreakpoints(bool ignore)78 void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
79 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, (bool),
80 ignore);
81
82 m_opaque_up->SetIgnoreBreakpoints(ignore);
83 }
84
GetFetchDynamicValue() const85 lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
86 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBExpressionOptions,
87 GetFetchDynamicValue);
88
89 return m_opaque_up->GetUseDynamic();
90 }
91
SetFetchDynamicValue(lldb::DynamicValueType dynamic)92 void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
93 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetFetchDynamicValue,
94 (lldb::DynamicValueType), dynamic);
95
96 m_opaque_up->SetUseDynamic(dynamic);
97 }
98
GetTimeoutInMicroSeconds() const99 uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
100 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions,
101 GetTimeoutInMicroSeconds);
102
103 return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
104 }
105
SetTimeoutInMicroSeconds(uint32_t timeout)106 void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
107 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds,
108 (uint32_t), timeout);
109
110 m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
111 : std::chrono::microseconds(timeout));
112 }
113
GetOneThreadTimeoutInMicroSeconds() const114 uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
115 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions,
116 GetOneThreadTimeoutInMicroSeconds);
117
118 return m_opaque_up->GetOneThreadTimeout()
119 ? m_opaque_up->GetOneThreadTimeout()->count()
120 : 0;
121 }
122
SetOneThreadTimeoutInMicroSeconds(uint32_t timeout)123 void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
124 LLDB_RECORD_METHOD(void, SBExpressionOptions,
125 SetOneThreadTimeoutInMicroSeconds, (uint32_t), timeout);
126
127 m_opaque_up->SetOneThreadTimeout(timeout == 0
128 ? Timeout<std::micro>(llvm::None)
129 : std::chrono::microseconds(timeout));
130 }
131
GetTryAllThreads() const132 bool SBExpressionOptions::GetTryAllThreads() const {
133 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetTryAllThreads);
134
135 return m_opaque_up->GetTryAllThreads();
136 }
137
SetTryAllThreads(bool run_others)138 void SBExpressionOptions::SetTryAllThreads(bool run_others) {
139 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool),
140 run_others);
141
142 m_opaque_up->SetTryAllThreads(run_others);
143 }
144
GetStopOthers() const145 bool SBExpressionOptions::GetStopOthers() const {
146 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetStopOthers);
147
148 return m_opaque_up->GetStopOthers();
149 }
150
SetStopOthers(bool run_others)151 void SBExpressionOptions::SetStopOthers(bool run_others) {
152 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetStopOthers, (bool),
153 run_others);
154
155 m_opaque_up->SetStopOthers(run_others);
156 }
157
GetTrapExceptions() const158 bool SBExpressionOptions::GetTrapExceptions() const {
159 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
160 GetTrapExceptions);
161
162 return m_opaque_up->GetTrapExceptions();
163 }
164
SetTrapExceptions(bool trap_exceptions)165 void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
166 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool),
167 trap_exceptions);
168
169 m_opaque_up->SetTrapExceptions(trap_exceptions);
170 }
171
SetLanguage(lldb::LanguageType language)172 void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
173 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetLanguage,
174 (lldb::LanguageType), language);
175
176 m_opaque_up->SetLanguage(language);
177 }
178
SetCancelCallback(lldb::ExpressionCancelCallback callback,void * baton)179 void SBExpressionOptions::SetCancelCallback(
180 lldb::ExpressionCancelCallback callback, void *baton) {
181 LLDB_RECORD_DUMMY(void, SBExpressionOptions, SetCancelCallback,
182 (lldb::ExpressionCancelCallback, void *), callback, baton);
183
184 m_opaque_up->SetCancelCallback(callback, baton);
185 }
186
GetGenerateDebugInfo()187 bool SBExpressionOptions::GetGenerateDebugInfo() {
188 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetGenerateDebugInfo);
189
190 return m_opaque_up->GetGenerateDebugInfo();
191 }
192
SetGenerateDebugInfo(bool b)193 void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
194 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, (bool),
195 b);
196
197 return m_opaque_up->SetGenerateDebugInfo(b);
198 }
199
GetSuppressPersistentResult()200 bool SBExpressionOptions::GetSuppressPersistentResult() {
201 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions,
202 GetSuppressPersistentResult);
203
204 return m_opaque_up->GetResultIsInternal();
205 }
206
SetSuppressPersistentResult(bool b)207 void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
208 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult,
209 (bool), b);
210
211 return m_opaque_up->SetResultIsInternal(b);
212 }
213
GetPrefix() const214 const char *SBExpressionOptions::GetPrefix() const {
215 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBExpressionOptions,
216 GetPrefix);
217
218 return m_opaque_up->GetPrefix();
219 }
220
SetPrefix(const char * prefix)221 void SBExpressionOptions::SetPrefix(const char *prefix) {
222 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetPrefix, (const char *),
223 prefix);
224
225 return m_opaque_up->SetPrefix(prefix);
226 }
227
GetAutoApplyFixIts()228 bool SBExpressionOptions::GetAutoApplyFixIts() {
229 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAutoApplyFixIts);
230
231 return m_opaque_up->GetAutoApplyFixIts();
232 }
233
SetAutoApplyFixIts(bool b)234 void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
235 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool), b);
236
237 return m_opaque_up->SetAutoApplyFixIts(b);
238 }
239
GetRetriesWithFixIts()240 uint64_t SBExpressionOptions::GetRetriesWithFixIts() {
241 LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBExpressionOptions,
242 GetRetriesWithFixIts);
243
244 return m_opaque_up->GetRetriesWithFixIts();
245 }
246
SetRetriesWithFixIts(uint64_t retries)247 void SBExpressionOptions::SetRetriesWithFixIts(uint64_t retries) {
248 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetRetriesWithFixIts,
249 (uint64_t), retries);
250
251 return m_opaque_up->SetRetriesWithFixIts(retries);
252 }
253
GetTopLevel()254 bool SBExpressionOptions::GetTopLevel() {
255 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel);
256
257 return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
258 }
259
SetTopLevel(bool b)260 void SBExpressionOptions::SetTopLevel(bool b) {
261 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTopLevel, (bool), b);
262
263 m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
264 : m_opaque_up->default_execution_policy);
265 }
266
GetAllowJIT()267 bool SBExpressionOptions::GetAllowJIT() {
268 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAllowJIT);
269
270 return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
271 }
272
SetAllowJIT(bool allow)273 void SBExpressionOptions::SetAllowJIT(bool allow) {
274 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool), allow);
275
276 m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
277 : eExecutionPolicyNever);
278 }
279
get() const280 EvaluateExpressionOptions *SBExpressionOptions::get() const {
281 return m_opaque_up.get();
282 }
283
ref() const284 EvaluateExpressionOptions &SBExpressionOptions::ref() const {
285 return *(m_opaque_up.get());
286 }
287
288 namespace lldb_private {
289 namespace repro {
290
291 template <>
RegisterMethods(Registry & R)292 void RegisterMethods<SBExpressionOptions>(Registry &R) {
293 LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions, ());
294 LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions,
295 (const lldb::SBExpressionOptions &));
296 LLDB_REGISTER_METHOD(
297 const lldb::SBExpressionOptions &,
298 SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &));
299 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetCoerceResultToId,
300 ());
301 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetCoerceResultToId,
302 (bool));
303 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetUnwindOnError, ());
304 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool));
305 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetIgnoreBreakpoints,
306 ());
307 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints,
308 (bool));
309 LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBExpressionOptions,
310 GetFetchDynamicValue, ());
311 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetFetchDynamicValue,
312 (lldb::DynamicValueType));
313 LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions,
314 GetTimeoutInMicroSeconds, ());
315 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds,
316 (uint32_t));
317 LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions,
318 GetOneThreadTimeoutInMicroSeconds, ());
319 LLDB_REGISTER_METHOD(void, SBExpressionOptions,
320 SetOneThreadTimeoutInMicroSeconds, (uint32_t));
321 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTryAllThreads, ());
322 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool));
323 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetStopOthers, ());
324 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetStopOthers, (bool));
325 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTrapExceptions,
326 ());
327 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool));
328 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetLanguage,
329 (lldb::LanguageType));
330 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetGenerateDebugInfo, ());
331 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo,
332 (bool));
333 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetSuppressPersistentResult,
334 ());
335 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult,
336 (bool));
337 LLDB_REGISTER_METHOD_CONST(const char *, SBExpressionOptions, GetPrefix,
338 ());
339 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetPrefix, (const char *));
340 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAutoApplyFixIts, ());
341 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool));
342 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetTopLevel, ());
343 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTopLevel, (bool));
344 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAllowJIT, ());
345 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool));
346 LLDB_REGISTER_METHOD(uint64_t, SBExpressionOptions, GetRetriesWithFixIts, ());
347 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetRetriesWithFixIts,
348 (uint64_t));
349 }
350
351 }
352 }
353