180814287SRaphael Isemann //===-- SBExpressionOptions.cpp -------------------------------------------===// 235e1bda6SJim Ingham // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 635e1bda6SJim Ingham // 735e1bda6SJim Ingham //===----------------------------------------------------------------------===// 835e1bda6SJim Ingham 935e1bda6SJim Ingham #include "lldb/API/SBExpressionOptions.h" 10d51402acSJonas Devlieghere #include "lldb/Utility/ReproducerInstrumentation.h" 11bd4bf82aSJonas 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() 19baf5664fSJonas Devlieghere : m_opaque_up(new EvaluateExpressionOptions()) { 20baf5664fSJonas Devlieghere LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExpressionOptions); 21baf5664fSJonas Devlieghere } 2235e1bda6SJim Ingham 23a3436f73SKazu Hirata SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) { 24baf5664fSJonas Devlieghere LLDB_RECORD_CONSTRUCTOR(SBExpressionOptions, 25baf5664fSJonas Devlieghere (const lldb::SBExpressionOptions &), rhs); 26baf5664fSJonas Devlieghere 27bd4bf82aSJonas Devlieghere m_opaque_up = clone(rhs.m_opaque_up); 2835e1bda6SJim Ingham } 2935e1bda6SJim Ingham 30b9c1b51eSKate Stone const SBExpressionOptions &SBExpressionOptions:: 31b9c1b51eSKate Stone operator=(const SBExpressionOptions &rhs) { 32baf5664fSJonas Devlieghere LLDB_RECORD_METHOD( 33baf5664fSJonas Devlieghere const lldb::SBExpressionOptions &, 34baf5664fSJonas Devlieghere SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &), rhs); 35baf5664fSJonas Devlieghere 36bd4bf82aSJonas Devlieghere if (this != &rhs) 37bd4bf82aSJonas Devlieghere m_opaque_up = clone(rhs.m_opaque_up); 38*d232abc3SJonas Devlieghere return *this; 3935e1bda6SJim Ingham } 4035e1bda6SJim Ingham 41866b7a65SJonas Devlieghere SBExpressionOptions::~SBExpressionOptions() = default; 4235e1bda6SJim Ingham 43b9c1b51eSKate Stone bool SBExpressionOptions::GetCoerceResultToId() const { 44baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, 45baf5664fSJonas Devlieghere GetCoerceResultToId); 46baf5664fSJonas Devlieghere 47d5b44036SJonas Devlieghere return m_opaque_up->DoesCoerceToId(); 4835e1bda6SJim Ingham } 4935e1bda6SJim Ingham 50b9c1b51eSKate Stone void SBExpressionOptions::SetCoerceResultToId(bool coerce) { 51baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetCoerceResultToId, (bool), 52baf5664fSJonas Devlieghere coerce); 53baf5664fSJonas Devlieghere 54d5b44036SJonas Devlieghere m_opaque_up->SetCoerceToId(coerce); 5535e1bda6SJim Ingham } 5635e1bda6SJim Ingham 57b9c1b51eSKate Stone bool SBExpressionOptions::GetUnwindOnError() const { 58baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetUnwindOnError); 59baf5664fSJonas Devlieghere 60d5b44036SJonas Devlieghere return m_opaque_up->DoesUnwindOnError(); 6135e1bda6SJim Ingham } 6235e1bda6SJim Ingham 63b9c1b51eSKate Stone void SBExpressionOptions::SetUnwindOnError(bool unwind) { 64baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool), 65baf5664fSJonas Devlieghere unwind); 66baf5664fSJonas Devlieghere 67d5b44036SJonas Devlieghere m_opaque_up->SetUnwindOnError(unwind); 6835e1bda6SJim Ingham } 6935e1bda6SJim Ingham 70b9c1b51eSKate Stone bool SBExpressionOptions::GetIgnoreBreakpoints() const { 71baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, 72baf5664fSJonas Devlieghere GetIgnoreBreakpoints); 73baf5664fSJonas Devlieghere 74d5b44036SJonas Devlieghere return m_opaque_up->DoesIgnoreBreakpoints(); 75184e9811SJim Ingham } 76184e9811SJim Ingham 77b9c1b51eSKate Stone void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) { 78baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, (bool), 79baf5664fSJonas Devlieghere ignore); 80baf5664fSJonas Devlieghere 81d5b44036SJonas Devlieghere m_opaque_up->SetIgnoreBreakpoints(ignore); 82184e9811SJim Ingham } 83184e9811SJim Ingham 84b9c1b51eSKate Stone lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const { 85baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBExpressionOptions, 86baf5664fSJonas Devlieghere GetFetchDynamicValue); 87baf5664fSJonas Devlieghere 88d5b44036SJonas Devlieghere return m_opaque_up->GetUseDynamic(); 8935e1bda6SJim Ingham } 9035e1bda6SJim Ingham 91b9c1b51eSKate Stone void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) { 92baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetFetchDynamicValue, 93baf5664fSJonas Devlieghere (lldb::DynamicValueType), dynamic); 94baf5664fSJonas Devlieghere 95d5b44036SJonas Devlieghere m_opaque_up->SetUseDynamic(dynamic); 9635e1bda6SJim Ingham } 9735e1bda6SJim Ingham 98b9c1b51eSKate Stone uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const { 99baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions, 100baf5664fSJonas Devlieghere GetTimeoutInMicroSeconds); 101baf5664fSJonas Devlieghere 102d5b44036SJonas Devlieghere return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0; 10335e1bda6SJim Ingham } 10435e1bda6SJim Ingham 105b9c1b51eSKate Stone void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) { 106baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds, 107baf5664fSJonas Devlieghere (uint32_t), timeout); 108baf5664fSJonas Devlieghere 109d5b44036SJonas Devlieghere m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) 11043d35418SPavel Labath : std::chrono::microseconds(timeout)); 11135e1bda6SJim Ingham } 11235e1bda6SJim Ingham 113b9c1b51eSKate Stone uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const { 114baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions, 115baf5664fSJonas Devlieghere GetOneThreadTimeoutInMicroSeconds); 116baf5664fSJonas Devlieghere 117d5b44036SJonas Devlieghere return m_opaque_up->GetOneThreadTimeout() 118d5b44036SJonas Devlieghere ? m_opaque_up->GetOneThreadTimeout()->count() 119d5b44036SJonas Devlieghere : 0; 120914f4e70SJim Ingham } 121914f4e70SJim Ingham 122b9c1b51eSKate Stone void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { 123baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, 124baf5664fSJonas Devlieghere SetOneThreadTimeoutInMicroSeconds, (uint32_t), timeout); 125baf5664fSJonas Devlieghere 126d5b44036SJonas Devlieghere m_opaque_up->SetOneThreadTimeout(timeout == 0 12743d35418SPavel Labath ? Timeout<std::micro>(llvm::None) 12843d35418SPavel Labath : std::chrono::microseconds(timeout)); 129914f4e70SJim Ingham } 130914f4e70SJim Ingham 131b9c1b51eSKate Stone bool SBExpressionOptions::GetTryAllThreads() const { 132baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetTryAllThreads); 133baf5664fSJonas Devlieghere 134d5b44036SJonas Devlieghere return m_opaque_up->GetTryAllThreads(); 13535e1bda6SJim Ingham } 13635e1bda6SJim Ingham 137b9c1b51eSKate Stone void SBExpressionOptions::SetTryAllThreads(bool run_others) { 138baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool), 139baf5664fSJonas Devlieghere run_others); 140baf5664fSJonas Devlieghere 141d5b44036SJonas Devlieghere m_opaque_up->SetTryAllThreads(run_others); 1426fbc48bcSJim Ingham } 1436fbc48bcSJim Ingham 144b9c1b51eSKate Stone bool SBExpressionOptions::GetStopOthers() const { 145baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetStopOthers); 146baf5664fSJonas Devlieghere 147d5b44036SJonas Devlieghere return m_opaque_up->GetStopOthers(); 148286fb1efSJim Ingham } 149286fb1efSJim Ingham 150b9c1b51eSKate Stone void SBExpressionOptions::SetStopOthers(bool run_others) { 151baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetStopOthers, (bool), 152baf5664fSJonas Devlieghere run_others); 153baf5664fSJonas Devlieghere 154d5b44036SJonas Devlieghere m_opaque_up->SetStopOthers(run_others); 155286fb1efSJim Ingham } 156286fb1efSJim Ingham 157b9c1b51eSKate Stone bool SBExpressionOptions::GetTrapExceptions() const { 158baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, 159baf5664fSJonas Devlieghere GetTrapExceptions); 160baf5664fSJonas Devlieghere 161d5b44036SJonas Devlieghere return m_opaque_up->GetTrapExceptions(); 1626fbc48bcSJim Ingham } 1636fbc48bcSJim Ingham 164b9c1b51eSKate Stone void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) { 165baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool), 166baf5664fSJonas Devlieghere trap_exceptions); 167baf5664fSJonas Devlieghere 168d5b44036SJonas Devlieghere m_opaque_up->SetTrapExceptions(trap_exceptions); 16935e1bda6SJim Ingham } 17035e1bda6SJim Ingham 171b9c1b51eSKate Stone void SBExpressionOptions::SetLanguage(lldb::LanguageType language) { 172baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetLanguage, 173baf5664fSJonas Devlieghere (lldb::LanguageType), language); 174baf5664fSJonas Devlieghere 175d5b44036SJonas Devlieghere m_opaque_up->SetLanguage(language); 176705b1809SJason Molenda } 177705b1809SJason Molenda 178b9c1b51eSKate Stone void SBExpressionOptions::SetCancelCallback( 179b9c1b51eSKate Stone lldb::ExpressionCancelCallback callback, void *baton) { 1800d7b0c96SJonas Devlieghere LLDB_RECORD_DUMMY(void, SBExpressionOptions, SetCancelCallback, 1817bc83564SJonas Devlieghere (lldb::ExpressionCancelCallback, void *), callback, baton); 1820d7b0c96SJonas Devlieghere 183d5b44036SJonas Devlieghere m_opaque_up->SetCancelCallback(callback, baton); 1841624a2d3SJim Ingham } 1851624a2d3SJim Ingham 186b9c1b51eSKate Stone bool SBExpressionOptions::GetGenerateDebugInfo() { 187baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetGenerateDebugInfo); 188baf5664fSJonas Devlieghere 189d5b44036SJonas Devlieghere return m_opaque_up->GetGenerateDebugInfo(); 190205ca1e8SGreg Clayton } 191205ca1e8SGreg Clayton 192b9c1b51eSKate Stone void SBExpressionOptions::SetGenerateDebugInfo(bool b) { 193baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, (bool), 194baf5664fSJonas Devlieghere b); 195baf5664fSJonas Devlieghere 196d5b44036SJonas Devlieghere return m_opaque_up->SetGenerateDebugInfo(b); 197205ca1e8SGreg Clayton } 198205ca1e8SGreg Clayton 199b9c1b51eSKate Stone bool SBExpressionOptions::GetSuppressPersistentResult() { 200baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, 201baf5664fSJonas Devlieghere GetSuppressPersistentResult); 202baf5664fSJonas Devlieghere 203d5b44036SJonas Devlieghere return m_opaque_up->GetResultIsInternal(); 2047ab079b6SJim Ingham } 2057ab079b6SJim Ingham 206b9c1b51eSKate Stone void SBExpressionOptions::SetSuppressPersistentResult(bool b) { 207baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult, 208baf5664fSJonas Devlieghere (bool), b); 209baf5664fSJonas Devlieghere 210d5b44036SJonas Devlieghere return m_opaque_up->SetResultIsInternal(b); 2117ab079b6SJim Ingham } 2127ab079b6SJim Ingham 213b9c1b51eSKate Stone const char *SBExpressionOptions::GetPrefix() const { 214baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBExpressionOptions, 215baf5664fSJonas Devlieghere GetPrefix); 216baf5664fSJonas Devlieghere 217d5b44036SJonas Devlieghere return m_opaque_up->GetPrefix(); 2184e1042e1SGreg Clayton } 2194e1042e1SGreg Clayton 220b9c1b51eSKate Stone void SBExpressionOptions::SetPrefix(const char *prefix) { 221baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetPrefix, (const char *), 222baf5664fSJonas Devlieghere prefix); 223baf5664fSJonas Devlieghere 224d5b44036SJonas Devlieghere return m_opaque_up->SetPrefix(prefix); 2254e1042e1SGreg Clayton } 2267ab079b6SJim Ingham 227b9c1b51eSKate Stone bool SBExpressionOptions::GetAutoApplyFixIts() { 228baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAutoApplyFixIts); 229baf5664fSJonas Devlieghere 230d5b44036SJonas Devlieghere return m_opaque_up->GetAutoApplyFixIts(); 231a1e541bfSJim Ingham } 232a1e541bfSJim Ingham 233b9c1b51eSKate Stone void SBExpressionOptions::SetAutoApplyFixIts(bool b) { 234baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool), b); 235baf5664fSJonas Devlieghere 236d5b44036SJonas Devlieghere return m_opaque_up->SetAutoApplyFixIts(b); 237a1e541bfSJim Ingham } 238a1e541bfSJim Ingham 239203a8adbSRaphael Isemann uint64_t SBExpressionOptions::GetRetriesWithFixIts() { 240203a8adbSRaphael Isemann LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBExpressionOptions, 241203a8adbSRaphael Isemann GetRetriesWithFixIts); 242203a8adbSRaphael Isemann 243203a8adbSRaphael Isemann return m_opaque_up->GetRetriesWithFixIts(); 244203a8adbSRaphael Isemann } 245203a8adbSRaphael Isemann 246203a8adbSRaphael Isemann void SBExpressionOptions::SetRetriesWithFixIts(uint64_t retries) { 247203a8adbSRaphael Isemann LLDB_RECORD_METHOD(void, SBExpressionOptions, SetRetriesWithFixIts, 248203a8adbSRaphael Isemann (uint64_t), retries); 249203a8adbSRaphael Isemann 250203a8adbSRaphael Isemann return m_opaque_up->SetRetriesWithFixIts(retries); 251203a8adbSRaphael Isemann } 252203a8adbSRaphael Isemann 253b9c1b51eSKate Stone bool SBExpressionOptions::GetTopLevel() { 254baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel); 255baf5664fSJonas Devlieghere 256d5b44036SJonas Devlieghere return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel; 257863fab69SSean Callanan } 258863fab69SSean Callanan 259b9c1b51eSKate Stone void SBExpressionOptions::SetTopLevel(bool b) { 260baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTopLevel, (bool), b); 261baf5664fSJonas Devlieghere 262d5b44036SJonas Devlieghere m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel 263d5b44036SJonas Devlieghere : m_opaque_up->default_execution_policy); 264863fab69SSean Callanan } 265863fab69SSean Callanan 266ab639986SJim Ingham bool SBExpressionOptions::GetAllowJIT() { 267baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAllowJIT); 268baf5664fSJonas Devlieghere 269d5b44036SJonas Devlieghere return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever; 270ab639986SJim Ingham } 271ab639986SJim Ingham 272ab639986SJim Ingham void SBExpressionOptions::SetAllowJIT(bool allow) { 273baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool), allow); 274baf5664fSJonas Devlieghere 275d5b44036SJonas Devlieghere m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy 276ab639986SJim Ingham : eExecutionPolicyNever); 277ab639986SJim Ingham } 278ab639986SJim Ingham 279b9c1b51eSKate Stone EvaluateExpressionOptions *SBExpressionOptions::get() const { 280d5b44036SJonas Devlieghere return m_opaque_up.get(); 28135e1bda6SJim Ingham } 28235e1bda6SJim Ingham 283b9c1b51eSKate Stone EvaluateExpressionOptions &SBExpressionOptions::ref() const { 284d5b44036SJonas Devlieghere return *(m_opaque_up.get()); 28535e1bda6SJim Ingham } 286