1 //===-- SBExpressionOptions.cpp ---------------------------------------------*- 2 //C++ -*-===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/API/SBExpressionOptions.h" 11 #include "lldb/API/SBStream.h" 12 13 #include "lldb/Target/Target.h" 14 15 using namespace lldb; 16 using namespace lldb_private; 17 18 SBExpressionOptions::SBExpressionOptions() 19 : m_opaque_ap(new EvaluateExpressionOptions()) {} 20 21 SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) { 22 m_opaque_ap.reset(new EvaluateExpressionOptions()); 23 *(m_opaque_ap.get()) = rhs.ref(); 24 } 25 26 const SBExpressionOptions &SBExpressionOptions:: 27 operator=(const SBExpressionOptions &rhs) { 28 if (this != &rhs) { 29 this->ref() = rhs.ref(); 30 } 31 return *this; 32 } 33 34 SBExpressionOptions::~SBExpressionOptions() {} 35 36 bool SBExpressionOptions::GetCoerceResultToId() const { 37 return m_opaque_ap->DoesCoerceToId(); 38 } 39 40 void SBExpressionOptions::SetCoerceResultToId(bool coerce) { 41 m_opaque_ap->SetCoerceToId(coerce); 42 } 43 44 bool SBExpressionOptions::GetUnwindOnError() const { 45 return m_opaque_ap->DoesUnwindOnError(); 46 } 47 48 void SBExpressionOptions::SetUnwindOnError(bool unwind) { 49 m_opaque_ap->SetUnwindOnError(unwind); 50 } 51 52 bool SBExpressionOptions::GetIgnoreBreakpoints() const { 53 return m_opaque_ap->DoesIgnoreBreakpoints(); 54 } 55 56 void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) { 57 m_opaque_ap->SetIgnoreBreakpoints(ignore); 58 } 59 60 lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const { 61 return m_opaque_ap->GetUseDynamic(); 62 } 63 64 void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) { 65 m_opaque_ap->SetUseDynamic(dynamic); 66 } 67 68 uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const { 69 return m_opaque_ap->GetTimeout() ? m_opaque_ap->GetTimeout()->count() : 0; 70 } 71 72 void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) { 73 m_opaque_ap->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) 74 : std::chrono::microseconds(timeout)); 75 } 76 77 uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const { 78 return m_opaque_ap->GetOneThreadTimeout() ? m_opaque_ap->GetOneThreadTimeout()->count() : 0; 79 } 80 81 void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { 82 m_opaque_ap->SetOneThreadTimeout(timeout == 0 83 ? Timeout<std::micro>(llvm::None) 84 : std::chrono::microseconds(timeout)); 85 } 86 87 bool SBExpressionOptions::GetTryAllThreads() const { 88 return m_opaque_ap->GetTryAllThreads(); 89 } 90 91 void SBExpressionOptions::SetTryAllThreads(bool run_others) { 92 m_opaque_ap->SetTryAllThreads(run_others); 93 } 94 95 bool SBExpressionOptions::GetStopOthers() const { 96 return m_opaque_ap->GetStopOthers(); 97 } 98 99 void SBExpressionOptions::SetStopOthers(bool run_others) { 100 m_opaque_ap->SetStopOthers(run_others); 101 } 102 103 bool SBExpressionOptions::GetTrapExceptions() const { 104 return m_opaque_ap->GetTrapExceptions(); 105 } 106 107 void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) { 108 m_opaque_ap->SetTrapExceptions(trap_exceptions); 109 } 110 111 void SBExpressionOptions::SetLanguage(lldb::LanguageType language) { 112 m_opaque_ap->SetLanguage(language); 113 } 114 115 void SBExpressionOptions::SetCancelCallback( 116 lldb::ExpressionCancelCallback callback, void *baton) { 117 m_opaque_ap->SetCancelCallback(callback, baton); 118 } 119 120 bool SBExpressionOptions::GetGenerateDebugInfo() { 121 return m_opaque_ap->GetGenerateDebugInfo(); 122 } 123 124 void SBExpressionOptions::SetGenerateDebugInfo(bool b) { 125 return m_opaque_ap->SetGenerateDebugInfo(b); 126 } 127 128 bool SBExpressionOptions::GetSuppressPersistentResult() { 129 return m_opaque_ap->GetResultIsInternal(); 130 } 131 132 void SBExpressionOptions::SetSuppressPersistentResult(bool b) { 133 return m_opaque_ap->SetResultIsInternal(b); 134 } 135 136 const char *SBExpressionOptions::GetPrefix() const { 137 return m_opaque_ap->GetPrefix(); 138 } 139 140 void SBExpressionOptions::SetPrefix(const char *prefix) { 141 return m_opaque_ap->SetPrefix(prefix); 142 } 143 144 bool SBExpressionOptions::GetAutoApplyFixIts() { 145 return m_opaque_ap->GetAutoApplyFixIts(); 146 } 147 148 void SBExpressionOptions::SetAutoApplyFixIts(bool b) { 149 return m_opaque_ap->SetAutoApplyFixIts(b); 150 } 151 152 bool SBExpressionOptions::GetTopLevel() { 153 return m_opaque_ap->GetExecutionPolicy() == eExecutionPolicyTopLevel; 154 } 155 156 void SBExpressionOptions::SetTopLevel(bool b) { 157 m_opaque_ap->SetExecutionPolicy(b ? eExecutionPolicyTopLevel 158 : m_opaque_ap->default_execution_policy); 159 } 160 161 bool SBExpressionOptions::GetAllowJIT() { 162 return m_opaque_ap->GetExecutionPolicy() != eExecutionPolicyNever; 163 } 164 165 void SBExpressionOptions::SetAllowJIT(bool allow) { 166 m_opaque_ap->SetExecutionPolicy(allow ? m_opaque_ap->default_execution_policy 167 : eExecutionPolicyNever); 168 } 169 170 EvaluateExpressionOptions *SBExpressionOptions::get() const { 171 return m_opaque_ap.get(); 172 } 173 174 EvaluateExpressionOptions &SBExpressionOptions::ref() const { 175 return *(m_opaque_ap.get()); 176 } 177