]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/source/API/SBExpressionOptions.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / source / API / SBExpressionOptions.cpp
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 "SBReproducerPrivate.h"
12 #include "Utils.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/Target/Target.h"
15
16 using namespace lldb;
17 using namespace lldb_private;
18
19 SBExpressionOptions::SBExpressionOptions()
20     : m_opaque_up(new EvaluateExpressionOptions()) {
21   LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExpressionOptions);
22 }
23
24 SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs)
25     : m_opaque_up() {
26   LLDB_RECORD_CONSTRUCTOR(SBExpressionOptions,
27                           (const lldb::SBExpressionOptions &), rhs);
28
29   m_opaque_up = clone(rhs.m_opaque_up);
30 }
31
32 const SBExpressionOptions &SBExpressionOptions::
33 operator=(const SBExpressionOptions &rhs) {
34   LLDB_RECORD_METHOD(
35       const lldb::SBExpressionOptions &,
36       SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &), rhs);
37
38   if (this != &rhs)
39     m_opaque_up = clone(rhs.m_opaque_up);
40   return LLDB_RECORD_RESULT(*this);
41 }
42
43 SBExpressionOptions::~SBExpressionOptions() {}
44
45 bool SBExpressionOptions::GetCoerceResultToId() const {
46   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
47                                    GetCoerceResultToId);
48
49   return m_opaque_up->DoesCoerceToId();
50 }
51
52 void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
53   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetCoerceResultToId, (bool),
54                      coerce);
55
56   m_opaque_up->SetCoerceToId(coerce);
57 }
58
59 bool SBExpressionOptions::GetUnwindOnError() const {
60   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetUnwindOnError);
61
62   return m_opaque_up->DoesUnwindOnError();
63 }
64
65 void SBExpressionOptions::SetUnwindOnError(bool unwind) {
66   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool),
67                      unwind);
68
69   m_opaque_up->SetUnwindOnError(unwind);
70 }
71
72 bool SBExpressionOptions::GetIgnoreBreakpoints() const {
73   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
74                                    GetIgnoreBreakpoints);
75
76   return m_opaque_up->DoesIgnoreBreakpoints();
77 }
78
79 void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
80   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, (bool),
81                      ignore);
82
83   m_opaque_up->SetIgnoreBreakpoints(ignore);
84 }
85
86 lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
87   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBExpressionOptions,
88                                    GetFetchDynamicValue);
89
90   return m_opaque_up->GetUseDynamic();
91 }
92
93 void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
94   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetFetchDynamicValue,
95                      (lldb::DynamicValueType), dynamic);
96
97   m_opaque_up->SetUseDynamic(dynamic);
98 }
99
100 uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
101   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions,
102                                    GetTimeoutInMicroSeconds);
103
104   return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
105 }
106
107 void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
108   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds,
109                      (uint32_t), timeout);
110
111   m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
112                                        : std::chrono::microseconds(timeout));
113 }
114
115 uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
116   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions,
117                                    GetOneThreadTimeoutInMicroSeconds);
118
119   return m_opaque_up->GetOneThreadTimeout()
120              ? m_opaque_up->GetOneThreadTimeout()->count()
121              : 0;
122 }
123
124 void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
125   LLDB_RECORD_METHOD(void, SBExpressionOptions,
126                      SetOneThreadTimeoutInMicroSeconds, (uint32_t), timeout);
127
128   m_opaque_up->SetOneThreadTimeout(timeout == 0
129                                        ? Timeout<std::micro>(llvm::None)
130                                        : std::chrono::microseconds(timeout));
131 }
132
133 bool SBExpressionOptions::GetTryAllThreads() const {
134   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetTryAllThreads);
135
136   return m_opaque_up->GetTryAllThreads();
137 }
138
139 void SBExpressionOptions::SetTryAllThreads(bool run_others) {
140   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool),
141                      run_others);
142
143   m_opaque_up->SetTryAllThreads(run_others);
144 }
145
146 bool SBExpressionOptions::GetStopOthers() const {
147   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetStopOthers);
148
149   return m_opaque_up->GetStopOthers();
150 }
151
152 void SBExpressionOptions::SetStopOthers(bool run_others) {
153   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetStopOthers, (bool),
154                      run_others);
155
156   m_opaque_up->SetStopOthers(run_others);
157 }
158
159 bool SBExpressionOptions::GetTrapExceptions() const {
160   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
161                                    GetTrapExceptions);
162
163   return m_opaque_up->GetTrapExceptions();
164 }
165
166 void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
167   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool),
168                      trap_exceptions);
169
170   m_opaque_up->SetTrapExceptions(trap_exceptions);
171 }
172
173 void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
174   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetLanguage,
175                      (lldb::LanguageType), language);
176
177   m_opaque_up->SetLanguage(language);
178 }
179
180 void SBExpressionOptions::SetCancelCallback(
181     lldb::ExpressionCancelCallback callback, void *baton) {
182   LLDB_RECORD_DUMMY(void, SBExpressionOptions, SetCancelCallback,
183                     (lldb::ExpressionCancelCallback, void *), callback, baton);
184
185   m_opaque_up->SetCancelCallback(callback, baton);
186 }
187
188 bool SBExpressionOptions::GetGenerateDebugInfo() {
189   LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetGenerateDebugInfo);
190
191   return m_opaque_up->GetGenerateDebugInfo();
192 }
193
194 void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
195   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, (bool),
196                      b);
197
198   return m_opaque_up->SetGenerateDebugInfo(b);
199 }
200
201 bool SBExpressionOptions::GetSuppressPersistentResult() {
202   LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions,
203                              GetSuppressPersistentResult);
204
205   return m_opaque_up->GetResultIsInternal();
206 }
207
208 void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
209   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult,
210                      (bool), b);
211
212   return m_opaque_up->SetResultIsInternal(b);
213 }
214
215 const char *SBExpressionOptions::GetPrefix() const {
216   LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBExpressionOptions,
217                                    GetPrefix);
218
219   return m_opaque_up->GetPrefix();
220 }
221
222 void SBExpressionOptions::SetPrefix(const char *prefix) {
223   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetPrefix, (const char *),
224                      prefix);
225
226   return m_opaque_up->SetPrefix(prefix);
227 }
228
229 bool SBExpressionOptions::GetAutoApplyFixIts() {
230   LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAutoApplyFixIts);
231
232   return m_opaque_up->GetAutoApplyFixIts();
233 }
234
235 void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
236   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool), b);
237
238   return m_opaque_up->SetAutoApplyFixIts(b);
239 }
240
241 bool SBExpressionOptions::GetTopLevel() {
242   LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel);
243
244   return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
245 }
246
247 void SBExpressionOptions::SetTopLevel(bool b) {
248   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTopLevel, (bool), b);
249
250   m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
251                                     : m_opaque_up->default_execution_policy);
252 }
253
254 bool SBExpressionOptions::GetAllowJIT() {
255   LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAllowJIT);
256
257   return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
258 }
259
260 void SBExpressionOptions::SetAllowJIT(bool allow) {
261   LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool), allow);
262
263   m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
264                                         : eExecutionPolicyNever);
265 }
266
267 EvaluateExpressionOptions *SBExpressionOptions::get() const {
268   return m_opaque_up.get();
269 }
270
271 EvaluateExpressionOptions &SBExpressionOptions::ref() const {
272   return *(m_opaque_up.get());
273 }
274
275 namespace lldb_private {
276 namespace repro {
277
278 template <>
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,
287                              ());
288   LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetCoerceResultToId,
289                        (bool));
290   LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetUnwindOnError, ());
291   LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool));
292   LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetIgnoreBreakpoints,
293                              ());
294   LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints,
295                        (bool));
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,
303                        (uint32_t));
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,
313                              ());
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,
319                        (bool));
320   LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetSuppressPersistentResult,
321                        ());
322   LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult,
323                        (bool));
324   LLDB_REGISTER_METHOD_CONST(const char *, SBExpressionOptions, GetPrefix,
325                              ());
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));
333 }
334
335 }
336 }