Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1 | //===-- SBExpressionOptions.cpp ---------------------------------------------*- |
| 2 | //C++ -*-===// |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 3 | // |
| 4 | // The LLVM Compiler Infrastructure |
| 5 | // |
| 6 | // This file is distributed under the University of Illinois Open Source |
| 7 | // License. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #include "lldb/API/SBExpressionOptions.h" |
| 12 | #include "lldb/API/SBStream.h" |
| 13 | |
| 14 | #include "lldb/Target/Target.h" |
| 15 | |
| 16 | using namespace lldb; |
| 17 | using namespace lldb_private; |
| 18 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 19 | SBExpressionOptions::SBExpressionOptions() |
| 20 | : m_opaque_ap(new EvaluateExpressionOptions()) {} |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 21 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 22 | SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) { |
| 23 | m_opaque_ap.reset(new EvaluateExpressionOptions()); |
| 24 | *(m_opaque_ap.get()) = rhs.ref(); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 25 | } |
| 26 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 27 | const SBExpressionOptions &SBExpressionOptions:: |
| 28 | operator=(const SBExpressionOptions &rhs) { |
| 29 | if (this != &rhs) { |
| 30 | this->ref() = rhs.ref(); |
| 31 | } |
| 32 | return *this; |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 35 | SBExpressionOptions::~SBExpressionOptions() {} |
| 36 | |
| 37 | bool SBExpressionOptions::GetCoerceResultToId() const { |
| 38 | return m_opaque_ap->DoesCoerceToId(); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 39 | } |
| 40 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 41 | void SBExpressionOptions::SetCoerceResultToId(bool coerce) { |
| 42 | m_opaque_ap->SetCoerceToId(coerce); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 45 | bool SBExpressionOptions::GetUnwindOnError() const { |
| 46 | return m_opaque_ap->DoesUnwindOnError(); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 49 | void SBExpressionOptions::SetUnwindOnError(bool unwind) { |
| 50 | m_opaque_ap->SetUnwindOnError(unwind); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 53 | bool SBExpressionOptions::GetIgnoreBreakpoints() const { |
| 54 | return m_opaque_ap->DoesIgnoreBreakpoints(); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 55 | } |
| 56 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 57 | void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) { |
| 58 | m_opaque_ap->SetIgnoreBreakpoints(ignore); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 61 | lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const { |
| 62 | return m_opaque_ap->GetUseDynamic(); |
Jim Ingham | 184e981 | 2013-01-15 02:47:48 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 65 | void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) { |
| 66 | m_opaque_ap->SetUseDynamic(dynamic); |
Jim Ingham | 184e981 | 2013-01-15 02:47:48 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 69 | uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const { |
Pavel Labath | 43d3541 | 2016-12-06 11:24:51 +0000 | [diff] [blame] | 70 | return m_opaque_ap->GetTimeout() ? m_opaque_ap->GetTimeout()->count() : 0; |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 73 | void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) { |
Pavel Labath | 43d3541 | 2016-12-06 11:24:51 +0000 | [diff] [blame] | 74 | m_opaque_ap->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) |
| 75 | : std::chrono::microseconds(timeout)); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 78 | uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const { |
Pavel Labath | 43d3541 | 2016-12-06 11:24:51 +0000 | [diff] [blame] | 79 | return m_opaque_ap->GetOneThreadTimeout() ? m_opaque_ap->GetOneThreadTimeout()->count() : 0; |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 82 | void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { |
Pavel Labath | 43d3541 | 2016-12-06 11:24:51 +0000 | [diff] [blame] | 83 | m_opaque_ap->SetOneThreadTimeout(timeout == 0 |
| 84 | ? Timeout<std::micro>(llvm::None) |
| 85 | : std::chrono::microseconds(timeout)); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 88 | bool SBExpressionOptions::GetTryAllThreads() const { |
| 89 | return m_opaque_ap->GetTryAllThreads(); |
Jim Ingham | 914f4e7 | 2014-03-28 21:58:28 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 92 | void SBExpressionOptions::SetTryAllThreads(bool run_others) { |
| 93 | m_opaque_ap->SetTryAllThreads(run_others); |
Jim Ingham | 914f4e7 | 2014-03-28 21:58:28 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 96 | bool SBExpressionOptions::GetStopOthers() const { |
| 97 | return m_opaque_ap->GetStopOthers(); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 98 | } |
| 99 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 100 | void SBExpressionOptions::SetStopOthers(bool run_others) { |
| 101 | m_opaque_ap->SetStopOthers(run_others); |
Jim Ingham | 6fbc48b | 2013-11-07 00:11:47 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 104 | bool SBExpressionOptions::GetTrapExceptions() const { |
| 105 | return m_opaque_ap->GetTrapExceptions(); |
Jim Ingham | 286fb1e | 2014-02-28 02:52:06 +0000 | [diff] [blame] | 106 | } |
| 107 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 108 | void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) { |
| 109 | m_opaque_ap->SetTrapExceptions(trap_exceptions); |
Jim Ingham | 286fb1e | 2014-02-28 02:52:06 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 112 | void SBExpressionOptions::SetLanguage(lldb::LanguageType language) { |
| 113 | m_opaque_ap->SetLanguage(language); |
Jim Ingham | 6fbc48b | 2013-11-07 00:11:47 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 116 | void SBExpressionOptions::SetCancelCallback( |
| 117 | lldb::ExpressionCancelCallback callback, void *baton) { |
| 118 | m_opaque_ap->SetCancelCallback(callback, baton); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 119 | } |
| 120 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 121 | bool SBExpressionOptions::GetGenerateDebugInfo() { |
| 122 | return m_opaque_ap->GetGenerateDebugInfo(); |
Jason Molenda | 705b180 | 2014-06-13 02:37:02 +0000 | [diff] [blame] | 123 | } |
| 124 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 125 | void SBExpressionOptions::SetGenerateDebugInfo(bool b) { |
| 126 | return m_opaque_ap->SetGenerateDebugInfo(b); |
Jim Ingham | 1624a2d | 2014-05-05 02:26:40 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 129 | bool SBExpressionOptions::GetSuppressPersistentResult() { |
| 130 | return m_opaque_ap->GetResultIsInternal(); |
Greg Clayton | 205ca1e | 2014-07-11 01:03:57 +0000 | [diff] [blame] | 131 | } |
| 132 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 133 | void SBExpressionOptions::SetSuppressPersistentResult(bool b) { |
| 134 | return m_opaque_ap->SetResultIsInternal(b); |
Greg Clayton | 205ca1e | 2014-07-11 01:03:57 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 137 | const char *SBExpressionOptions::GetPrefix() const { |
| 138 | return m_opaque_ap->GetPrefix(); |
Jim Ingham | 7ab079b | 2014-08-08 21:45:36 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 141 | void SBExpressionOptions::SetPrefix(const char *prefix) { |
| 142 | return m_opaque_ap->SetPrefix(prefix); |
Jim Ingham | 7ab079b | 2014-08-08 21:45:36 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 145 | bool SBExpressionOptions::GetAutoApplyFixIts() { |
| 146 | return m_opaque_ap->GetAutoApplyFixIts(); |
Greg Clayton | 4e1042e | 2015-05-27 22:32:39 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 149 | void SBExpressionOptions::SetAutoApplyFixIts(bool b) { |
| 150 | return m_opaque_ap->SetAutoApplyFixIts(b); |
Greg Clayton | 4e1042e | 2015-05-27 22:32:39 +0000 | [diff] [blame] | 151 | } |
Jim Ingham | 7ab079b | 2014-08-08 21:45:36 +0000 | [diff] [blame] | 152 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 153 | bool SBExpressionOptions::GetTopLevel() { |
| 154 | return m_opaque_ap->GetExecutionPolicy() == eExecutionPolicyTopLevel; |
Jim Ingham | a1e541b | 2016-03-25 01:57:14 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 157 | void SBExpressionOptions::SetTopLevel(bool b) { |
| 158 | m_opaque_ap->SetExecutionPolicy(b ? eExecutionPolicyTopLevel |
| 159 | : m_opaque_ap->default_execution_policy); |
Jim Ingham | a1e541b | 2016-03-25 01:57:14 +0000 | [diff] [blame] | 160 | } |
| 161 | |
Jim Ingham | ab63998 | 2018-11-02 23:42:40 +0000 | [diff] [blame] | 162 | bool SBExpressionOptions::GetAllowJIT() { |
| 163 | return m_opaque_ap->GetExecutionPolicy() != eExecutionPolicyNever; |
| 164 | } |
| 165 | |
| 166 | void SBExpressionOptions::SetAllowJIT(bool allow) { |
| 167 | m_opaque_ap->SetExecutionPolicy(allow ? m_opaque_ap->default_execution_policy |
| 168 | : eExecutionPolicyNever); |
| 169 | } |
| 170 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 171 | EvaluateExpressionOptions *SBExpressionOptions::get() const { |
| 172 | return m_opaque_ap.get(); |
Sean Callanan | 863fab6 | 2016-03-28 21:20:05 +0000 | [diff] [blame] | 173 | } |
| 174 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 175 | EvaluateExpressionOptions &SBExpressionOptions::ref() const { |
| 176 | return *(m_opaque_ap.get()); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 177 | } |