1435933ddSDimitry Andric //===-- SBExpressionOptions.cpp ---------------------------------------------*- 2435933ddSDimitry Andric //C++ -*-===// 3ac7ddfbfSEd Maste // 4ac7ddfbfSEd Maste // The LLVM Compiler Infrastructure 5ac7ddfbfSEd Maste // 6ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source 7ac7ddfbfSEd Maste // License. See LICENSE.TXT for details. 8ac7ddfbfSEd Maste // 9ac7ddfbfSEd Maste //===----------------------------------------------------------------------===// 10ac7ddfbfSEd Maste 11ac7ddfbfSEd Maste #include "lldb/API/SBExpressionOptions.h" 12ac7ddfbfSEd Maste #include "lldb/API/SBStream.h" 13ac7ddfbfSEd Maste 14ac7ddfbfSEd Maste #include "lldb/Target/Target.h" 15ac7ddfbfSEd Maste 16ac7ddfbfSEd Maste using namespace lldb; 17ac7ddfbfSEd Maste using namespace lldb_private; 18ac7ddfbfSEd Maste SBExpressionOptions()19435933ddSDimitry AndricSBExpressionOptions::SBExpressionOptions() 20435933ddSDimitry Andric : m_opaque_ap(new EvaluateExpressionOptions()) {} 21ac7ddfbfSEd Maste SBExpressionOptions(const SBExpressionOptions & rhs)22435933ddSDimitry AndricSBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) { 23ac7ddfbfSEd Maste m_opaque_ap.reset(new EvaluateExpressionOptions()); 24ac7ddfbfSEd Maste *(m_opaque_ap.get()) = rhs.ref(); 25ac7ddfbfSEd Maste } 26ac7ddfbfSEd Maste 27435933ddSDimitry Andric const SBExpressionOptions &SBExpressionOptions:: operator =(const SBExpressionOptions & rhs)28435933ddSDimitry Andricoperator=(const SBExpressionOptions &rhs) { 29435933ddSDimitry Andric if (this != &rhs) { 30ac7ddfbfSEd Maste this->ref() = rhs.ref(); 31ac7ddfbfSEd Maste } 32ac7ddfbfSEd Maste return *this; 33ac7ddfbfSEd Maste } 34ac7ddfbfSEd Maste ~SBExpressionOptions()35435933ddSDimitry AndricSBExpressionOptions::~SBExpressionOptions() {} 36ac7ddfbfSEd Maste GetCoerceResultToId() const37435933ddSDimitry Andricbool SBExpressionOptions::GetCoerceResultToId() const { 38ac7ddfbfSEd Maste return m_opaque_ap->DoesCoerceToId(); 39ac7ddfbfSEd Maste } 40ac7ddfbfSEd Maste SetCoerceResultToId(bool coerce)41435933ddSDimitry Andricvoid SBExpressionOptions::SetCoerceResultToId(bool coerce) { 42ac7ddfbfSEd Maste m_opaque_ap->SetCoerceToId(coerce); 43ac7ddfbfSEd Maste } 44ac7ddfbfSEd Maste GetUnwindOnError() const45435933ddSDimitry Andricbool SBExpressionOptions::GetUnwindOnError() const { 46ac7ddfbfSEd Maste return m_opaque_ap->DoesUnwindOnError(); 47ac7ddfbfSEd Maste } 48ac7ddfbfSEd Maste SetUnwindOnError(bool unwind)49435933ddSDimitry Andricvoid SBExpressionOptions::SetUnwindOnError(bool unwind) { 50ac7ddfbfSEd Maste m_opaque_ap->SetUnwindOnError(unwind); 51ac7ddfbfSEd Maste } 52ac7ddfbfSEd Maste GetIgnoreBreakpoints() const53435933ddSDimitry Andricbool SBExpressionOptions::GetIgnoreBreakpoints() const { 54ac7ddfbfSEd Maste return m_opaque_ap->DoesIgnoreBreakpoints(); 55ac7ddfbfSEd Maste } 56ac7ddfbfSEd Maste SetIgnoreBreakpoints(bool ignore)57435933ddSDimitry Andricvoid SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) { 58ac7ddfbfSEd Maste m_opaque_ap->SetIgnoreBreakpoints(ignore); 59ac7ddfbfSEd Maste } 60ac7ddfbfSEd Maste GetFetchDynamicValue() const61435933ddSDimitry Andriclldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const { 62ac7ddfbfSEd Maste return m_opaque_ap->GetUseDynamic(); 63ac7ddfbfSEd Maste } 64ac7ddfbfSEd Maste SetFetchDynamicValue(lldb::DynamicValueType dynamic)65435933ddSDimitry Andricvoid SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) { 66ac7ddfbfSEd Maste m_opaque_ap->SetUseDynamic(dynamic); 67ac7ddfbfSEd Maste } 68ac7ddfbfSEd Maste GetTimeoutInMicroSeconds() const69435933ddSDimitry Andricuint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const { 70435933ddSDimitry Andric return m_opaque_ap->GetTimeout() ? m_opaque_ap->GetTimeout()->count() : 0; 71ac7ddfbfSEd Maste } 72ac7ddfbfSEd Maste SetTimeoutInMicroSeconds(uint32_t timeout)73435933ddSDimitry Andricvoid SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) { 74435933ddSDimitry Andric m_opaque_ap->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) 75435933ddSDimitry Andric : std::chrono::microseconds(timeout)); 76ac7ddfbfSEd Maste } 77ac7ddfbfSEd Maste GetOneThreadTimeoutInMicroSeconds() const78435933ddSDimitry Andricuint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const { 79435933ddSDimitry Andric return m_opaque_ap->GetOneThreadTimeout() ? m_opaque_ap->GetOneThreadTimeout()->count() : 0; 800127ef0fSEd Maste } 810127ef0fSEd Maste SetOneThreadTimeoutInMicroSeconds(uint32_t timeout)82435933ddSDimitry Andricvoid SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { 83435933ddSDimitry Andric m_opaque_ap->SetOneThreadTimeout(timeout == 0 84435933ddSDimitry Andric ? Timeout<std::micro>(llvm::None) 85435933ddSDimitry Andric : std::chrono::microseconds(timeout)); 860127ef0fSEd Maste } 870127ef0fSEd Maste GetTryAllThreads() const88435933ddSDimitry Andricbool SBExpressionOptions::GetTryAllThreads() const { 89b952cd58SEd Maste return m_opaque_ap->GetTryAllThreads(); 90ac7ddfbfSEd Maste } 91ac7ddfbfSEd Maste SetTryAllThreads(bool run_others)92435933ddSDimitry Andricvoid SBExpressionOptions::SetTryAllThreads(bool run_others) { 93b952cd58SEd Maste m_opaque_ap->SetTryAllThreads(run_others); 94b952cd58SEd Maste } 95b952cd58SEd Maste GetStopOthers() const96435933ddSDimitry Andricbool SBExpressionOptions::GetStopOthers() const { 970127ef0fSEd Maste return m_opaque_ap->GetStopOthers(); 980127ef0fSEd Maste } 990127ef0fSEd Maste SetStopOthers(bool run_others)100435933ddSDimitry Andricvoid SBExpressionOptions::SetStopOthers(bool run_others) { 1010127ef0fSEd Maste m_opaque_ap->SetStopOthers(run_others); 1020127ef0fSEd Maste } 1030127ef0fSEd Maste GetTrapExceptions() const104435933ddSDimitry Andricbool SBExpressionOptions::GetTrapExceptions() const { 105b952cd58SEd Maste return m_opaque_ap->GetTrapExceptions(); 106b952cd58SEd Maste } 107b952cd58SEd Maste SetTrapExceptions(bool trap_exceptions)108435933ddSDimitry Andricvoid SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) { 109b952cd58SEd Maste m_opaque_ap->SetTrapExceptions(trap_exceptions); 110ac7ddfbfSEd Maste } 111ac7ddfbfSEd Maste SetLanguage(lldb::LanguageType language)112435933ddSDimitry Andricvoid SBExpressionOptions::SetLanguage(lldb::LanguageType language) { 1130127ef0fSEd Maste m_opaque_ap->SetLanguage(language); 1140127ef0fSEd Maste } 1150127ef0fSEd Maste SetCancelCallback(lldb::ExpressionCancelCallback callback,void * baton)116435933ddSDimitry Andricvoid SBExpressionOptions::SetCancelCallback( 117435933ddSDimitry Andric lldb::ExpressionCancelCallback callback, void *baton) { 1180127ef0fSEd Maste m_opaque_ap->SetCancelCallback(callback, baton); 1190127ef0fSEd Maste } 1200127ef0fSEd Maste GetGenerateDebugInfo()121435933ddSDimitry Andricbool SBExpressionOptions::GetGenerateDebugInfo() { 1220127ef0fSEd Maste return m_opaque_ap->GetGenerateDebugInfo(); 1230127ef0fSEd Maste } 1240127ef0fSEd Maste SetGenerateDebugInfo(bool b)125435933ddSDimitry Andricvoid SBExpressionOptions::SetGenerateDebugInfo(bool b) { 1260127ef0fSEd Maste return m_opaque_ap->SetGenerateDebugInfo(b); 1270127ef0fSEd Maste } 1280127ef0fSEd Maste GetSuppressPersistentResult()129435933ddSDimitry Andricbool SBExpressionOptions::GetSuppressPersistentResult() { 1300127ef0fSEd Maste return m_opaque_ap->GetResultIsInternal(); 1310127ef0fSEd Maste } 1320127ef0fSEd Maste SetSuppressPersistentResult(bool b)133435933ddSDimitry Andricvoid SBExpressionOptions::SetSuppressPersistentResult(bool b) { 1340127ef0fSEd Maste return m_opaque_ap->SetResultIsInternal(b); 1350127ef0fSEd Maste } 1360127ef0fSEd Maste GetPrefix() const137435933ddSDimitry Andricconst char *SBExpressionOptions::GetPrefix() const { 1381c3bbb01SEd Maste return m_opaque_ap->GetPrefix(); 1391c3bbb01SEd Maste } 1401c3bbb01SEd Maste SetPrefix(const char * prefix)141435933ddSDimitry Andricvoid SBExpressionOptions::SetPrefix(const char *prefix) { 1421c3bbb01SEd Maste return m_opaque_ap->SetPrefix(prefix); 1431c3bbb01SEd Maste } 1440127ef0fSEd Maste GetAutoApplyFixIts()145435933ddSDimitry Andricbool SBExpressionOptions::GetAutoApplyFixIts() { 1464bb0738eSEd Maste return m_opaque_ap->GetAutoApplyFixIts(); 1474bb0738eSEd Maste } 1484bb0738eSEd Maste SetAutoApplyFixIts(bool b)149435933ddSDimitry Andricvoid SBExpressionOptions::SetAutoApplyFixIts(bool b) { 1504bb0738eSEd Maste return m_opaque_ap->SetAutoApplyFixIts(b); 1514bb0738eSEd Maste } 1524bb0738eSEd Maste GetTopLevel()153435933ddSDimitry Andricbool SBExpressionOptions::GetTopLevel() { 1544bb0738eSEd Maste return m_opaque_ap->GetExecutionPolicy() == eExecutionPolicyTopLevel; 1554bb0738eSEd Maste } 1564bb0738eSEd Maste SetTopLevel(bool b)157435933ddSDimitry Andricvoid SBExpressionOptions::SetTopLevel(bool b) { 158435933ddSDimitry Andric m_opaque_ap->SetExecutionPolicy(b ? eExecutionPolicyTopLevel 159435933ddSDimitry Andric : m_opaque_ap->default_execution_policy); 1604bb0738eSEd Maste } 1614bb0738eSEd Maste GetAllowJIT()162*b5893f02SDimitry Andricbool SBExpressionOptions::GetAllowJIT() { 163*b5893f02SDimitry Andric return m_opaque_ap->GetExecutionPolicy() != eExecutionPolicyNever; 164*b5893f02SDimitry Andric } 165*b5893f02SDimitry Andric SetAllowJIT(bool allow)166*b5893f02SDimitry Andricvoid SBExpressionOptions::SetAllowJIT(bool allow) { 167*b5893f02SDimitry Andric m_opaque_ap->SetExecutionPolicy(allow ? m_opaque_ap->default_execution_policy 168*b5893f02SDimitry Andric : eExecutionPolicyNever); 169*b5893f02SDimitry Andric } 170*b5893f02SDimitry Andric get() const171435933ddSDimitry AndricEvaluateExpressionOptions *SBExpressionOptions::get() const { 172ac7ddfbfSEd Maste return m_opaque_ap.get(); 173ac7ddfbfSEd Maste } 174ac7ddfbfSEd Maste ref() const175435933ddSDimitry AndricEvaluateExpressionOptions &SBExpressionOptions::ref() const { 176ac7ddfbfSEd Maste return *(m_opaque_ap.get()); 177ac7ddfbfSEd Maste } 178