xref: /src/contrib/llvm-project/lldb/source/API/SBVariablesOptions.cpp (revision 04eeddc0aa8e0a417a16eaf9d7d095207f4a8623)
1cfca06d7SDimitry Andric //===-- SBVariablesOptions.cpp --------------------------------------------===//
25e95aa85SEd 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
65e95aa85SEd Maste //
75e95aa85SEd Maste //===----------------------------------------------------------------------===//
85e95aa85SEd Maste 
95e95aa85SEd Maste #include "lldb/API/SBVariablesOptions.h"
1094994d37SDimitry Andric #include "lldb/API/SBTarget.h"
1194994d37SDimitry Andric #include "lldb/Target/Target.h"
126f8fc217SDimitry Andric #include "lldb/Utility/Instrumentation.h"
1394994d37SDimitry Andric 
1494994d37SDimitry Andric #include "lldb/lldb-private.h"
155e95aa85SEd Maste 
165e95aa85SEd Maste using namespace lldb;
175e95aa85SEd Maste using namespace lldb_private;
185e95aa85SEd Maste 
1914f1b3e8SDimitry Andric class VariablesOptionsImpl {
205e95aa85SEd Maste public:
VariablesOptionsImpl()2114f1b3e8SDimitry Andric   VariablesOptionsImpl()
2214f1b3e8SDimitry Andric       : m_include_arguments(false), m_include_locals(false),
2314f1b3e8SDimitry Andric         m_include_statics(false), m_in_scope_only(false),
24344a3780SDimitry Andric         m_include_runtime_support_values(false) {}
255e95aa85SEd Maste 
265e95aa85SEd Maste   VariablesOptionsImpl(const VariablesOptionsImpl &) = default;
275e95aa85SEd Maste 
285e95aa85SEd Maste   ~VariablesOptionsImpl() = default;
295e95aa85SEd Maste 
3014f1b3e8SDimitry Andric   VariablesOptionsImpl &operator=(const VariablesOptionsImpl &) = default;
315e95aa85SEd Maste 
GetIncludeArguments() const3214f1b3e8SDimitry Andric   bool GetIncludeArguments() const { return m_include_arguments; }
335e95aa85SEd Maste 
SetIncludeArguments(bool b)3414f1b3e8SDimitry Andric   void SetIncludeArguments(bool b) { m_include_arguments = b; }
355e95aa85SEd Maste 
GetIncludeRecognizedArguments(const lldb::TargetSP & target_sp) const3694994d37SDimitry Andric   bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const {
3794994d37SDimitry Andric     if (m_include_recognized_arguments != eLazyBoolCalculate)
3894994d37SDimitry Andric         return m_include_recognized_arguments;
3994994d37SDimitry Andric     return target_sp ? target_sp->GetDisplayRecognizedArguments() : false;
4094994d37SDimitry Andric   }
4194994d37SDimitry Andric 
SetIncludeRecognizedArguments(bool b)4294994d37SDimitry Andric   void SetIncludeRecognizedArguments(bool b) {
4394994d37SDimitry Andric     m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo;
4494994d37SDimitry Andric   }
4594994d37SDimitry Andric 
GetIncludeLocals() const4614f1b3e8SDimitry Andric   bool GetIncludeLocals() const { return m_include_locals; }
475e95aa85SEd Maste 
SetIncludeLocals(bool b)4814f1b3e8SDimitry Andric   void SetIncludeLocals(bool b) { m_include_locals = b; }
495e95aa85SEd Maste 
GetIncludeStatics() const5014f1b3e8SDimitry Andric   bool GetIncludeStatics() const { return m_include_statics; }
515e95aa85SEd Maste 
SetIncludeStatics(bool b)5214f1b3e8SDimitry Andric   void SetIncludeStatics(bool b) { m_include_statics = b; }
535e95aa85SEd Maste 
GetInScopeOnly() const5414f1b3e8SDimitry Andric   bool GetInScopeOnly() const { return m_in_scope_only; }
555e95aa85SEd Maste 
SetInScopeOnly(bool b)5614f1b3e8SDimitry Andric   void SetInScopeOnly(bool b) { m_in_scope_only = b; }
575e95aa85SEd Maste 
GetIncludeRuntimeSupportValues() const5814f1b3e8SDimitry Andric   bool GetIncludeRuntimeSupportValues() const {
595e95aa85SEd Maste     return m_include_runtime_support_values;
605e95aa85SEd Maste   }
615e95aa85SEd Maste 
SetIncludeRuntimeSupportValues(bool b)6214f1b3e8SDimitry Andric   void SetIncludeRuntimeSupportValues(bool b) {
635e95aa85SEd Maste     m_include_runtime_support_values = b;
645e95aa85SEd Maste   }
655e95aa85SEd Maste 
GetUseDynamic() const6614f1b3e8SDimitry Andric   lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; }
675e95aa85SEd Maste 
SetUseDynamic(lldb::DynamicValueType d)6814f1b3e8SDimitry Andric   void SetUseDynamic(lldb::DynamicValueType d) { m_use_dynamic = d; }
695e95aa85SEd Maste 
705e95aa85SEd Maste private:
715e95aa85SEd Maste   bool m_include_arguments : 1;
725e95aa85SEd Maste   bool m_include_locals : 1;
735e95aa85SEd Maste   bool m_include_statics : 1;
745e95aa85SEd Maste   bool m_in_scope_only : 1;
755e95aa85SEd Maste   bool m_include_runtime_support_values : 1;
76344a3780SDimitry Andric   LazyBool m_include_recognized_arguments =
77344a3780SDimitry Andric       eLazyBoolCalculate; // can be overridden with a setting
78344a3780SDimitry Andric   lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
795e95aa85SEd Maste };
805e95aa85SEd Maste 
SBVariablesOptions()8114f1b3e8SDimitry Andric SBVariablesOptions::SBVariablesOptions()
825f29bb8aSDimitry Andric     : m_opaque_up(new VariablesOptionsImpl()) {
836f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
845f29bb8aSDimitry Andric }
855e95aa85SEd Maste 
SBVariablesOptions(const SBVariablesOptions & options)8614f1b3e8SDimitry Andric SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options)
875f29bb8aSDimitry Andric     : m_opaque_up(new VariablesOptionsImpl(options.ref())) {
886f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, options);
895f29bb8aSDimitry Andric }
905e95aa85SEd Maste 
9114f1b3e8SDimitry Andric SBVariablesOptions &SBVariablesOptions::
operator =(const SBVariablesOptions & options)9214f1b3e8SDimitry Andric operator=(const SBVariablesOptions &options) {
936f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, options);
945f29bb8aSDimitry Andric 
95cfca06d7SDimitry Andric   m_opaque_up = std::make_unique<VariablesOptionsImpl>(options.ref());
966f8fc217SDimitry Andric   return *this;
975e95aa85SEd Maste }
985e95aa85SEd Maste 
995e95aa85SEd Maste SBVariablesOptions::~SBVariablesOptions() = default;
1005e95aa85SEd Maste 
IsValid() const1015f29bb8aSDimitry Andric bool SBVariablesOptions::IsValid() const {
1026f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1035f29bb8aSDimitry Andric   return this->operator bool();
1045f29bb8aSDimitry Andric }
operator bool() const1055f29bb8aSDimitry Andric SBVariablesOptions::operator bool() const {
1066f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1075f29bb8aSDimitry Andric 
1085f29bb8aSDimitry Andric   return m_opaque_up != nullptr;
1095f29bb8aSDimitry Andric }
1105e95aa85SEd Maste 
GetIncludeArguments() const11114f1b3e8SDimitry Andric bool SBVariablesOptions::GetIncludeArguments() const {
1126f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1135f29bb8aSDimitry Andric 
1145f29bb8aSDimitry Andric   return m_opaque_up->GetIncludeArguments();
1155e95aa85SEd Maste }
1165e95aa85SEd Maste 
SetIncludeArguments(bool arguments)11714f1b3e8SDimitry Andric void SBVariablesOptions::SetIncludeArguments(bool arguments) {
1186f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, arguments);
1195f29bb8aSDimitry Andric 
1205f29bb8aSDimitry Andric   m_opaque_up->SetIncludeArguments(arguments);
1215e95aa85SEd Maste }
1225e95aa85SEd Maste 
GetIncludeRecognizedArguments(const lldb::SBTarget & target) const12394994d37SDimitry Andric bool SBVariablesOptions::GetIncludeRecognizedArguments(
12494994d37SDimitry Andric     const lldb::SBTarget &target) const {
1256f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, target);
1265f29bb8aSDimitry Andric 
1275f29bb8aSDimitry Andric   return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP());
12894994d37SDimitry Andric }
12994994d37SDimitry Andric 
SetIncludeRecognizedArguments(bool arguments)13094994d37SDimitry Andric void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) {
1316f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, arguments);
1325f29bb8aSDimitry Andric 
1335f29bb8aSDimitry Andric   m_opaque_up->SetIncludeRecognizedArguments(arguments);
13494994d37SDimitry Andric }
13594994d37SDimitry Andric 
GetIncludeLocals() const13614f1b3e8SDimitry Andric bool SBVariablesOptions::GetIncludeLocals() const {
1376f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1385f29bb8aSDimitry Andric 
1395f29bb8aSDimitry Andric   return m_opaque_up->GetIncludeLocals();
1405e95aa85SEd Maste }
1415e95aa85SEd Maste 
SetIncludeLocals(bool locals)14214f1b3e8SDimitry Andric void SBVariablesOptions::SetIncludeLocals(bool locals) {
1436f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, locals);
1445f29bb8aSDimitry Andric 
1455f29bb8aSDimitry Andric   m_opaque_up->SetIncludeLocals(locals);
1465e95aa85SEd Maste }
1475e95aa85SEd Maste 
GetIncludeStatics() const14814f1b3e8SDimitry Andric bool SBVariablesOptions::GetIncludeStatics() const {
1496f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1505f29bb8aSDimitry Andric 
1515f29bb8aSDimitry Andric   return m_opaque_up->GetIncludeStatics();
1525e95aa85SEd Maste }
1535e95aa85SEd Maste 
SetIncludeStatics(bool statics)15414f1b3e8SDimitry Andric void SBVariablesOptions::SetIncludeStatics(bool statics) {
1556f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, statics);
1565f29bb8aSDimitry Andric 
1575f29bb8aSDimitry Andric   m_opaque_up->SetIncludeStatics(statics);
1585e95aa85SEd Maste }
1595e95aa85SEd Maste 
GetInScopeOnly() const16014f1b3e8SDimitry Andric bool SBVariablesOptions::GetInScopeOnly() const {
1616f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1625f29bb8aSDimitry Andric 
1635f29bb8aSDimitry Andric   return m_opaque_up->GetInScopeOnly();
1645e95aa85SEd Maste }
1655e95aa85SEd Maste 
SetInScopeOnly(bool in_scope_only)16614f1b3e8SDimitry Andric void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) {
1676f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, in_scope_only);
1685f29bb8aSDimitry Andric 
1695f29bb8aSDimitry Andric   m_opaque_up->SetInScopeOnly(in_scope_only);
1705e95aa85SEd Maste }
1715e95aa85SEd Maste 
GetIncludeRuntimeSupportValues() const17214f1b3e8SDimitry Andric bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const {
1736f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1745f29bb8aSDimitry Andric 
1755f29bb8aSDimitry Andric   return m_opaque_up->GetIncludeRuntimeSupportValues();
1765e95aa85SEd Maste }
1775e95aa85SEd Maste 
SetIncludeRuntimeSupportValues(bool runtime_support_values)17814f1b3e8SDimitry Andric void SBVariablesOptions::SetIncludeRuntimeSupportValues(
17914f1b3e8SDimitry Andric     bool runtime_support_values) {
1806f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, runtime_support_values);
1815f29bb8aSDimitry Andric 
1825f29bb8aSDimitry Andric   m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values);
1835e95aa85SEd Maste }
1845e95aa85SEd Maste 
GetUseDynamic() const18514f1b3e8SDimitry Andric lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const {
1866f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1875f29bb8aSDimitry Andric 
1885f29bb8aSDimitry Andric   return m_opaque_up->GetUseDynamic();
1895e95aa85SEd Maste }
1905e95aa85SEd Maste 
SetUseDynamic(lldb::DynamicValueType dynamic)19114f1b3e8SDimitry Andric void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) {
1926f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, dynamic);
1935f29bb8aSDimitry Andric 
1945f29bb8aSDimitry Andric   m_opaque_up->SetUseDynamic(dynamic);
1955e95aa85SEd Maste }
1965e95aa85SEd Maste 
operator ->()19714f1b3e8SDimitry Andric VariablesOptionsImpl *SBVariablesOptions::operator->() {
1985f29bb8aSDimitry Andric   return m_opaque_up.operator->();
1995e95aa85SEd Maste }
2005e95aa85SEd Maste 
operator ->() const20114f1b3e8SDimitry Andric const VariablesOptionsImpl *SBVariablesOptions::operator->() const {
2025f29bb8aSDimitry Andric   return m_opaque_up.operator->();
2035e95aa85SEd Maste }
2045e95aa85SEd Maste 
get()2055f29bb8aSDimitry Andric VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_up.get(); }
2065e95aa85SEd Maste 
ref()2075f29bb8aSDimitry Andric VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_up; }
20814f1b3e8SDimitry Andric 
ref() const20914f1b3e8SDimitry Andric const VariablesOptionsImpl &SBVariablesOptions::ref() const {
2105f29bb8aSDimitry Andric   return *m_opaque_up;
2115e95aa85SEd Maste }
2125e95aa85SEd Maste 
SBVariablesOptions(VariablesOptionsImpl * lldb_object_ptr)21314f1b3e8SDimitry Andric SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr)
2145f29bb8aSDimitry Andric     : m_opaque_up(std::move(lldb_object_ptr)) {}
2155e95aa85SEd Maste 
SetOptions(VariablesOptionsImpl * lldb_object_ptr)21614f1b3e8SDimitry Andric void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) {
2175f29bb8aSDimitry Andric   m_opaque_up.reset(std::move(lldb_object_ptr));
2185f29bb8aSDimitry Andric }
219