15ffd83dbSDimitry Andric //===-- SBExpressionOptions.cpp -------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include "lldb/API/SBExpressionOptions.h"
100b57cec5SDimitry Andric #include "Utils.h"
110b57cec5SDimitry Andric #include "lldb/API/SBStream.h"
120b57cec5SDimitry Andric #include "lldb/Target/Target.h"
1304eeddc0SDimitry Andric #include "lldb/Utility/Instrumentation.h"
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric using namespace lldb;
160b57cec5SDimitry Andric using namespace lldb_private;
170b57cec5SDimitry Andric 
SBExpressionOptions()180b57cec5SDimitry Andric SBExpressionOptions::SBExpressionOptions()
190b57cec5SDimitry Andric     : m_opaque_up(new EvaluateExpressionOptions()) {
2004eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
210b57cec5SDimitry Andric }
220b57cec5SDimitry Andric 
SBExpressionOptions(const SBExpressionOptions & rhs)2304eeddc0SDimitry Andric SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) {
2404eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric   m_opaque_up = clone(rhs.m_opaque_up);
270b57cec5SDimitry Andric }
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric const SBExpressionOptions &SBExpressionOptions::
operator =(const SBExpressionOptions & rhs)300b57cec5SDimitry Andric operator=(const SBExpressionOptions &rhs) {
3104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
320b57cec5SDimitry Andric 
330b57cec5SDimitry Andric   if (this != &rhs)
340b57cec5SDimitry Andric     m_opaque_up = clone(rhs.m_opaque_up);
3504eeddc0SDimitry Andric   return *this;
360b57cec5SDimitry Andric }
370b57cec5SDimitry Andric 
385ffd83dbSDimitry Andric SBExpressionOptions::~SBExpressionOptions() = default;
390b57cec5SDimitry Andric 
GetCoerceResultToId() const400b57cec5SDimitry Andric bool SBExpressionOptions::GetCoerceResultToId() const {
4104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
420b57cec5SDimitry Andric 
430b57cec5SDimitry Andric   return m_opaque_up->DoesCoerceToId();
440b57cec5SDimitry Andric }
450b57cec5SDimitry Andric 
SetCoerceResultToId(bool coerce)460b57cec5SDimitry Andric void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
4704eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, coerce);
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric   m_opaque_up->SetCoerceToId(coerce);
500b57cec5SDimitry Andric }
510b57cec5SDimitry Andric 
GetUnwindOnError() const520b57cec5SDimitry Andric bool SBExpressionOptions::GetUnwindOnError() const {
5304eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric   return m_opaque_up->DoesUnwindOnError();
560b57cec5SDimitry Andric }
570b57cec5SDimitry Andric 
SetUnwindOnError(bool unwind)580b57cec5SDimitry Andric void SBExpressionOptions::SetUnwindOnError(bool unwind) {
5904eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, unwind);
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric   m_opaque_up->SetUnwindOnError(unwind);
620b57cec5SDimitry Andric }
630b57cec5SDimitry Andric 
GetIgnoreBreakpoints() const640b57cec5SDimitry Andric bool SBExpressionOptions::GetIgnoreBreakpoints() const {
6504eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
660b57cec5SDimitry Andric 
670b57cec5SDimitry Andric   return m_opaque_up->DoesIgnoreBreakpoints();
680b57cec5SDimitry Andric }
690b57cec5SDimitry Andric 
SetIgnoreBreakpoints(bool ignore)700b57cec5SDimitry Andric void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
7104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, ignore);
720b57cec5SDimitry Andric 
730b57cec5SDimitry Andric   m_opaque_up->SetIgnoreBreakpoints(ignore);
740b57cec5SDimitry Andric }
750b57cec5SDimitry Andric 
GetFetchDynamicValue() const760b57cec5SDimitry Andric lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
7704eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
780b57cec5SDimitry Andric 
790b57cec5SDimitry Andric   return m_opaque_up->GetUseDynamic();
800b57cec5SDimitry Andric }
810b57cec5SDimitry Andric 
SetFetchDynamicValue(lldb::DynamicValueType dynamic)820b57cec5SDimitry Andric void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
8304eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, dynamic);
840b57cec5SDimitry Andric 
850b57cec5SDimitry Andric   m_opaque_up->SetUseDynamic(dynamic);
860b57cec5SDimitry Andric }
870b57cec5SDimitry Andric 
GetTimeoutInMicroSeconds() const880b57cec5SDimitry Andric uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
8904eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
900b57cec5SDimitry Andric 
910b57cec5SDimitry Andric   return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
920b57cec5SDimitry Andric }
930b57cec5SDimitry Andric 
SetTimeoutInMicroSeconds(uint32_t timeout)940b57cec5SDimitry Andric void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
9504eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, timeout);
960b57cec5SDimitry Andric 
97bdd1243dSDimitry Andric   m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(std::nullopt)
980b57cec5SDimitry Andric                                        : std::chrono::microseconds(timeout));
990b57cec5SDimitry Andric }
1000b57cec5SDimitry Andric 
GetOneThreadTimeoutInMicroSeconds() const1010b57cec5SDimitry Andric uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
10204eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1030b57cec5SDimitry Andric 
1040b57cec5SDimitry Andric   return m_opaque_up->GetOneThreadTimeout()
1050b57cec5SDimitry Andric              ? m_opaque_up->GetOneThreadTimeout()->count()
1060b57cec5SDimitry Andric              : 0;
1070b57cec5SDimitry Andric }
1080b57cec5SDimitry Andric 
SetOneThreadTimeoutInMicroSeconds(uint32_t timeout)1090b57cec5SDimitry Andric void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
11004eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, timeout);
1110b57cec5SDimitry Andric 
1120b57cec5SDimitry Andric   m_opaque_up->SetOneThreadTimeout(timeout == 0
113bdd1243dSDimitry Andric                                        ? Timeout<std::micro>(std::nullopt)
1140b57cec5SDimitry Andric                                        : std::chrono::microseconds(timeout));
1150b57cec5SDimitry Andric }
1160b57cec5SDimitry Andric 
GetTryAllThreads() const1170b57cec5SDimitry Andric bool SBExpressionOptions::GetTryAllThreads() const {
11804eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1190b57cec5SDimitry Andric 
1200b57cec5SDimitry Andric   return m_opaque_up->GetTryAllThreads();
1210b57cec5SDimitry Andric }
1220b57cec5SDimitry Andric 
SetTryAllThreads(bool run_others)1230b57cec5SDimitry Andric void SBExpressionOptions::SetTryAllThreads(bool run_others) {
12404eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, run_others);
1250b57cec5SDimitry Andric 
1260b57cec5SDimitry Andric   m_opaque_up->SetTryAllThreads(run_others);
1270b57cec5SDimitry Andric }
1280b57cec5SDimitry Andric 
GetStopOthers() const1290b57cec5SDimitry Andric bool SBExpressionOptions::GetStopOthers() const {
13004eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1310b57cec5SDimitry Andric 
1320b57cec5SDimitry Andric   return m_opaque_up->GetStopOthers();
1330b57cec5SDimitry Andric }
1340b57cec5SDimitry Andric 
SetStopOthers(bool run_others)1350b57cec5SDimitry Andric void SBExpressionOptions::SetStopOthers(bool run_others) {
13604eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, run_others);
1370b57cec5SDimitry Andric 
1380b57cec5SDimitry Andric   m_opaque_up->SetStopOthers(run_others);
1390b57cec5SDimitry Andric }
1400b57cec5SDimitry Andric 
GetTrapExceptions() const1410b57cec5SDimitry Andric bool SBExpressionOptions::GetTrapExceptions() const {
14204eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1430b57cec5SDimitry Andric 
1440b57cec5SDimitry Andric   return m_opaque_up->GetTrapExceptions();
1450b57cec5SDimitry Andric }
1460b57cec5SDimitry Andric 
SetTrapExceptions(bool trap_exceptions)1470b57cec5SDimitry Andric void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
14804eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, trap_exceptions);
1490b57cec5SDimitry Andric 
1500b57cec5SDimitry Andric   m_opaque_up->SetTrapExceptions(trap_exceptions);
1510b57cec5SDimitry Andric }
1520b57cec5SDimitry Andric 
SetLanguage(lldb::LanguageType language)1530b57cec5SDimitry Andric void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
15404eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, language);
1550b57cec5SDimitry Andric 
1560b57cec5SDimitry Andric   m_opaque_up->SetLanguage(language);
1570b57cec5SDimitry Andric }
1580b57cec5SDimitry Andric 
SetCancelCallback(lldb::ExpressionCancelCallback callback,void * baton)1590b57cec5SDimitry Andric void SBExpressionOptions::SetCancelCallback(
1600b57cec5SDimitry Andric     lldb::ExpressionCancelCallback callback, void *baton) {
16104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, callback, baton);
1620b57cec5SDimitry Andric 
1630b57cec5SDimitry Andric   m_opaque_up->SetCancelCallback(callback, baton);
1640b57cec5SDimitry Andric }
1650b57cec5SDimitry Andric 
GetGenerateDebugInfo()1660b57cec5SDimitry Andric bool SBExpressionOptions::GetGenerateDebugInfo() {
16704eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1680b57cec5SDimitry Andric 
1690b57cec5SDimitry Andric   return m_opaque_up->GetGenerateDebugInfo();
1700b57cec5SDimitry Andric }
1710b57cec5SDimitry Andric 
SetGenerateDebugInfo(bool b)1720b57cec5SDimitry Andric void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
17304eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, b);
1740b57cec5SDimitry Andric 
1750b57cec5SDimitry Andric   return m_opaque_up->SetGenerateDebugInfo(b);
1760b57cec5SDimitry Andric }
1770b57cec5SDimitry Andric 
GetSuppressPersistentResult()1780b57cec5SDimitry Andric bool SBExpressionOptions::GetSuppressPersistentResult() {
17904eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1800b57cec5SDimitry Andric 
181*fe013be4SDimitry Andric   return m_opaque_up->GetSuppressPersistentResult();
1820b57cec5SDimitry Andric }
1830b57cec5SDimitry Andric 
SetSuppressPersistentResult(bool b)1840b57cec5SDimitry Andric void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
18504eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, b);
1860b57cec5SDimitry Andric 
187*fe013be4SDimitry Andric   return m_opaque_up->SetSuppressPersistentResult(b);
1880b57cec5SDimitry Andric }
1890b57cec5SDimitry Andric 
GetPrefix() const1900b57cec5SDimitry Andric const char *SBExpressionOptions::GetPrefix() const {
19104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1920b57cec5SDimitry Andric 
193*fe013be4SDimitry Andric   return ConstString(m_opaque_up->GetPrefix()).GetCString();
1940b57cec5SDimitry Andric }
1950b57cec5SDimitry Andric 
SetPrefix(const char * prefix)1960b57cec5SDimitry Andric void SBExpressionOptions::SetPrefix(const char *prefix) {
19704eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, prefix);
1980b57cec5SDimitry Andric 
1990b57cec5SDimitry Andric   return m_opaque_up->SetPrefix(prefix);
2000b57cec5SDimitry Andric }
2010b57cec5SDimitry Andric 
GetAutoApplyFixIts()2020b57cec5SDimitry Andric bool SBExpressionOptions::GetAutoApplyFixIts() {
20304eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2040b57cec5SDimitry Andric 
2050b57cec5SDimitry Andric   return m_opaque_up->GetAutoApplyFixIts();
2060b57cec5SDimitry Andric }
2070b57cec5SDimitry Andric 
SetAutoApplyFixIts(bool b)2080b57cec5SDimitry Andric void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
20904eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, b);
2100b57cec5SDimitry Andric 
2110b57cec5SDimitry Andric   return m_opaque_up->SetAutoApplyFixIts(b);
2120b57cec5SDimitry Andric }
2130b57cec5SDimitry Andric 
GetRetriesWithFixIts()2145ffd83dbSDimitry Andric uint64_t SBExpressionOptions::GetRetriesWithFixIts() {
21504eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2165ffd83dbSDimitry Andric 
2175ffd83dbSDimitry Andric   return m_opaque_up->GetRetriesWithFixIts();
2185ffd83dbSDimitry Andric }
2195ffd83dbSDimitry Andric 
SetRetriesWithFixIts(uint64_t retries)2205ffd83dbSDimitry Andric void SBExpressionOptions::SetRetriesWithFixIts(uint64_t retries) {
22104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, retries);
2225ffd83dbSDimitry Andric 
2235ffd83dbSDimitry Andric   return m_opaque_up->SetRetriesWithFixIts(retries);
2245ffd83dbSDimitry Andric }
2255ffd83dbSDimitry Andric 
GetTopLevel()2260b57cec5SDimitry Andric bool SBExpressionOptions::GetTopLevel() {
22704eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2280b57cec5SDimitry Andric 
2290b57cec5SDimitry Andric   return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
2300b57cec5SDimitry Andric }
2310b57cec5SDimitry Andric 
SetTopLevel(bool b)2320b57cec5SDimitry Andric void SBExpressionOptions::SetTopLevel(bool b) {
23304eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, b);
2340b57cec5SDimitry Andric 
2350b57cec5SDimitry Andric   m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
2360b57cec5SDimitry Andric                                     : m_opaque_up->default_execution_policy);
2370b57cec5SDimitry Andric }
2380b57cec5SDimitry Andric 
GetAllowJIT()2390b57cec5SDimitry Andric bool SBExpressionOptions::GetAllowJIT() {
24004eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2410b57cec5SDimitry Andric 
2420b57cec5SDimitry Andric   return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
2430b57cec5SDimitry Andric }
2440b57cec5SDimitry Andric 
SetAllowJIT(bool allow)2450b57cec5SDimitry Andric void SBExpressionOptions::SetAllowJIT(bool allow) {
24604eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, allow);
2470b57cec5SDimitry Andric 
2480b57cec5SDimitry Andric   m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
2490b57cec5SDimitry Andric                                         : eExecutionPolicyNever);
2500b57cec5SDimitry Andric }
2510b57cec5SDimitry Andric 
get() const2520b57cec5SDimitry Andric EvaluateExpressionOptions *SBExpressionOptions::get() const {
2530b57cec5SDimitry Andric   return m_opaque_up.get();
2540b57cec5SDimitry Andric }
2550b57cec5SDimitry Andric 
ref() const2560b57cec5SDimitry Andric EvaluateExpressionOptions &SBExpressionOptions::ref() const {
257bdd1243dSDimitry Andric   return *m_opaque_up;
2580b57cec5SDimitry Andric }
259