180814287SRaphael Isemann //===-- SBExpressionOptions.cpp -------------------------------------------===//
235e1bda6SJim Ingham //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
635e1bda6SJim Ingham //
735e1bda6SJim Ingham //===----------------------------------------------------------------------===//
835e1bda6SJim Ingham
935e1bda6SJim Ingham #include "lldb/API/SBExpressionOptions.h"
10bd4bf82aSJonas Devlieghere #include "Utils.h"
1135e1bda6SJim Ingham #include "lldb/API/SBStream.h"
1235e1bda6SJim Ingham #include "lldb/Target/Target.h"
13*1755f5b1SJonas Devlieghere #include "lldb/Utility/Instrumentation.h"
1435e1bda6SJim Ingham
1535e1bda6SJim Ingham using namespace lldb;
1635e1bda6SJim Ingham using namespace lldb_private;
1735e1bda6SJim Ingham
SBExpressionOptions()18b9c1b51eSKate Stone SBExpressionOptions::SBExpressionOptions()
19baf5664fSJonas Devlieghere : m_opaque_up(new EvaluateExpressionOptions()) {
20*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
21baf5664fSJonas Devlieghere }
2235e1bda6SJim Ingham
SBExpressionOptions(const SBExpressionOptions & rhs)23a3436f73SKazu Hirata SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) {
24*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, rhs);
25baf5664fSJonas Devlieghere
26bd4bf82aSJonas Devlieghere m_opaque_up = clone(rhs.m_opaque_up);
2735e1bda6SJim Ingham }
2835e1bda6SJim Ingham
29b9c1b51eSKate Stone const SBExpressionOptions &SBExpressionOptions::
operator =(const SBExpressionOptions & rhs)30b9c1b51eSKate Stone operator=(const SBExpressionOptions &rhs) {
31*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, rhs);
32baf5664fSJonas Devlieghere
33bd4bf82aSJonas Devlieghere if (this != &rhs)
34bd4bf82aSJonas Devlieghere m_opaque_up = clone(rhs.m_opaque_up);
35d232abc3SJonas Devlieghere return *this;
3635e1bda6SJim Ingham }
3735e1bda6SJim Ingham
38866b7a65SJonas Devlieghere SBExpressionOptions::~SBExpressionOptions() = default;
3935e1bda6SJim Ingham
GetCoerceResultToId() const40b9c1b51eSKate Stone bool SBExpressionOptions::GetCoerceResultToId() const {
41*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
42baf5664fSJonas Devlieghere
43d5b44036SJonas Devlieghere return m_opaque_up->DoesCoerceToId();
4435e1bda6SJim Ingham }
4535e1bda6SJim Ingham
SetCoerceResultToId(bool coerce)46b9c1b51eSKate Stone void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
47*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, coerce);
48baf5664fSJonas Devlieghere
49d5b44036SJonas Devlieghere m_opaque_up->SetCoerceToId(coerce);
5035e1bda6SJim Ingham }
5135e1bda6SJim Ingham
GetUnwindOnError() const52b9c1b51eSKate Stone bool SBExpressionOptions::GetUnwindOnError() const {
53*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
54baf5664fSJonas Devlieghere
55d5b44036SJonas Devlieghere return m_opaque_up->DoesUnwindOnError();
5635e1bda6SJim Ingham }
5735e1bda6SJim Ingham
SetUnwindOnError(bool unwind)58b9c1b51eSKate Stone void SBExpressionOptions::SetUnwindOnError(bool unwind) {
59*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, unwind);
60baf5664fSJonas Devlieghere
61d5b44036SJonas Devlieghere m_opaque_up->SetUnwindOnError(unwind);
6235e1bda6SJim Ingham }
6335e1bda6SJim Ingham
GetIgnoreBreakpoints() const64b9c1b51eSKate Stone bool SBExpressionOptions::GetIgnoreBreakpoints() const {
65*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
66baf5664fSJonas Devlieghere
67d5b44036SJonas Devlieghere return m_opaque_up->DoesIgnoreBreakpoints();
68184e9811SJim Ingham }
69184e9811SJim Ingham
SetIgnoreBreakpoints(bool ignore)70b9c1b51eSKate Stone void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
71*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, ignore);
72baf5664fSJonas Devlieghere
73d5b44036SJonas Devlieghere m_opaque_up->SetIgnoreBreakpoints(ignore);
74184e9811SJim Ingham }
75184e9811SJim Ingham
GetFetchDynamicValue() const76b9c1b51eSKate Stone lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
77*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
78baf5664fSJonas Devlieghere
79d5b44036SJonas Devlieghere return m_opaque_up->GetUseDynamic();
8035e1bda6SJim Ingham }
8135e1bda6SJim Ingham
SetFetchDynamicValue(lldb::DynamicValueType dynamic)82b9c1b51eSKate Stone void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
83*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, dynamic);
84baf5664fSJonas Devlieghere
85d5b44036SJonas Devlieghere m_opaque_up->SetUseDynamic(dynamic);
8635e1bda6SJim Ingham }
8735e1bda6SJim Ingham
GetTimeoutInMicroSeconds() const88b9c1b51eSKate Stone uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
89*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
90baf5664fSJonas Devlieghere
91d5b44036SJonas Devlieghere return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
9235e1bda6SJim Ingham }
9335e1bda6SJim Ingham
SetTimeoutInMicroSeconds(uint32_t timeout)94b9c1b51eSKate Stone void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
95*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, timeout);
96baf5664fSJonas Devlieghere
97d5b44036SJonas Devlieghere m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
9843d35418SPavel Labath : std::chrono::microseconds(timeout));
9935e1bda6SJim Ingham }
10035e1bda6SJim Ingham
GetOneThreadTimeoutInMicroSeconds() const101b9c1b51eSKate Stone uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
102*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
103baf5664fSJonas Devlieghere
104d5b44036SJonas Devlieghere return m_opaque_up->GetOneThreadTimeout()
105d5b44036SJonas Devlieghere ? m_opaque_up->GetOneThreadTimeout()->count()
106d5b44036SJonas Devlieghere : 0;
107914f4e70SJim Ingham }
108914f4e70SJim Ingham
SetOneThreadTimeoutInMicroSeconds(uint32_t timeout)109b9c1b51eSKate Stone void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
110*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, timeout);
111baf5664fSJonas Devlieghere
112d5b44036SJonas Devlieghere m_opaque_up->SetOneThreadTimeout(timeout == 0
11343d35418SPavel Labath ? Timeout<std::micro>(llvm::None)
11443d35418SPavel Labath : std::chrono::microseconds(timeout));
115914f4e70SJim Ingham }
116914f4e70SJim Ingham
GetTryAllThreads() const117b9c1b51eSKate Stone bool SBExpressionOptions::GetTryAllThreads() const {
118*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
119baf5664fSJonas Devlieghere
120d5b44036SJonas Devlieghere return m_opaque_up->GetTryAllThreads();
12135e1bda6SJim Ingham }
12235e1bda6SJim Ingham
SetTryAllThreads(bool run_others)123b9c1b51eSKate Stone void SBExpressionOptions::SetTryAllThreads(bool run_others) {
124*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, run_others);
125baf5664fSJonas Devlieghere
126d5b44036SJonas Devlieghere m_opaque_up->SetTryAllThreads(run_others);
1276fbc48bcSJim Ingham }
1286fbc48bcSJim Ingham
GetStopOthers() const129b9c1b51eSKate Stone bool SBExpressionOptions::GetStopOthers() const {
130*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
131baf5664fSJonas Devlieghere
132d5b44036SJonas Devlieghere return m_opaque_up->GetStopOthers();
133286fb1efSJim Ingham }
134286fb1efSJim Ingham
SetStopOthers(bool run_others)135b9c1b51eSKate Stone void SBExpressionOptions::SetStopOthers(bool run_others) {
136*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, run_others);
137baf5664fSJonas Devlieghere
138d5b44036SJonas Devlieghere m_opaque_up->SetStopOthers(run_others);
139286fb1efSJim Ingham }
140286fb1efSJim Ingham
GetTrapExceptions() const141b9c1b51eSKate Stone bool SBExpressionOptions::GetTrapExceptions() const {
142*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
143baf5664fSJonas Devlieghere
144d5b44036SJonas Devlieghere return m_opaque_up->GetTrapExceptions();
1456fbc48bcSJim Ingham }
1466fbc48bcSJim Ingham
SetTrapExceptions(bool trap_exceptions)147b9c1b51eSKate Stone void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
148*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, trap_exceptions);
149baf5664fSJonas Devlieghere
150d5b44036SJonas Devlieghere m_opaque_up->SetTrapExceptions(trap_exceptions);
15135e1bda6SJim Ingham }
15235e1bda6SJim Ingham
SetLanguage(lldb::LanguageType language)153b9c1b51eSKate Stone void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
154*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, language);
155baf5664fSJonas Devlieghere
156d5b44036SJonas Devlieghere m_opaque_up->SetLanguage(language);
157705b1809SJason Molenda }
158705b1809SJason Molenda
SetCancelCallback(lldb::ExpressionCancelCallback callback,void * baton)159b9c1b51eSKate Stone void SBExpressionOptions::SetCancelCallback(
160b9c1b51eSKate Stone lldb::ExpressionCancelCallback callback, void *baton) {
161*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, callback, baton);
1620d7b0c96SJonas Devlieghere
163d5b44036SJonas Devlieghere m_opaque_up->SetCancelCallback(callback, baton);
1641624a2d3SJim Ingham }
1651624a2d3SJim Ingham
GetGenerateDebugInfo()166b9c1b51eSKate Stone bool SBExpressionOptions::GetGenerateDebugInfo() {
167*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
168baf5664fSJonas Devlieghere
169d5b44036SJonas Devlieghere return m_opaque_up->GetGenerateDebugInfo();
170205ca1e8SGreg Clayton }
171205ca1e8SGreg Clayton
SetGenerateDebugInfo(bool b)172b9c1b51eSKate Stone void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
173*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, b);
174baf5664fSJonas Devlieghere
175d5b44036SJonas Devlieghere return m_opaque_up->SetGenerateDebugInfo(b);
176205ca1e8SGreg Clayton }
177205ca1e8SGreg Clayton
GetSuppressPersistentResult()178b9c1b51eSKate Stone bool SBExpressionOptions::GetSuppressPersistentResult() {
179*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
180baf5664fSJonas Devlieghere
181d5b44036SJonas Devlieghere return m_opaque_up->GetResultIsInternal();
1827ab079b6SJim Ingham }
1837ab079b6SJim Ingham
SetSuppressPersistentResult(bool b)184b9c1b51eSKate Stone void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
185*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, b);
186baf5664fSJonas Devlieghere
187d5b44036SJonas Devlieghere return m_opaque_up->SetResultIsInternal(b);
1887ab079b6SJim Ingham }
1897ab079b6SJim Ingham
GetPrefix() const190b9c1b51eSKate Stone const char *SBExpressionOptions::GetPrefix() const {
191*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
192baf5664fSJonas Devlieghere
193d5b44036SJonas Devlieghere return m_opaque_up->GetPrefix();
1944e1042e1SGreg Clayton }
1954e1042e1SGreg Clayton
SetPrefix(const char * prefix)196b9c1b51eSKate Stone void SBExpressionOptions::SetPrefix(const char *prefix) {
197*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, prefix);
198baf5664fSJonas Devlieghere
199d5b44036SJonas Devlieghere return m_opaque_up->SetPrefix(prefix);
2004e1042e1SGreg Clayton }
2017ab079b6SJim Ingham
GetAutoApplyFixIts()202b9c1b51eSKate Stone bool SBExpressionOptions::GetAutoApplyFixIts() {
203*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
204baf5664fSJonas Devlieghere
205d5b44036SJonas Devlieghere return m_opaque_up->GetAutoApplyFixIts();
206a1e541bfSJim Ingham }
207a1e541bfSJim Ingham
SetAutoApplyFixIts(bool b)208b9c1b51eSKate Stone void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
209*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, b);
210baf5664fSJonas Devlieghere
211d5b44036SJonas Devlieghere return m_opaque_up->SetAutoApplyFixIts(b);
212a1e541bfSJim Ingham }
213a1e541bfSJim Ingham
GetRetriesWithFixIts()214203a8adbSRaphael Isemann uint64_t SBExpressionOptions::GetRetriesWithFixIts() {
215*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
216203a8adbSRaphael Isemann
217203a8adbSRaphael Isemann return m_opaque_up->GetRetriesWithFixIts();
218203a8adbSRaphael Isemann }
219203a8adbSRaphael Isemann
SetRetriesWithFixIts(uint64_t retries)220203a8adbSRaphael Isemann void SBExpressionOptions::SetRetriesWithFixIts(uint64_t retries) {
221*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, retries);
222203a8adbSRaphael Isemann
223203a8adbSRaphael Isemann return m_opaque_up->SetRetriesWithFixIts(retries);
224203a8adbSRaphael Isemann }
225203a8adbSRaphael Isemann
GetTopLevel()226b9c1b51eSKate Stone bool SBExpressionOptions::GetTopLevel() {
227*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
228baf5664fSJonas Devlieghere
229d5b44036SJonas Devlieghere return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
230863fab69SSean Callanan }
231863fab69SSean Callanan
SetTopLevel(bool b)232b9c1b51eSKate Stone void SBExpressionOptions::SetTopLevel(bool b) {
233*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, b);
234baf5664fSJonas Devlieghere
235d5b44036SJonas Devlieghere m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
236d5b44036SJonas Devlieghere : m_opaque_up->default_execution_policy);
237863fab69SSean Callanan }
238863fab69SSean Callanan
GetAllowJIT()239ab639986SJim Ingham bool SBExpressionOptions::GetAllowJIT() {
240*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
241baf5664fSJonas Devlieghere
242d5b44036SJonas Devlieghere return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
243ab639986SJim Ingham }
244ab639986SJim Ingham
SetAllowJIT(bool allow)245ab639986SJim Ingham void SBExpressionOptions::SetAllowJIT(bool allow) {
246*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, allow);
247baf5664fSJonas Devlieghere
248d5b44036SJonas Devlieghere m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
249ab639986SJim Ingham : eExecutionPolicyNever);
250ab639986SJim Ingham }
251ab639986SJim Ingham
get() const252b9c1b51eSKate Stone EvaluateExpressionOptions *SBExpressionOptions::get() const {
253d5b44036SJonas Devlieghere return m_opaque_up.get();
25435e1bda6SJim Ingham }
25535e1bda6SJim Ingham
ref() const256b9c1b51eSKate Stone EvaluateExpressionOptions &SBExpressionOptions::ref() const {
257d5b44036SJonas Devlieghere return *(m_opaque_up.get());
25835e1bda6SJim Ingham }
259