xref: /src/contrib/llvm-project/lldb/source/API/SBExpressionOptions.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1cfca06d7SDimitry Andric //===-- SBExpressionOptions.cpp -------------------------------------------===//
2f034231aSEd Maste //
35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f034231aSEd Maste //
7f034231aSEd Maste //===----------------------------------------------------------------------===//
8f034231aSEd Maste 
9f034231aSEd Maste #include "lldb/API/SBExpressionOptions.h"
105f29bb8aSDimitry Andric #include "Utils.h"
11f034231aSEd Maste #include "lldb/API/SBStream.h"
12f034231aSEd Maste #include "lldb/Target/Target.h"
136f8fc217SDimitry Andric #include "lldb/Utility/Instrumentation.h"
14f034231aSEd Maste 
15f034231aSEd Maste using namespace lldb;
16f034231aSEd Maste using namespace lldb_private;
17f034231aSEd Maste 
SBExpressionOptions()1814f1b3e8SDimitry Andric SBExpressionOptions::SBExpressionOptions()
195f29bb8aSDimitry Andric     : m_opaque_up(new EvaluateExpressionOptions()) {
206f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
215f29bb8aSDimitry Andric }
22f034231aSEd Maste 
SBExpressionOptions(const SBExpressionOptions & rhs)236f8fc217SDimitry Andric SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) {
246f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
255f29bb8aSDimitry Andric 
265f29bb8aSDimitry Andric   m_opaque_up = clone(rhs.m_opaque_up);
27f034231aSEd Maste }
28f034231aSEd Maste 
2914f1b3e8SDimitry Andric const SBExpressionOptions &SBExpressionOptions::
operator =(const SBExpressionOptions & rhs)3014f1b3e8SDimitry Andric operator=(const SBExpressionOptions &rhs) {
316f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
325f29bb8aSDimitry Andric 
335f29bb8aSDimitry Andric   if (this != &rhs)
345f29bb8aSDimitry Andric     m_opaque_up = clone(rhs.m_opaque_up);
356f8fc217SDimitry Andric   return *this;
36f034231aSEd Maste }
37f034231aSEd Maste 
38cfca06d7SDimitry Andric SBExpressionOptions::~SBExpressionOptions() = default;
39f034231aSEd Maste 
GetCoerceResultToId() const4014f1b3e8SDimitry Andric bool SBExpressionOptions::GetCoerceResultToId() const {
416f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
425f29bb8aSDimitry Andric 
435f29bb8aSDimitry Andric   return m_opaque_up->DoesCoerceToId();
44f034231aSEd Maste }
45f034231aSEd Maste 
SetCoerceResultToId(bool coerce)4614f1b3e8SDimitry Andric void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
476f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, coerce);
485f29bb8aSDimitry Andric 
495f29bb8aSDimitry Andric   m_opaque_up->SetCoerceToId(coerce);
50f034231aSEd Maste }
51f034231aSEd Maste 
GetUnwindOnError() const5214f1b3e8SDimitry Andric bool SBExpressionOptions::GetUnwindOnError() const {
536f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
545f29bb8aSDimitry Andric 
555f29bb8aSDimitry Andric   return m_opaque_up->DoesUnwindOnError();
56f034231aSEd Maste }
57f034231aSEd Maste 
SetUnwindOnError(bool unwind)5814f1b3e8SDimitry Andric void SBExpressionOptions::SetUnwindOnError(bool unwind) {
596f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, unwind);
605f29bb8aSDimitry Andric 
615f29bb8aSDimitry Andric   m_opaque_up->SetUnwindOnError(unwind);
62f034231aSEd Maste }
63f034231aSEd Maste 
GetIgnoreBreakpoints() const6414f1b3e8SDimitry Andric bool SBExpressionOptions::GetIgnoreBreakpoints() const {
656f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
665f29bb8aSDimitry Andric 
675f29bb8aSDimitry Andric   return m_opaque_up->DoesIgnoreBreakpoints();
68f034231aSEd Maste }
69f034231aSEd Maste 
SetIgnoreBreakpoints(bool ignore)7014f1b3e8SDimitry Andric void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
716f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, ignore);
725f29bb8aSDimitry Andric 
735f29bb8aSDimitry Andric   m_opaque_up->SetIgnoreBreakpoints(ignore);
74f034231aSEd Maste }
75f034231aSEd Maste 
GetFetchDynamicValue() const7614f1b3e8SDimitry Andric lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
776f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
785f29bb8aSDimitry Andric 
795f29bb8aSDimitry Andric   return m_opaque_up->GetUseDynamic();
80f034231aSEd Maste }
81f034231aSEd Maste 
SetFetchDynamicValue(lldb::DynamicValueType dynamic)8214f1b3e8SDimitry Andric void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
836f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, dynamic);
845f29bb8aSDimitry Andric 
855f29bb8aSDimitry Andric   m_opaque_up->SetUseDynamic(dynamic);
86f034231aSEd Maste }
87f034231aSEd Maste 
GetTimeoutInMicroSeconds() const8814f1b3e8SDimitry Andric uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
896f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
905f29bb8aSDimitry Andric 
915f29bb8aSDimitry Andric   return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
92f034231aSEd Maste }
93f034231aSEd Maste 
SetTimeoutInMicroSeconds(uint32_t timeout)9414f1b3e8SDimitry Andric void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
956f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, timeout);
965f29bb8aSDimitry Andric 
97e3b55780SDimitry Andric   m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(std::nullopt)
9814f1b3e8SDimitry Andric                                        : std::chrono::microseconds(timeout));
99f034231aSEd Maste }
100f034231aSEd Maste 
GetOneThreadTimeoutInMicroSeconds() const10114f1b3e8SDimitry Andric uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
1026f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1035f29bb8aSDimitry Andric 
1045f29bb8aSDimitry Andric   return m_opaque_up->GetOneThreadTimeout()
1055f29bb8aSDimitry Andric              ? m_opaque_up->GetOneThreadTimeout()->count()
1065f29bb8aSDimitry Andric              : 0;
1070cac4ca3SEd Maste }
1080cac4ca3SEd Maste 
SetOneThreadTimeoutInMicroSeconds(uint32_t timeout)10914f1b3e8SDimitry Andric void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
1106f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, timeout);
1115f29bb8aSDimitry Andric 
1125f29bb8aSDimitry Andric   m_opaque_up->SetOneThreadTimeout(timeout == 0
113e3b55780SDimitry Andric                                        ? Timeout<std::micro>(std::nullopt)
11414f1b3e8SDimitry Andric                                        : std::chrono::microseconds(timeout));
1150cac4ca3SEd Maste }
1160cac4ca3SEd Maste 
GetTryAllThreads() const11714f1b3e8SDimitry Andric bool SBExpressionOptions::GetTryAllThreads() const {
1186f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1195f29bb8aSDimitry Andric 
1205f29bb8aSDimitry Andric   return m_opaque_up->GetTryAllThreads();
121f034231aSEd Maste }
122f034231aSEd Maste 
SetTryAllThreads(bool run_others)12314f1b3e8SDimitry Andric void SBExpressionOptions::SetTryAllThreads(bool run_others) {
1246f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, run_others);
1255f29bb8aSDimitry Andric 
1265f29bb8aSDimitry Andric   m_opaque_up->SetTryAllThreads(run_others);
12786758c71SEd Maste }
12886758c71SEd Maste 
GetStopOthers() const12914f1b3e8SDimitry Andric bool SBExpressionOptions::GetStopOthers() const {
1306f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1315f29bb8aSDimitry Andric 
1325f29bb8aSDimitry Andric   return m_opaque_up->GetStopOthers();
1330cac4ca3SEd Maste }
1340cac4ca3SEd Maste 
SetStopOthers(bool run_others)13514f1b3e8SDimitry Andric void SBExpressionOptions::SetStopOthers(bool run_others) {
1366f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, run_others);
1375f29bb8aSDimitry Andric 
1385f29bb8aSDimitry Andric   m_opaque_up->SetStopOthers(run_others);
1390cac4ca3SEd Maste }
1400cac4ca3SEd Maste 
GetTrapExceptions() const14114f1b3e8SDimitry Andric bool SBExpressionOptions::GetTrapExceptions() const {
1426f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1435f29bb8aSDimitry Andric 
1445f29bb8aSDimitry Andric   return m_opaque_up->GetTrapExceptions();
14586758c71SEd Maste }
14686758c71SEd Maste 
SetTrapExceptions(bool trap_exceptions)14714f1b3e8SDimitry Andric void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
1486f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, trap_exceptions);
1495f29bb8aSDimitry Andric 
1505f29bb8aSDimitry Andric   m_opaque_up->SetTrapExceptions(trap_exceptions);
151f034231aSEd Maste }
152f034231aSEd Maste 
SetLanguage(lldb::LanguageType language)15314f1b3e8SDimitry Andric void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
1546f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, language);
1555f29bb8aSDimitry Andric 
1565f29bb8aSDimitry Andric   m_opaque_up->SetLanguage(language);
1570cac4ca3SEd Maste }
1580cac4ca3SEd Maste 
SetLanguage(lldb::SBSourceLanguageName name,uint32_t version)159ac9a064cSDimitry Andric void SBExpressionOptions::SetLanguage(lldb::SBSourceLanguageName name,
160ac9a064cSDimitry Andric                                       uint32_t version) {
161ac9a064cSDimitry Andric   LLDB_INSTRUMENT_VA(this, name, version);
162ac9a064cSDimitry Andric 
163ac9a064cSDimitry Andric   m_opaque_up->SetLanguage(name, version);
164ac9a064cSDimitry Andric }
165ac9a064cSDimitry Andric 
SetCancelCallback(lldb::ExpressionCancelCallback callback,void * baton)16614f1b3e8SDimitry Andric void SBExpressionOptions::SetCancelCallback(
16714f1b3e8SDimitry Andric     lldb::ExpressionCancelCallback callback, void *baton) {
1686f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, callback, baton);
1695f29bb8aSDimitry Andric 
1705f29bb8aSDimitry Andric   m_opaque_up->SetCancelCallback(callback, baton);
1710cac4ca3SEd Maste }
1720cac4ca3SEd Maste 
GetGenerateDebugInfo()17314f1b3e8SDimitry Andric bool SBExpressionOptions::GetGenerateDebugInfo() {
1746f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1755f29bb8aSDimitry Andric 
1765f29bb8aSDimitry Andric   return m_opaque_up->GetGenerateDebugInfo();
1770cac4ca3SEd Maste }
1780cac4ca3SEd Maste 
SetGenerateDebugInfo(bool b)17914f1b3e8SDimitry Andric void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
1806f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, b);
1815f29bb8aSDimitry Andric 
1825f29bb8aSDimitry Andric   return m_opaque_up->SetGenerateDebugInfo(b);
1830cac4ca3SEd Maste }
1840cac4ca3SEd Maste 
GetSuppressPersistentResult()18514f1b3e8SDimitry Andric bool SBExpressionOptions::GetSuppressPersistentResult() {
1866f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1875f29bb8aSDimitry Andric 
1887fa27ce4SDimitry Andric   return m_opaque_up->GetSuppressPersistentResult();
1890cac4ca3SEd Maste }
1900cac4ca3SEd Maste 
SetSuppressPersistentResult(bool b)19114f1b3e8SDimitry Andric void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
1926f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, b);
1935f29bb8aSDimitry Andric 
1947fa27ce4SDimitry Andric   return m_opaque_up->SetSuppressPersistentResult(b);
1950cac4ca3SEd Maste }
1960cac4ca3SEd Maste 
GetPrefix() const19714f1b3e8SDimitry Andric const char *SBExpressionOptions::GetPrefix() const {
1986f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1995f29bb8aSDimitry Andric 
2007fa27ce4SDimitry Andric   return ConstString(m_opaque_up->GetPrefix()).GetCString();
2015e95aa85SEd Maste }
2025e95aa85SEd Maste 
SetPrefix(const char * prefix)20314f1b3e8SDimitry Andric void SBExpressionOptions::SetPrefix(const char *prefix) {
2046f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, prefix);
2055f29bb8aSDimitry Andric 
2065f29bb8aSDimitry Andric   return m_opaque_up->SetPrefix(prefix);
2075e95aa85SEd Maste }
2080cac4ca3SEd Maste 
GetAutoApplyFixIts()20914f1b3e8SDimitry Andric bool SBExpressionOptions::GetAutoApplyFixIts() {
2106f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2115f29bb8aSDimitry Andric 
2125f29bb8aSDimitry Andric   return m_opaque_up->GetAutoApplyFixIts();
213f3fbd1c0SDimitry Andric }
214f3fbd1c0SDimitry Andric 
SetAutoApplyFixIts(bool b)21514f1b3e8SDimitry Andric void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
2166f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, b);
2175f29bb8aSDimitry Andric 
2185f29bb8aSDimitry Andric   return m_opaque_up->SetAutoApplyFixIts(b);
219f3fbd1c0SDimitry Andric }
220f3fbd1c0SDimitry Andric 
GetRetriesWithFixIts()221cfca06d7SDimitry Andric uint64_t SBExpressionOptions::GetRetriesWithFixIts() {
2226f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
223cfca06d7SDimitry Andric 
224cfca06d7SDimitry Andric   return m_opaque_up->GetRetriesWithFixIts();
225cfca06d7SDimitry Andric }
226cfca06d7SDimitry Andric 
SetRetriesWithFixIts(uint64_t retries)227cfca06d7SDimitry Andric void SBExpressionOptions::SetRetriesWithFixIts(uint64_t retries) {
2286f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, retries);
229cfca06d7SDimitry Andric 
230cfca06d7SDimitry Andric   return m_opaque_up->SetRetriesWithFixIts(retries);
231cfca06d7SDimitry Andric }
232cfca06d7SDimitry Andric 
GetTopLevel()23314f1b3e8SDimitry Andric bool SBExpressionOptions::GetTopLevel() {
2346f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2355f29bb8aSDimitry Andric 
2365f29bb8aSDimitry Andric   return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
237f3fbd1c0SDimitry Andric }
238f3fbd1c0SDimitry Andric 
SetTopLevel(bool b)23914f1b3e8SDimitry Andric void SBExpressionOptions::SetTopLevel(bool b) {
2406f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, b);
2415f29bb8aSDimitry Andric 
2425f29bb8aSDimitry Andric   m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
2435f29bb8aSDimitry Andric                                     : m_opaque_up->default_execution_policy);
244f3fbd1c0SDimitry Andric }
245f3fbd1c0SDimitry Andric 
GetAllowJIT()24694994d37SDimitry Andric bool SBExpressionOptions::GetAllowJIT() {
2476f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2485f29bb8aSDimitry Andric 
2495f29bb8aSDimitry Andric   return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
25094994d37SDimitry Andric }
25194994d37SDimitry Andric 
SetAllowJIT(bool allow)25294994d37SDimitry Andric void SBExpressionOptions::SetAllowJIT(bool allow) {
2536f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, allow);
2545f29bb8aSDimitry Andric 
2555f29bb8aSDimitry Andric   m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
25694994d37SDimitry Andric                                         : eExecutionPolicyNever);
25794994d37SDimitry Andric }
25894994d37SDimitry Andric 
get() const25914f1b3e8SDimitry Andric EvaluateExpressionOptions *SBExpressionOptions::get() const {
2605f29bb8aSDimitry Andric   return m_opaque_up.get();
261f034231aSEd Maste }
262f034231aSEd Maste 
ref() const26314f1b3e8SDimitry Andric EvaluateExpressionOptions &SBExpressionOptions::ref() const {
264e3b55780SDimitry Andric   return *m_opaque_up;
2655f29bb8aSDimitry Andric }
266