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"
15
16using namespace lldb;
17using namespace lldb_private;
18
23
29
32 LLDB_INSTRUMENT_VA(this, rhs);
33
34 if (this != &rhs)
36 return *this;
37}
38
40
43
44 return m_opaque_up->DoesCoerceToId();
45}
46
48 LLDB_INSTRUMENT_VA(this, coerce);
49
50 m_opaque_up->SetCoerceToId(coerce);
51}
52
55
56 return m_opaque_up->DoesUnwindOnError();
57}
58
60 LLDB_INSTRUMENT_VA(this, unwind);
61
62 m_opaque_up->SetUnwindOnError(unwind);
63}
64
67
68 return m_opaque_up->DoesIgnoreBreakpoints();
69}
70
72 LLDB_INSTRUMENT_VA(this, ignore);
73
74 m_opaque_up->SetIgnoreBreakpoints(ignore);
75}
76
82
84 LLDB_INSTRUMENT_VA(this, dynamic);
85
86 m_opaque_up->SetUseDynamic(dynamic);
87}
88
91
92 return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
93}
94
96 LLDB_INSTRUMENT_VA(this, timeout);
97
98 m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(std::nullopt)
99 : std::chrono::microseconds(timeout));
100}
101
103 LLDB_INSTRUMENT_VA(this);
104
105 return m_opaque_up->GetOneThreadTimeout()
106 ? m_opaque_up->GetOneThreadTimeout()->count()
107 : 0;
108}
109
111 LLDB_INSTRUMENT_VA(this, timeout);
112
113 m_opaque_up->SetOneThreadTimeout(timeout == 0
114 ? Timeout<std::micro>(std::nullopt)
115 : std::chrono::microseconds(timeout));
116}
117
119 LLDB_INSTRUMENT_VA(this);
120
121 return m_opaque_up->GetTryAllThreads();
122}
123
125 LLDB_INSTRUMENT_VA(this, run_others);
126
127 m_opaque_up->SetTryAllThreads(run_others);
128}
129
131 LLDB_INSTRUMENT_VA(this);
132
133 return m_opaque_up->GetStopOthers();
134}
135
137 LLDB_INSTRUMENT_VA(this, run_others);
138
139 m_opaque_up->SetStopOthers(run_others);
140}
141
143 LLDB_INSTRUMENT_VA(this);
144
145 return m_opaque_up->GetTrapExceptions();
146}
147
148void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
149 LLDB_INSTRUMENT_VA(this, trap_exceptions);
150
151 m_opaque_up->SetTrapExceptions(trap_exceptions);
152}
153
155 LLDB_INSTRUMENT_VA(this, language);
156
157 m_opaque_up->SetLanguage(language);
158}
159
160void SBExpressionOptions::SetLanguage(lldb::SBSourceLanguageName name,
161 uint32_t version) {
162 LLDB_INSTRUMENT_VA(this, name, version);
163
164 m_opaque_up->SetLanguage(name, version);
165}
166
168 lldb::ExpressionCancelCallback callback, void *baton) {
169 LLDB_INSTRUMENT_VA(this, callback, baton);
170
171 m_opaque_up->SetCancelCallback(callback, baton);
172}
173
175 LLDB_INSTRUMENT_VA(this);
176
177 return m_opaque_up->GetGenerateDebugInfo();
178}
179
181 LLDB_INSTRUMENT_VA(this, b);
182
183 return m_opaque_up->SetGenerateDebugInfo(b);
184}
185
187 LLDB_INSTRUMENT_VA(this);
188
189 return m_opaque_up->GetSuppressPersistentResult();
190}
191
193 LLDB_INSTRUMENT_VA(this, b);
194
195 return m_opaque_up->SetSuppressPersistentResult(b);
196}
197
199 LLDB_INSTRUMENT_VA(this);
200
201 return ConstString(m_opaque_up->GetPrefix()).GetCString();
202}
203
204void SBExpressionOptions::SetPrefix(const char *prefix) {
205 LLDB_INSTRUMENT_VA(this, prefix);
206
207 return m_opaque_up->SetPrefix(prefix);
208}
209
211 LLDB_INSTRUMENT_VA(this);
212
213 return m_opaque_up->GetAutoApplyFixIts();
214}
215
217 LLDB_INSTRUMENT_VA(this, b);
218
219 return m_opaque_up->SetAutoApplyFixIts(b);
220}
221
223 LLDB_INSTRUMENT_VA(this);
224
225 return m_opaque_up->GetRetriesWithFixIts();
226}
227
229 LLDB_INSTRUMENT_VA(this, retries);
230
231 return m_opaque_up->SetRetriesWithFixIts(retries);
232}
233
235 LLDB_INSTRUMENT_VA(this);
236
237 return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
238}
239
241 LLDB_INSTRUMENT_VA(this, b);
242
243 m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
244 : m_opaque_up->default_execution_policy);
245}
246
248 LLDB_INSTRUMENT_VA(this);
249
250 return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
251}
252
254 LLDB_INSTRUMENT_VA(this, allow);
255
256 m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
258}
259
260// FIXME: the language plugin should expression options dynamically and
261// we should validate here (by asking the language plugin) that the options
262// being set/retrieved are actually valid options.
263
265 SBError &error) const {
266 LLDB_INSTRUMENT_VA(this, option_name, error);
267
268 error.Clear();
269
270 auto value_or_err = m_opaque_up->GetBooleanLanguageOption(option_name);
271 if (!value_or_err) {
272 error.SetErrorString(llvm::toString(value_or_err.takeError()).c_str());
273 return false;
274 }
275
276 return *value_or_err;
277}
278
280 bool value) {
281 LLDB_INSTRUMENT_VA(this, option_name, value);
282
284
285 if (llvm::Error err =
286 m_opaque_up->SetBooleanLanguageOption(option_name, value))
287 error.SetErrorString(llvm::toString(std::move(err)).c_str());
288
289 return error;
290}
291
295
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 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
A uniqued constant string class.
Definition ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
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