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" 11*bd4bf82aSJonas Devlieghere #include "Utils.h" 1235e1bda6SJim Ingham #include "lldb/API/SBStream.h" 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() 19d5b44036SJonas Devlieghere : m_opaque_up(new EvaluateExpressionOptions()) {} 2035e1bda6SJim Ingham 21*bd4bf82aSJonas Devlieghere SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) 22*bd4bf82aSJonas Devlieghere : m_opaque_up() { 23*bd4bf82aSJonas Devlieghere m_opaque_up = clone(rhs.m_opaque_up); 2435e1bda6SJim Ingham } 2535e1bda6SJim Ingham 26b9c1b51eSKate Stone const SBExpressionOptions &SBExpressionOptions:: 27b9c1b51eSKate Stone operator=(const SBExpressionOptions &rhs) { 28*bd4bf82aSJonas Devlieghere if (this != &rhs) 29*bd4bf82aSJonas Devlieghere m_opaque_up = clone(rhs.m_opaque_up); 3035e1bda6SJim Ingham return *this; 3135e1bda6SJim Ingham } 3235e1bda6SJim Ingham 33b9c1b51eSKate Stone SBExpressionOptions::~SBExpressionOptions() {} 3435e1bda6SJim Ingham 35b9c1b51eSKate Stone bool SBExpressionOptions::GetCoerceResultToId() const { 36d5b44036SJonas Devlieghere return m_opaque_up->DoesCoerceToId(); 3735e1bda6SJim Ingham } 3835e1bda6SJim Ingham 39b9c1b51eSKate Stone void SBExpressionOptions::SetCoerceResultToId(bool coerce) { 40d5b44036SJonas Devlieghere m_opaque_up->SetCoerceToId(coerce); 4135e1bda6SJim Ingham } 4235e1bda6SJim Ingham 43b9c1b51eSKate Stone bool SBExpressionOptions::GetUnwindOnError() const { 44d5b44036SJonas Devlieghere return m_opaque_up->DoesUnwindOnError(); 4535e1bda6SJim Ingham } 4635e1bda6SJim Ingham 47b9c1b51eSKate Stone void SBExpressionOptions::SetUnwindOnError(bool unwind) { 48d5b44036SJonas Devlieghere m_opaque_up->SetUnwindOnError(unwind); 4935e1bda6SJim Ingham } 5035e1bda6SJim Ingham 51b9c1b51eSKate Stone bool SBExpressionOptions::GetIgnoreBreakpoints() const { 52d5b44036SJonas Devlieghere return m_opaque_up->DoesIgnoreBreakpoints(); 53184e9811SJim Ingham } 54184e9811SJim Ingham 55b9c1b51eSKate Stone void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) { 56d5b44036SJonas Devlieghere m_opaque_up->SetIgnoreBreakpoints(ignore); 57184e9811SJim Ingham } 58184e9811SJim Ingham 59b9c1b51eSKate Stone lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const { 60d5b44036SJonas Devlieghere return m_opaque_up->GetUseDynamic(); 6135e1bda6SJim Ingham } 6235e1bda6SJim Ingham 63b9c1b51eSKate Stone void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) { 64d5b44036SJonas Devlieghere m_opaque_up->SetUseDynamic(dynamic); 6535e1bda6SJim Ingham } 6635e1bda6SJim Ingham 67b9c1b51eSKate Stone uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const { 68d5b44036SJonas Devlieghere return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0; 6935e1bda6SJim Ingham } 7035e1bda6SJim Ingham 71b9c1b51eSKate Stone void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) { 72d5b44036SJonas Devlieghere m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) 7343d35418SPavel Labath : std::chrono::microseconds(timeout)); 7435e1bda6SJim Ingham } 7535e1bda6SJim Ingham 76b9c1b51eSKate Stone uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const { 77d5b44036SJonas Devlieghere return m_opaque_up->GetOneThreadTimeout() 78d5b44036SJonas Devlieghere ? m_opaque_up->GetOneThreadTimeout()->count() 79d5b44036SJonas Devlieghere : 0; 80914f4e70SJim Ingham } 81914f4e70SJim Ingham 82b9c1b51eSKate Stone void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { 83d5b44036SJonas Devlieghere m_opaque_up->SetOneThreadTimeout(timeout == 0 8443d35418SPavel Labath ? Timeout<std::micro>(llvm::None) 8543d35418SPavel Labath : std::chrono::microseconds(timeout)); 86914f4e70SJim Ingham } 87914f4e70SJim Ingham 88b9c1b51eSKate Stone bool SBExpressionOptions::GetTryAllThreads() const { 89d5b44036SJonas Devlieghere return m_opaque_up->GetTryAllThreads(); 9035e1bda6SJim Ingham } 9135e1bda6SJim Ingham 92b9c1b51eSKate Stone void SBExpressionOptions::SetTryAllThreads(bool run_others) { 93d5b44036SJonas Devlieghere m_opaque_up->SetTryAllThreads(run_others); 946fbc48bcSJim Ingham } 956fbc48bcSJim Ingham 96b9c1b51eSKate Stone bool SBExpressionOptions::GetStopOthers() const { 97d5b44036SJonas Devlieghere return m_opaque_up->GetStopOthers(); 98286fb1efSJim Ingham } 99286fb1efSJim Ingham 100b9c1b51eSKate Stone void SBExpressionOptions::SetStopOthers(bool run_others) { 101d5b44036SJonas Devlieghere m_opaque_up->SetStopOthers(run_others); 102286fb1efSJim Ingham } 103286fb1efSJim Ingham 104b9c1b51eSKate Stone bool SBExpressionOptions::GetTrapExceptions() const { 105d5b44036SJonas Devlieghere return m_opaque_up->GetTrapExceptions(); 1066fbc48bcSJim Ingham } 1076fbc48bcSJim Ingham 108b9c1b51eSKate Stone void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) { 109d5b44036SJonas Devlieghere m_opaque_up->SetTrapExceptions(trap_exceptions); 11035e1bda6SJim Ingham } 11135e1bda6SJim Ingham 112b9c1b51eSKate Stone void SBExpressionOptions::SetLanguage(lldb::LanguageType language) { 113d5b44036SJonas Devlieghere m_opaque_up->SetLanguage(language); 114705b1809SJason Molenda } 115705b1809SJason Molenda 116b9c1b51eSKate Stone void SBExpressionOptions::SetCancelCallback( 117b9c1b51eSKate Stone lldb::ExpressionCancelCallback callback, void *baton) { 118d5b44036SJonas Devlieghere m_opaque_up->SetCancelCallback(callback, baton); 1191624a2d3SJim Ingham } 1201624a2d3SJim Ingham 121b9c1b51eSKate Stone bool SBExpressionOptions::GetGenerateDebugInfo() { 122d5b44036SJonas Devlieghere return m_opaque_up->GetGenerateDebugInfo(); 123205ca1e8SGreg Clayton } 124205ca1e8SGreg Clayton 125b9c1b51eSKate Stone void SBExpressionOptions::SetGenerateDebugInfo(bool b) { 126d5b44036SJonas Devlieghere return m_opaque_up->SetGenerateDebugInfo(b); 127205ca1e8SGreg Clayton } 128205ca1e8SGreg Clayton 129b9c1b51eSKate Stone bool SBExpressionOptions::GetSuppressPersistentResult() { 130d5b44036SJonas Devlieghere return m_opaque_up->GetResultIsInternal(); 1317ab079b6SJim Ingham } 1327ab079b6SJim Ingham 133b9c1b51eSKate Stone void SBExpressionOptions::SetSuppressPersistentResult(bool b) { 134d5b44036SJonas Devlieghere return m_opaque_up->SetResultIsInternal(b); 1357ab079b6SJim Ingham } 1367ab079b6SJim Ingham 137b9c1b51eSKate Stone const char *SBExpressionOptions::GetPrefix() const { 138d5b44036SJonas Devlieghere return m_opaque_up->GetPrefix(); 1394e1042e1SGreg Clayton } 1404e1042e1SGreg Clayton 141b9c1b51eSKate Stone void SBExpressionOptions::SetPrefix(const char *prefix) { 142d5b44036SJonas Devlieghere return m_opaque_up->SetPrefix(prefix); 1434e1042e1SGreg Clayton } 1447ab079b6SJim Ingham 145b9c1b51eSKate Stone bool SBExpressionOptions::GetAutoApplyFixIts() { 146d5b44036SJonas Devlieghere return m_opaque_up->GetAutoApplyFixIts(); 147a1e541bfSJim Ingham } 148a1e541bfSJim Ingham 149b9c1b51eSKate Stone void SBExpressionOptions::SetAutoApplyFixIts(bool b) { 150d5b44036SJonas Devlieghere return m_opaque_up->SetAutoApplyFixIts(b); 151a1e541bfSJim Ingham } 152a1e541bfSJim Ingham 153b9c1b51eSKate Stone bool SBExpressionOptions::GetTopLevel() { 154d5b44036SJonas Devlieghere return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel; 155863fab69SSean Callanan } 156863fab69SSean Callanan 157b9c1b51eSKate Stone void SBExpressionOptions::SetTopLevel(bool b) { 158d5b44036SJonas Devlieghere m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel 159d5b44036SJonas Devlieghere : m_opaque_up->default_execution_policy); 160863fab69SSean Callanan } 161863fab69SSean Callanan 162ab639986SJim Ingham bool SBExpressionOptions::GetAllowJIT() { 163d5b44036SJonas Devlieghere return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever; 164ab639986SJim Ingham } 165ab639986SJim Ingham 166ab639986SJim Ingham void SBExpressionOptions::SetAllowJIT(bool allow) { 167d5b44036SJonas Devlieghere m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy 168ab639986SJim Ingham : eExecutionPolicyNever); 169ab639986SJim Ingham } 170ab639986SJim Ingham 171b9c1b51eSKate Stone EvaluateExpressionOptions *SBExpressionOptions::get() const { 172d5b44036SJonas Devlieghere return m_opaque_up.get(); 17335e1bda6SJim Ingham } 17435e1bda6SJim Ingham 175b9c1b51eSKate Stone EvaluateExpressionOptions &SBExpressionOptions::ref() const { 176d5b44036SJonas Devlieghere return *(m_opaque_up.get()); 17735e1bda6SJim Ingham } 178