Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / source / API / SBExpressionOptions.cpp
blobbd81a04596b10dd97a6fdaf73af6901a0bcab692
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 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBExpressionOptions.h"
10 #include "Utils.h"
11 #include "lldb/API/SBStream.h"
12 #include "lldb/Target/Target.h"
13 #include "lldb/Utility/Instrumentation.h"
15 using namespace lldb;
16 using namespace lldb_private;
18 SBExpressionOptions::SBExpressionOptions()
19 : m_opaque_up(new EvaluateExpressionOptions()) {
20 LLDB_INSTRUMENT_VA(this);
23 SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) {
24 LLDB_INSTRUMENT_VA(this, rhs);
26 m_opaque_up = clone(rhs.m_opaque_up);
29 const SBExpressionOptions &SBExpressionOptions::
30 operator=(const SBExpressionOptions &rhs) {
31 LLDB_INSTRUMENT_VA(this, rhs);
33 if (this != &rhs)
34 m_opaque_up = clone(rhs.m_opaque_up);
35 return *this;
38 SBExpressionOptions::~SBExpressionOptions() = default;
40 bool SBExpressionOptions::GetCoerceResultToId() const {
41 LLDB_INSTRUMENT_VA(this);
43 return m_opaque_up->DoesCoerceToId();
46 void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
47 LLDB_INSTRUMENT_VA(this, coerce);
49 m_opaque_up->SetCoerceToId(coerce);
52 bool SBExpressionOptions::GetUnwindOnError() const {
53 LLDB_INSTRUMENT_VA(this);
55 return m_opaque_up->DoesUnwindOnError();
58 void SBExpressionOptions::SetUnwindOnError(bool unwind) {
59 LLDB_INSTRUMENT_VA(this, unwind);
61 m_opaque_up->SetUnwindOnError(unwind);
64 bool SBExpressionOptions::GetIgnoreBreakpoints() const {
65 LLDB_INSTRUMENT_VA(this);
67 return m_opaque_up->DoesIgnoreBreakpoints();
70 void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
71 LLDB_INSTRUMENT_VA(this, ignore);
73 m_opaque_up->SetIgnoreBreakpoints(ignore);
76 lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
77 LLDB_INSTRUMENT_VA(this);
79 return m_opaque_up->GetUseDynamic();
82 void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
83 LLDB_INSTRUMENT_VA(this, dynamic);
85 m_opaque_up->SetUseDynamic(dynamic);
88 uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
89 LLDB_INSTRUMENT_VA(this);
91 return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
94 void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
95 LLDB_INSTRUMENT_VA(this, timeout);
97 m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(std::nullopt)
98 : std::chrono::microseconds(timeout));
101 uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
102 LLDB_INSTRUMENT_VA(this);
104 return m_opaque_up->GetOneThreadTimeout()
105 ? m_opaque_up->GetOneThreadTimeout()->count()
106 : 0;
109 void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
110 LLDB_INSTRUMENT_VA(this, timeout);
112 m_opaque_up->SetOneThreadTimeout(timeout == 0
113 ? Timeout<std::micro>(std::nullopt)
114 : std::chrono::microseconds(timeout));
117 bool SBExpressionOptions::GetTryAllThreads() const {
118 LLDB_INSTRUMENT_VA(this);
120 return m_opaque_up->GetTryAllThreads();
123 void SBExpressionOptions::SetTryAllThreads(bool run_others) {
124 LLDB_INSTRUMENT_VA(this, run_others);
126 m_opaque_up->SetTryAllThreads(run_others);
129 bool SBExpressionOptions::GetStopOthers() const {
130 LLDB_INSTRUMENT_VA(this);
132 return m_opaque_up->GetStopOthers();
135 void SBExpressionOptions::SetStopOthers(bool run_others) {
136 LLDB_INSTRUMENT_VA(this, run_others);
138 m_opaque_up->SetStopOthers(run_others);
141 bool SBExpressionOptions::GetTrapExceptions() const {
142 LLDB_INSTRUMENT_VA(this);
144 return m_opaque_up->GetTrapExceptions();
147 void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
148 LLDB_INSTRUMENT_VA(this, trap_exceptions);
150 m_opaque_up->SetTrapExceptions(trap_exceptions);
153 void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
154 LLDB_INSTRUMENT_VA(this, language);
156 m_opaque_up->SetLanguage(language);
159 void SBExpressionOptions::SetCancelCallback(
160 lldb::ExpressionCancelCallback callback, void *baton) {
161 LLDB_INSTRUMENT_VA(this, callback, baton);
163 m_opaque_up->SetCancelCallback(callback, baton);
166 bool SBExpressionOptions::GetGenerateDebugInfo() {
167 LLDB_INSTRUMENT_VA(this);
169 return m_opaque_up->GetGenerateDebugInfo();
172 void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
173 LLDB_INSTRUMENT_VA(this, b);
175 return m_opaque_up->SetGenerateDebugInfo(b);
178 bool SBExpressionOptions::GetSuppressPersistentResult() {
179 LLDB_INSTRUMENT_VA(this);
181 return m_opaque_up->GetSuppressPersistentResult();
184 void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
185 LLDB_INSTRUMENT_VA(this, b);
187 return m_opaque_up->SetSuppressPersistentResult(b);
190 const char *SBExpressionOptions::GetPrefix() const {
191 LLDB_INSTRUMENT_VA(this);
193 return ConstString(m_opaque_up->GetPrefix()).GetCString();
196 void SBExpressionOptions::SetPrefix(const char *prefix) {
197 LLDB_INSTRUMENT_VA(this, prefix);
199 return m_opaque_up->SetPrefix(prefix);
202 bool SBExpressionOptions::GetAutoApplyFixIts() {
203 LLDB_INSTRUMENT_VA(this);
205 return m_opaque_up->GetAutoApplyFixIts();
208 void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
209 LLDB_INSTRUMENT_VA(this, b);
211 return m_opaque_up->SetAutoApplyFixIts(b);
214 uint64_t SBExpressionOptions::GetRetriesWithFixIts() {
215 LLDB_INSTRUMENT_VA(this);
217 return m_opaque_up->GetRetriesWithFixIts();
220 void SBExpressionOptions::SetRetriesWithFixIts(uint64_t retries) {
221 LLDB_INSTRUMENT_VA(this, retries);
223 return m_opaque_up->SetRetriesWithFixIts(retries);
226 bool SBExpressionOptions::GetTopLevel() {
227 LLDB_INSTRUMENT_VA(this);
229 return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
232 void SBExpressionOptions::SetTopLevel(bool b) {
233 LLDB_INSTRUMENT_VA(this, b);
235 m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
236 : m_opaque_up->default_execution_policy);
239 bool SBExpressionOptions::GetAllowJIT() {
240 LLDB_INSTRUMENT_VA(this);
242 return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
245 void SBExpressionOptions::SetAllowJIT(bool allow) {
246 LLDB_INSTRUMENT_VA(this, allow);
248 m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
249 : eExecutionPolicyNever);
252 EvaluateExpressionOptions *SBExpressionOptions::get() const {
253 return m_opaque_up.get();
256 EvaluateExpressionOptions &SBExpressionOptions::ref() const {
257 return *m_opaque_up;