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