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 "SBReproducerPrivate.h" 12 #include "Utils.h" 13 #include "lldb/API/SBStream.h" 14 #include "lldb/Target/Target.h" 15 16 using namespace lldb; 17 using namespace lldb_private; 18 19 SBExpressionOptions::SBExpressionOptions() 20 : m_opaque_up(new EvaluateExpressionOptions()) { 21 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExpressionOptions); 22 } 23 24 SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) 25 : m_opaque_up() { 26 LLDB_RECORD_CONSTRUCTOR(SBExpressionOptions, 27 (const lldb::SBExpressionOptions &), rhs); 28 29 m_opaque_up = clone(rhs.m_opaque_up); 30 } 31 32 const SBExpressionOptions &SBExpressionOptions:: 33 operator=(const SBExpressionOptions &rhs) { 34 LLDB_RECORD_METHOD( 35 const lldb::SBExpressionOptions &, 36 SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &), rhs); 37 38 if (this != &rhs) 39 m_opaque_up = clone(rhs.m_opaque_up); 40 return *this; 41 } 42 43 SBExpressionOptions::~SBExpressionOptions() {} 44 45 bool SBExpressionOptions::GetCoerceResultToId() const { 46 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, 47 GetCoerceResultToId); 48 49 return m_opaque_up->DoesCoerceToId(); 50 } 51 52 void SBExpressionOptions::SetCoerceResultToId(bool coerce) { 53 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetCoerceResultToId, (bool), 54 coerce); 55 56 m_opaque_up->SetCoerceToId(coerce); 57 } 58 59 bool SBExpressionOptions::GetUnwindOnError() const { 60 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetUnwindOnError); 61 62 return m_opaque_up->DoesUnwindOnError(); 63 } 64 65 void SBExpressionOptions::SetUnwindOnError(bool unwind) { 66 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool), 67 unwind); 68 69 m_opaque_up->SetUnwindOnError(unwind); 70 } 71 72 bool SBExpressionOptions::GetIgnoreBreakpoints() const { 73 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, 74 GetIgnoreBreakpoints); 75 76 return m_opaque_up->DoesIgnoreBreakpoints(); 77 } 78 79 void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) { 80 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, (bool), 81 ignore); 82 83 m_opaque_up->SetIgnoreBreakpoints(ignore); 84 } 85 86 lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const { 87 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBExpressionOptions, 88 GetFetchDynamicValue); 89 90 return m_opaque_up->GetUseDynamic(); 91 } 92 93 void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) { 94 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetFetchDynamicValue, 95 (lldb::DynamicValueType), dynamic); 96 97 m_opaque_up->SetUseDynamic(dynamic); 98 } 99 100 uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const { 101 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions, 102 GetTimeoutInMicroSeconds); 103 104 return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0; 105 } 106 107 void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) { 108 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds, 109 (uint32_t), timeout); 110 111 m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) 112 : std::chrono::microseconds(timeout)); 113 } 114 115 uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const { 116 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions, 117 GetOneThreadTimeoutInMicroSeconds); 118 119 return m_opaque_up->GetOneThreadTimeout() 120 ? m_opaque_up->GetOneThreadTimeout()->count() 121 : 0; 122 } 123 124 void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { 125 LLDB_RECORD_METHOD(void, SBExpressionOptions, 126 SetOneThreadTimeoutInMicroSeconds, (uint32_t), timeout); 127 128 m_opaque_up->SetOneThreadTimeout(timeout == 0 129 ? Timeout<std::micro>(llvm::None) 130 : std::chrono::microseconds(timeout)); 131 } 132 133 bool SBExpressionOptions::GetTryAllThreads() const { 134 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetTryAllThreads); 135 136 return m_opaque_up->GetTryAllThreads(); 137 } 138 139 void SBExpressionOptions::SetTryAllThreads(bool run_others) { 140 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool), 141 run_others); 142 143 m_opaque_up->SetTryAllThreads(run_others); 144 } 145 146 bool SBExpressionOptions::GetStopOthers() const { 147 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetStopOthers); 148 149 return m_opaque_up->GetStopOthers(); 150 } 151 152 void SBExpressionOptions::SetStopOthers(bool run_others) { 153 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetStopOthers, (bool), 154 run_others); 155 156 m_opaque_up->SetStopOthers(run_others); 157 } 158 159 bool SBExpressionOptions::GetTrapExceptions() const { 160 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, 161 GetTrapExceptions); 162 163 return m_opaque_up->GetTrapExceptions(); 164 } 165 166 void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) { 167 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool), 168 trap_exceptions); 169 170 m_opaque_up->SetTrapExceptions(trap_exceptions); 171 } 172 173 void SBExpressionOptions::SetLanguage(lldb::LanguageType language) { 174 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetLanguage, 175 (lldb::LanguageType), language); 176 177 m_opaque_up->SetLanguage(language); 178 } 179 180 void SBExpressionOptions::SetCancelCallback( 181 lldb::ExpressionCancelCallback callback, void *baton) { 182 m_opaque_up->SetCancelCallback(callback, baton); 183 } 184 185 bool SBExpressionOptions::GetGenerateDebugInfo() { 186 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetGenerateDebugInfo); 187 188 return m_opaque_up->GetGenerateDebugInfo(); 189 } 190 191 void SBExpressionOptions::SetGenerateDebugInfo(bool b) { 192 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, (bool), 193 b); 194 195 return m_opaque_up->SetGenerateDebugInfo(b); 196 } 197 198 bool SBExpressionOptions::GetSuppressPersistentResult() { 199 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, 200 GetSuppressPersistentResult); 201 202 return m_opaque_up->GetResultIsInternal(); 203 } 204 205 void SBExpressionOptions::SetSuppressPersistentResult(bool b) { 206 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult, 207 (bool), b); 208 209 return m_opaque_up->SetResultIsInternal(b); 210 } 211 212 const char *SBExpressionOptions::GetPrefix() const { 213 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBExpressionOptions, 214 GetPrefix); 215 216 return m_opaque_up->GetPrefix(); 217 } 218 219 void SBExpressionOptions::SetPrefix(const char *prefix) { 220 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetPrefix, (const char *), 221 prefix); 222 223 return m_opaque_up->SetPrefix(prefix); 224 } 225 226 bool SBExpressionOptions::GetAutoApplyFixIts() { 227 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAutoApplyFixIts); 228 229 return m_opaque_up->GetAutoApplyFixIts(); 230 } 231 232 void SBExpressionOptions::SetAutoApplyFixIts(bool b) { 233 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool), b); 234 235 return m_opaque_up->SetAutoApplyFixIts(b); 236 } 237 238 bool SBExpressionOptions::GetTopLevel() { 239 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel); 240 241 return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel; 242 } 243 244 void SBExpressionOptions::SetTopLevel(bool b) { 245 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTopLevel, (bool), b); 246 247 m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel 248 : m_opaque_up->default_execution_policy); 249 } 250 251 bool SBExpressionOptions::GetAllowJIT() { 252 LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAllowJIT); 253 254 return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever; 255 } 256 257 void SBExpressionOptions::SetAllowJIT(bool allow) { 258 LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool), allow); 259 260 m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy 261 : eExecutionPolicyNever); 262 } 263 264 EvaluateExpressionOptions *SBExpressionOptions::get() const { 265 return m_opaque_up.get(); 266 } 267 268 EvaluateExpressionOptions &SBExpressionOptions::ref() const { 269 return *(m_opaque_up.get()); 270 } 271