1 //===-- SBExpressionOptions.cpp ---------------------------------------------*-
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SBExpressionOptions.h"
11 #include "SBReproducerPrivate.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/Target/Target.h"
17 using namespace lldb_private;
19 SBExpressionOptions::SBExpressionOptions()
20 : m_opaque_up(new EvaluateExpressionOptions()) {
21 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExpressionOptions);
24 SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs)
26 LLDB_RECORD_CONSTRUCTOR(SBExpressionOptions,
27 (const lldb::SBExpressionOptions &), rhs);
29 m_opaque_up = clone(rhs.m_opaque_up);
32 const SBExpressionOptions &SBExpressionOptions::
33 operator=(const SBExpressionOptions &rhs) {
35 const lldb::SBExpressionOptions &,
36 SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &), rhs);
39 m_opaque_up = clone(rhs.m_opaque_up);
40 return LLDB_RECORD_RESULT(*this);
43 SBExpressionOptions::~SBExpressionOptions() {}
45 bool SBExpressionOptions::GetCoerceResultToId() const {
46 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
49 return m_opaque_up->DoesCoerceToId();
52 void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
53 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetCoerceResultToId, (bool),
56 m_opaque_up->SetCoerceToId(coerce);
59 bool SBExpressionOptions::GetUnwindOnError() const {
60 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetUnwindOnError);
62 return m_opaque_up->DoesUnwindOnError();
65 void SBExpressionOptions::SetUnwindOnError(bool unwind) {
66 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool),
69 m_opaque_up->SetUnwindOnError(unwind);
72 bool SBExpressionOptions::GetIgnoreBreakpoints() const {
73 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
74 GetIgnoreBreakpoints);
76 return m_opaque_up->DoesIgnoreBreakpoints();
79 void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
80 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, (bool),
83 m_opaque_up->SetIgnoreBreakpoints(ignore);
86 lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
87 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBExpressionOptions,
88 GetFetchDynamicValue);
90 return m_opaque_up->GetUseDynamic();
93 void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
94 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetFetchDynamicValue,
95 (lldb::DynamicValueType), dynamic);
97 m_opaque_up->SetUseDynamic(dynamic);
100 uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
101 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions,
102 GetTimeoutInMicroSeconds);
104 return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
107 void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
108 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds,
109 (uint32_t), timeout);
111 m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
112 : std::chrono::microseconds(timeout));
115 uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
116 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions,
117 GetOneThreadTimeoutInMicroSeconds);
119 return m_opaque_up->GetOneThreadTimeout()
120 ? m_opaque_up->GetOneThreadTimeout()->count()
124 void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
125 LLDB_RECORD_METHOD(void, SBExpressionOptions,
126 SetOneThreadTimeoutInMicroSeconds, (uint32_t), timeout);
128 m_opaque_up->SetOneThreadTimeout(timeout == 0
129 ? Timeout<std::micro>(llvm::None)
130 : std::chrono::microseconds(timeout));
133 bool SBExpressionOptions::GetTryAllThreads() const {
134 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetTryAllThreads);
136 return m_opaque_up->GetTryAllThreads();
139 void SBExpressionOptions::SetTryAllThreads(bool run_others) {
140 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool),
143 m_opaque_up->SetTryAllThreads(run_others);
146 bool SBExpressionOptions::GetStopOthers() const {
147 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetStopOthers);
149 return m_opaque_up->GetStopOthers();
152 void SBExpressionOptions::SetStopOthers(bool run_others) {
153 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetStopOthers, (bool),
156 m_opaque_up->SetStopOthers(run_others);
159 bool SBExpressionOptions::GetTrapExceptions() const {
160 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
163 return m_opaque_up->GetTrapExceptions();
166 void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
167 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool),
170 m_opaque_up->SetTrapExceptions(trap_exceptions);
173 void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
174 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetLanguage,
175 (lldb::LanguageType), language);
177 m_opaque_up->SetLanguage(language);
180 void SBExpressionOptions::SetCancelCallback(
181 lldb::ExpressionCancelCallback callback, void *baton) {
182 LLDB_RECORD_DUMMY(void, SBExpressionOptions, SetCancelCallback,
183 (lldb::ExpressionCancelCallback, void *), callback, baton);
185 m_opaque_up->SetCancelCallback(callback, baton);
188 bool SBExpressionOptions::GetGenerateDebugInfo() {
189 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetGenerateDebugInfo);
191 return m_opaque_up->GetGenerateDebugInfo();
194 void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
195 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, (bool),
198 return m_opaque_up->SetGenerateDebugInfo(b);
201 bool SBExpressionOptions::GetSuppressPersistentResult() {
202 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions,
203 GetSuppressPersistentResult);
205 return m_opaque_up->GetResultIsInternal();
208 void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
209 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult,
212 return m_opaque_up->SetResultIsInternal(b);
215 const char *SBExpressionOptions::GetPrefix() const {
216 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBExpressionOptions,
219 return m_opaque_up->GetPrefix();
222 void SBExpressionOptions::SetPrefix(const char *prefix) {
223 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetPrefix, (const char *),
226 return m_opaque_up->SetPrefix(prefix);
229 bool SBExpressionOptions::GetAutoApplyFixIts() {
230 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAutoApplyFixIts);
232 return m_opaque_up->GetAutoApplyFixIts();
235 void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
236 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool), b);
238 return m_opaque_up->SetAutoApplyFixIts(b);
241 bool SBExpressionOptions::GetTopLevel() {
242 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel);
244 return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
247 void SBExpressionOptions::SetTopLevel(bool b) {
248 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTopLevel, (bool), b);
250 m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
251 : m_opaque_up->default_execution_policy);
254 bool SBExpressionOptions::GetAllowJIT() {
255 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAllowJIT);
257 return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
260 void SBExpressionOptions::SetAllowJIT(bool allow) {
261 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool), allow);
263 m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
264 : eExecutionPolicyNever);
267 EvaluateExpressionOptions *SBExpressionOptions::get() const {
268 return m_opaque_up.get();
271 EvaluateExpressionOptions &SBExpressionOptions::ref() const {
272 return *(m_opaque_up.get());
275 namespace lldb_private {
279 void RegisterMethods<SBExpressionOptions>(Registry &R) {
280 LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions, ());
281 LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions,
282 (const lldb::SBExpressionOptions &));
283 LLDB_REGISTER_METHOD(
284 const lldb::SBExpressionOptions &,
285 SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &));
286 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetCoerceResultToId,
288 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetCoerceResultToId,
290 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetUnwindOnError, ());
291 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool));
292 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetIgnoreBreakpoints,
294 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints,
296 LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBExpressionOptions,
297 GetFetchDynamicValue, ());
298 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetFetchDynamicValue,
299 (lldb::DynamicValueType));
300 LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions,
301 GetTimeoutInMicroSeconds, ());
302 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds,
304 LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions,
305 GetOneThreadTimeoutInMicroSeconds, ());
306 LLDB_REGISTER_METHOD(void, SBExpressionOptions,
307 SetOneThreadTimeoutInMicroSeconds, (uint32_t));
308 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTryAllThreads, ());
309 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool));
310 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetStopOthers, ());
311 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetStopOthers, (bool));
312 LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTrapExceptions,
314 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool));
315 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetLanguage,
316 (lldb::LanguageType));
317 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetGenerateDebugInfo, ());
318 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo,
320 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetSuppressPersistentResult,
322 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult,
324 LLDB_REGISTER_METHOD_CONST(const char *, SBExpressionOptions, GetPrefix,
326 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetPrefix, (const char *));
327 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAutoApplyFixIts, ());
328 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool));
329 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetTopLevel, ());
330 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTopLevel, (bool));
331 LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAllowJIT, ());
332 LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool));