LLDB mainline
SBExpressionOptions.cpp
Go to the documentation of this file.
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
10#include "Utils.h"
11#include "lldb/API/SBError.h"
12#include "lldb/API/SBStream.h"
13#include "lldb/Target/Target.h"
16
17using namespace lldb;
18using namespace lldb_private;
19
24
30
33 LLDB_INSTRUMENT_VA(this, rhs);
34
35 if (this != &rhs)
37 return *this;
38}
39
41
44
45 return m_opaque_up->DoesCoerceToId();
46}
47
49 LLDB_INSTRUMENT_VA(this, coerce);
50
51 m_opaque_up->SetCoerceToId(coerce);
52}
53
56
57 return m_opaque_up->DoesUnwindOnError();
58}
59
61 LLDB_INSTRUMENT_VA(this, unwind);
62
63 m_opaque_up->SetUnwindOnError(unwind);
64}
65
68
69 return m_opaque_up->DoesIgnoreBreakpoints();
70}
71
73 LLDB_INSTRUMENT_VA(this, ignore);
74
75 m_opaque_up->SetIgnoreBreakpoints(ignore);
76}
77
83
85 LLDB_INSTRUMENT_VA(this, dynamic);
86
87 m_opaque_up->SetUseDynamic(dynamic);
88}
89
92
93 return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
94}
95
97 LLDB_INSTRUMENT_VA(this, timeout);
98
99 m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(std::nullopt)
100 : std::chrono::microseconds(timeout));
101}
102
104 LLDB_INSTRUMENT_VA(this);
105
106 return m_opaque_up->GetOneThreadTimeout()
107 ? m_opaque_up->GetOneThreadTimeout()->count()
108 : 0;
109}
110
112 LLDB_INSTRUMENT_VA(this, timeout);
113
114 m_opaque_up->SetOneThreadTimeout(timeout == 0
115 ? Timeout<std::micro>(std::nullopt)
116 : std::chrono::microseconds(timeout));
117}
118
120 LLDB_INSTRUMENT_VA(this);
121
122 return m_opaque_up->GetTryAllThreads();
123}
124
126 LLDB_INSTRUMENT_VA(this, run_others);
127
128 m_opaque_up->SetTryAllThreads(run_others);
129}
130
132 LLDB_INSTRUMENT_VA(this);
133
134 return m_opaque_up->GetStopOthers();
135}
136
138 LLDB_INSTRUMENT_VA(this, run_others);
139
140 m_opaque_up->SetStopOthers(run_others);
141}
142
144 LLDB_INSTRUMENT_VA(this);
145
146 return m_opaque_up->GetTrapExceptions();
147}
148
149void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
150 LLDB_INSTRUMENT_VA(this, trap_exceptions);
151
152 m_opaque_up->SetTrapExceptions(trap_exceptions);
153}
154
156 LLDB_INSTRUMENT_VA(this);
157
158 return m_opaque_up->GetStopOnFork();
159}
160
161void SBExpressionOptions::SetStopOnFork(bool stop_on_fork) {
162 LLDB_INSTRUMENT_VA(this, stop_on_fork);
163
164 m_opaque_up->SetStopOnFork(stop_on_fork);
165}
166
168 LLDB_INSTRUMENT_VA(this, language);
169
170 m_opaque_up->SetLanguage(language);
171}
172
173void SBExpressionOptions::SetLanguage(lldb::SBSourceLanguageName name,
174 uint32_t version) {
175 LLDB_INSTRUMENT_VA(this, name, version);
176
177 m_opaque_up->SetLanguage(name, version);
178}
179
181 lldb::ExpressionCancelCallback callback, void *baton) {
182 LLDB_INSTRUMENT_VA(this, callback, baton);
183
184 m_opaque_up->SetCancelCallback(callback, baton);
185}
186
188 LLDB_INSTRUMENT_VA(this);
189
190 return m_opaque_up->GetGenerateDebugInfo();
191}
192
194 LLDB_INSTRUMENT_VA(this, b);
195
196 return m_opaque_up->SetGenerateDebugInfo(b);
197}
198
200 LLDB_INSTRUMENT_VA(this);
201
202 return m_opaque_up->GetSuppressPersistentResult();
203}
204
206 LLDB_INSTRUMENT_VA(this, b);
207
208 return m_opaque_up->SetSuppressPersistentResult(b);
209}
210
212 LLDB_INSTRUMENT_VA(this);
213
214 return StringPool::GetSystemPool().Intern(m_opaque_up->GetPrefix());
215}
216
217void SBExpressionOptions::SetPrefix(const char *prefix) {
218 LLDB_INSTRUMENT_VA(this, prefix);
219
220 return m_opaque_up->SetPrefix(prefix);
221}
222
224 LLDB_INSTRUMENT_VA(this);
225
226 return m_opaque_up->GetAutoApplyFixIts();
227}
228
230 LLDB_INSTRUMENT_VA(this, b);
231
232 return m_opaque_up->SetAutoApplyFixIts(b);
233}
234
236 LLDB_INSTRUMENT_VA(this);
237
238 return m_opaque_up->GetRetriesWithFixIts();
239}
240
242 LLDB_INSTRUMENT_VA(this, retries);
243
244 return m_opaque_up->SetRetriesWithFixIts(retries);
245}
246
248 LLDB_INSTRUMENT_VA(this);
249
250 return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
251}
252
254 LLDB_INSTRUMENT_VA(this, b);
255
256 m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
257 : m_opaque_up->default_execution_policy);
258}
259
261 LLDB_INSTRUMENT_VA(this);
262
263 return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
264}
265
267 LLDB_INSTRUMENT_VA(this, allow);
268
269 m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
271}
272
273// FIXME: the language plugin should expression options dynamically and
274// we should validate here (by asking the language plugin) that the options
275// being set/retrieved are actually valid options.
276
278 SBError &error) const {
279 LLDB_INSTRUMENT_VA(this, option_name, error);
280
281 error.Clear();
282
283 auto value_or_err = m_opaque_up->GetBooleanLanguageOption(option_name);
284 if (!value_or_err) {
285 error.SetErrorString(llvm::toString(value_or_err.takeError()).c_str());
286 return false;
287 }
288
289 return *value_or_err;
290}
291
293 bool value) {
294 LLDB_INSTRUMENT_VA(this, option_name, value);
295
297
298 if (llvm::Error err =
299 m_opaque_up->SetBooleanLanguageOption(option_name, value))
300 error.SetErrorString(llvm::toString(std::move(err)).c_str());
301
302 return error;
303}
304
306 LLDB_INSTRUMENT_VA(this);
307
308 return m_opaque_up->GetTryDILFirst();
309}
310
312 LLDB_INSTRUMENT_VA(this, b);
313
314 m_opaque_up->SetTryDILFirst(b);
315}
316
320
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT_VA(...)
void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton)
bool GetBooleanLanguageOption(const char *option_name, SBError &error) const
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
void SetStopOnFork(bool stop_on_fork=false)
void SetLanguage(lldb::LanguageType language)
lldb_private::EvaluateExpressionOptions & ref() const
void SetSuppressPersistentResult(bool b=false)
void SetTryAllThreads(bool run_others=true)
void SetRetriesWithFixIts(uint64_t retries)
std::unique_ptr< lldb_private::EvaluateExpressionOptions > m_opaque_up
void SetTrapExceptions(bool trap_exceptions=true)
void SetTimeoutInMicroSeconds(uint32_t timeout=0)
void SetStopOthers(bool stop_others=true)
void SetIgnoreBreakpoints(bool ignore=true)
void SetOneThreadTimeoutInMicroSeconds(uint32_t timeout=0)
uint32_t GetTimeoutInMicroSeconds() const
void SetCoerceResultToId(bool coerce=true)
SBError SetBooleanLanguageOption(const char *option_name, bool value)
const SBExpressionOptions & operator=(const lldb::SBExpressionOptions &rhs)
lldb_private::EvaluateExpressionOptions * get() const
void SetUnwindOnError(bool unwind=true)
lldb::DynamicValueType GetFetchDynamicValue() const
void SetPrefix(const char *prefix)
uint32_t GetOneThreadTimeoutInMicroSeconds() const
const char * Intern(llvm::StringRef str) const
Definition StringPool.h:78
static StringPoolRef GetSystemPool()
The system pool. Only valid between Initialize and Terminate.
A class that represents a running process on the host machine.
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition Utils.h:17
LanguageType
Programming language type.
bool(* ExpressionCancelCallback)(lldb::ExpressionEvaluationPhase phase, void *baton)
Definition lldb-types.h:75