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