1b9c1b51eSKate Stone //===-- SBExpressionOptions.cpp ---------------------------------------------*-
2b9c1b51eSKate Stone //C++ -*-===//
335e1bda6SJim Ingham //
42946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
52946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
62946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
735e1bda6SJim Ingham //
835e1bda6SJim Ingham //===----------------------------------------------------------------------===//
935e1bda6SJim Ingham 
1035e1bda6SJim Ingham #include "lldb/API/SBExpressionOptions.h"
1135e1bda6SJim Ingham #include "lldb/API/SBStream.h"
1235e1bda6SJim Ingham 
1335e1bda6SJim Ingham #include "lldb/Target/Target.h"
1435e1bda6SJim Ingham 
1535e1bda6SJim Ingham using namespace lldb;
1635e1bda6SJim Ingham using namespace lldb_private;
1735e1bda6SJim Ingham 
18b9c1b51eSKate Stone SBExpressionOptions::SBExpressionOptions()
19*d5b44036SJonas Devlieghere     : m_opaque_up(new EvaluateExpressionOptions()) {}
2035e1bda6SJim Ingham 
21b9c1b51eSKate Stone SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) {
22*d5b44036SJonas Devlieghere   m_opaque_up.reset(new EvaluateExpressionOptions());
23*d5b44036SJonas Devlieghere   *(m_opaque_up.get()) = rhs.ref();
2435e1bda6SJim Ingham }
2535e1bda6SJim Ingham 
26b9c1b51eSKate Stone const SBExpressionOptions &SBExpressionOptions::
27b9c1b51eSKate Stone operator=(const SBExpressionOptions &rhs) {
28b9c1b51eSKate Stone   if (this != &rhs) {
2935e1bda6SJim Ingham     this->ref() = rhs.ref();
3035e1bda6SJim Ingham   }
3135e1bda6SJim Ingham   return *this;
3235e1bda6SJim Ingham }
3335e1bda6SJim Ingham 
34b9c1b51eSKate Stone SBExpressionOptions::~SBExpressionOptions() {}
3535e1bda6SJim Ingham 
36b9c1b51eSKate Stone bool SBExpressionOptions::GetCoerceResultToId() const {
37*d5b44036SJonas Devlieghere   return m_opaque_up->DoesCoerceToId();
3835e1bda6SJim Ingham }
3935e1bda6SJim Ingham 
40b9c1b51eSKate Stone void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
41*d5b44036SJonas Devlieghere   m_opaque_up->SetCoerceToId(coerce);
4235e1bda6SJim Ingham }
4335e1bda6SJim Ingham 
44b9c1b51eSKate Stone bool SBExpressionOptions::GetUnwindOnError() const {
45*d5b44036SJonas Devlieghere   return m_opaque_up->DoesUnwindOnError();
4635e1bda6SJim Ingham }
4735e1bda6SJim Ingham 
48b9c1b51eSKate Stone void SBExpressionOptions::SetUnwindOnError(bool unwind) {
49*d5b44036SJonas Devlieghere   m_opaque_up->SetUnwindOnError(unwind);
5035e1bda6SJim Ingham }
5135e1bda6SJim Ingham 
52b9c1b51eSKate Stone bool SBExpressionOptions::GetIgnoreBreakpoints() const {
53*d5b44036SJonas Devlieghere   return m_opaque_up->DoesIgnoreBreakpoints();
54184e9811SJim Ingham }
55184e9811SJim Ingham 
56b9c1b51eSKate Stone void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
57*d5b44036SJonas Devlieghere   m_opaque_up->SetIgnoreBreakpoints(ignore);
58184e9811SJim Ingham }
59184e9811SJim Ingham 
60b9c1b51eSKate Stone lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
61*d5b44036SJonas Devlieghere   return m_opaque_up->GetUseDynamic();
6235e1bda6SJim Ingham }
6335e1bda6SJim Ingham 
64b9c1b51eSKate Stone void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
65*d5b44036SJonas Devlieghere   m_opaque_up->SetUseDynamic(dynamic);
6635e1bda6SJim Ingham }
6735e1bda6SJim Ingham 
68b9c1b51eSKate Stone uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
69*d5b44036SJonas Devlieghere   return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
7035e1bda6SJim Ingham }
7135e1bda6SJim Ingham 
72b9c1b51eSKate Stone void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
73*d5b44036SJonas Devlieghere   m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
7443d35418SPavel Labath                                        : std::chrono::microseconds(timeout));
7535e1bda6SJim Ingham }
7635e1bda6SJim Ingham 
77b9c1b51eSKate Stone uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
78*d5b44036SJonas Devlieghere   return m_opaque_up->GetOneThreadTimeout()
79*d5b44036SJonas Devlieghere              ? m_opaque_up->GetOneThreadTimeout()->count()
80*d5b44036SJonas Devlieghere              : 0;
81914f4e70SJim Ingham }
82914f4e70SJim Ingham 
83b9c1b51eSKate Stone void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
84*d5b44036SJonas Devlieghere   m_opaque_up->SetOneThreadTimeout(timeout == 0
8543d35418SPavel Labath                                        ? Timeout<std::micro>(llvm::None)
8643d35418SPavel Labath                                        : std::chrono::microseconds(timeout));
87914f4e70SJim Ingham }
88914f4e70SJim Ingham 
89b9c1b51eSKate Stone bool SBExpressionOptions::GetTryAllThreads() const {
90*d5b44036SJonas Devlieghere   return m_opaque_up->GetTryAllThreads();
9135e1bda6SJim Ingham }
9235e1bda6SJim Ingham 
93b9c1b51eSKate Stone void SBExpressionOptions::SetTryAllThreads(bool run_others) {
94*d5b44036SJonas Devlieghere   m_opaque_up->SetTryAllThreads(run_others);
956fbc48bcSJim Ingham }
966fbc48bcSJim Ingham 
97b9c1b51eSKate Stone bool SBExpressionOptions::GetStopOthers() const {
98*d5b44036SJonas Devlieghere   return m_opaque_up->GetStopOthers();
99286fb1efSJim Ingham }
100286fb1efSJim Ingham 
101b9c1b51eSKate Stone void SBExpressionOptions::SetStopOthers(bool run_others) {
102*d5b44036SJonas Devlieghere   m_opaque_up->SetStopOthers(run_others);
103286fb1efSJim Ingham }
104286fb1efSJim Ingham 
105b9c1b51eSKate Stone bool SBExpressionOptions::GetTrapExceptions() const {
106*d5b44036SJonas Devlieghere   return m_opaque_up->GetTrapExceptions();
1076fbc48bcSJim Ingham }
1086fbc48bcSJim Ingham 
109b9c1b51eSKate Stone void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
110*d5b44036SJonas Devlieghere   m_opaque_up->SetTrapExceptions(trap_exceptions);
11135e1bda6SJim Ingham }
11235e1bda6SJim Ingham 
113b9c1b51eSKate Stone void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
114*d5b44036SJonas Devlieghere   m_opaque_up->SetLanguage(language);
115705b1809SJason Molenda }
116705b1809SJason Molenda 
117b9c1b51eSKate Stone void SBExpressionOptions::SetCancelCallback(
118b9c1b51eSKate Stone     lldb::ExpressionCancelCallback callback, void *baton) {
119*d5b44036SJonas Devlieghere   m_opaque_up->SetCancelCallback(callback, baton);
1201624a2d3SJim Ingham }
1211624a2d3SJim Ingham 
122b9c1b51eSKate Stone bool SBExpressionOptions::GetGenerateDebugInfo() {
123*d5b44036SJonas Devlieghere   return m_opaque_up->GetGenerateDebugInfo();
124205ca1e8SGreg Clayton }
125205ca1e8SGreg Clayton 
126b9c1b51eSKate Stone void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
127*d5b44036SJonas Devlieghere   return m_opaque_up->SetGenerateDebugInfo(b);
128205ca1e8SGreg Clayton }
129205ca1e8SGreg Clayton 
130b9c1b51eSKate Stone bool SBExpressionOptions::GetSuppressPersistentResult() {
131*d5b44036SJonas Devlieghere   return m_opaque_up->GetResultIsInternal();
1327ab079b6SJim Ingham }
1337ab079b6SJim Ingham 
134b9c1b51eSKate Stone void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
135*d5b44036SJonas Devlieghere   return m_opaque_up->SetResultIsInternal(b);
1367ab079b6SJim Ingham }
1377ab079b6SJim Ingham 
138b9c1b51eSKate Stone const char *SBExpressionOptions::GetPrefix() const {
139*d5b44036SJonas Devlieghere   return m_opaque_up->GetPrefix();
1404e1042e1SGreg Clayton }
1414e1042e1SGreg Clayton 
142b9c1b51eSKate Stone void SBExpressionOptions::SetPrefix(const char *prefix) {
143*d5b44036SJonas Devlieghere   return m_opaque_up->SetPrefix(prefix);
1444e1042e1SGreg Clayton }
1457ab079b6SJim Ingham 
146b9c1b51eSKate Stone bool SBExpressionOptions::GetAutoApplyFixIts() {
147*d5b44036SJonas Devlieghere   return m_opaque_up->GetAutoApplyFixIts();
148a1e541bfSJim Ingham }
149a1e541bfSJim Ingham 
150b9c1b51eSKate Stone void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
151*d5b44036SJonas Devlieghere   return m_opaque_up->SetAutoApplyFixIts(b);
152a1e541bfSJim Ingham }
153a1e541bfSJim Ingham 
154b9c1b51eSKate Stone bool SBExpressionOptions::GetTopLevel() {
155*d5b44036SJonas Devlieghere   return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
156863fab69SSean Callanan }
157863fab69SSean Callanan 
158b9c1b51eSKate Stone void SBExpressionOptions::SetTopLevel(bool b) {
159*d5b44036SJonas Devlieghere   m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
160*d5b44036SJonas Devlieghere                                     : m_opaque_up->default_execution_policy);
161863fab69SSean Callanan }
162863fab69SSean Callanan 
163ab639986SJim Ingham bool SBExpressionOptions::GetAllowJIT() {
164*d5b44036SJonas Devlieghere   return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
165ab639986SJim Ingham }
166ab639986SJim Ingham 
167ab639986SJim Ingham void SBExpressionOptions::SetAllowJIT(bool allow) {
168*d5b44036SJonas Devlieghere   m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
169ab639986SJim Ingham                                         : eExecutionPolicyNever);
170ab639986SJim Ingham }
171ab639986SJim Ingham 
172b9c1b51eSKate Stone EvaluateExpressionOptions *SBExpressionOptions::get() const {
173*d5b44036SJonas Devlieghere   return m_opaque_up.get();
17435e1bda6SJim Ingham }
17535e1bda6SJim Ingham 
176b9c1b51eSKate Stone EvaluateExpressionOptions &SBExpressionOptions::ref() const {
177*d5b44036SJonas Devlieghere   return *(m_opaque_up.get());
17835e1bda6SJim Ingham }
179