1 //===-- SBExpressionOptions.cpp ---------------------------------------------*-
2 //C++ -*-===//
3 //
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
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "lldb/API/SBExpressionOptions.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 
18 SBExpressionOptions::SBExpressionOptions()
19     : m_opaque_up(new EvaluateExpressionOptions()) {}
20 
21 SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs)
22     : m_opaque_up() {
23   m_opaque_up = clone(rhs.m_opaque_up);
24 }
25 
26 const SBExpressionOptions &SBExpressionOptions::
27 operator=(const SBExpressionOptions &rhs) {
28   if (this != &rhs)
29     m_opaque_up = clone(rhs.m_opaque_up);
30   return *this;
31 }
32 
33 SBExpressionOptions::~SBExpressionOptions() {}
34 
35 bool SBExpressionOptions::GetCoerceResultToId() const {
36   return m_opaque_up->DoesCoerceToId();
37 }
38 
39 void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
40   m_opaque_up->SetCoerceToId(coerce);
41 }
42 
43 bool SBExpressionOptions::GetUnwindOnError() const {
44   return m_opaque_up->DoesUnwindOnError();
45 }
46 
47 void SBExpressionOptions::SetUnwindOnError(bool unwind) {
48   m_opaque_up->SetUnwindOnError(unwind);
49 }
50 
51 bool SBExpressionOptions::GetIgnoreBreakpoints() const {
52   return m_opaque_up->DoesIgnoreBreakpoints();
53 }
54 
55 void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
56   m_opaque_up->SetIgnoreBreakpoints(ignore);
57 }
58 
59 lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
60   return m_opaque_up->GetUseDynamic();
61 }
62 
63 void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
64   m_opaque_up->SetUseDynamic(dynamic);
65 }
66 
67 uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
68   return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
69 }
70 
71 void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
72   m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
73                                        : std::chrono::microseconds(timeout));
74 }
75 
76 uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
77   return m_opaque_up->GetOneThreadTimeout()
78              ? m_opaque_up->GetOneThreadTimeout()->count()
79              : 0;
80 }
81 
82 void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
83   m_opaque_up->SetOneThreadTimeout(timeout == 0
84                                        ? Timeout<std::micro>(llvm::None)
85                                        : std::chrono::microseconds(timeout));
86 }
87 
88 bool SBExpressionOptions::GetTryAllThreads() const {
89   return m_opaque_up->GetTryAllThreads();
90 }
91 
92 void SBExpressionOptions::SetTryAllThreads(bool run_others) {
93   m_opaque_up->SetTryAllThreads(run_others);
94 }
95 
96 bool SBExpressionOptions::GetStopOthers() const {
97   return m_opaque_up->GetStopOthers();
98 }
99 
100 void SBExpressionOptions::SetStopOthers(bool run_others) {
101   m_opaque_up->SetStopOthers(run_others);
102 }
103 
104 bool SBExpressionOptions::GetTrapExceptions() const {
105   return m_opaque_up->GetTrapExceptions();
106 }
107 
108 void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
109   m_opaque_up->SetTrapExceptions(trap_exceptions);
110 }
111 
112 void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
113   m_opaque_up->SetLanguage(language);
114 }
115 
116 void SBExpressionOptions::SetCancelCallback(
117     lldb::ExpressionCancelCallback callback, void *baton) {
118   m_opaque_up->SetCancelCallback(callback, baton);
119 }
120 
121 bool SBExpressionOptions::GetGenerateDebugInfo() {
122   return m_opaque_up->GetGenerateDebugInfo();
123 }
124 
125 void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
126   return m_opaque_up->SetGenerateDebugInfo(b);
127 }
128 
129 bool SBExpressionOptions::GetSuppressPersistentResult() {
130   return m_opaque_up->GetResultIsInternal();
131 }
132 
133 void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
134   return m_opaque_up->SetResultIsInternal(b);
135 }
136 
137 const char *SBExpressionOptions::GetPrefix() const {
138   return m_opaque_up->GetPrefix();
139 }
140 
141 void SBExpressionOptions::SetPrefix(const char *prefix) {
142   return m_opaque_up->SetPrefix(prefix);
143 }
144 
145 bool SBExpressionOptions::GetAutoApplyFixIts() {
146   return m_opaque_up->GetAutoApplyFixIts();
147 }
148 
149 void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
150   return m_opaque_up->SetAutoApplyFixIts(b);
151 }
152 
153 bool SBExpressionOptions::GetTopLevel() {
154   return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
155 }
156 
157 void SBExpressionOptions::SetTopLevel(bool b) {
158   m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
159                                     : m_opaque_up->default_execution_policy);
160 }
161 
162 bool SBExpressionOptions::GetAllowJIT() {
163   return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
164 }
165 
166 void SBExpressionOptions::SetAllowJIT(bool allow) {
167   m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
168                                         : eExecutionPolicyNever);
169 }
170 
171 EvaluateExpressionOptions *SBExpressionOptions::get() const {
172   return m_opaque_up.get();
173 }
174 
175 EvaluateExpressionOptions &SBExpressionOptions::ref() const {
176   return *(m_opaque_up.get());
177 }
178