15ffd83dbSDimitry Andric //===-- SBVariablesOptions.cpp --------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric
90b57cec5SDimitry Andric #include "lldb/API/SBVariablesOptions.h"
100b57cec5SDimitry Andric #include "SBReproducerPrivate.h"
110b57cec5SDimitry Andric #include "lldb/API/SBTarget.h"
120b57cec5SDimitry Andric #include "lldb/Target/Target.h"
130b57cec5SDimitry Andric
140b57cec5SDimitry Andric #include "lldb/lldb-private.h"
150b57cec5SDimitry Andric
160b57cec5SDimitry Andric using namespace lldb;
170b57cec5SDimitry Andric using namespace lldb_private;
180b57cec5SDimitry Andric
190b57cec5SDimitry Andric class VariablesOptionsImpl {
200b57cec5SDimitry Andric public:
VariablesOptionsImpl()210b57cec5SDimitry Andric VariablesOptionsImpl()
220b57cec5SDimitry Andric : m_include_arguments(false), m_include_locals(false),
230b57cec5SDimitry Andric m_include_statics(false), m_in_scope_only(false),
24*5f7ddb14SDimitry Andric m_include_runtime_support_values(false) {}
250b57cec5SDimitry Andric
260b57cec5SDimitry Andric VariablesOptionsImpl(const VariablesOptionsImpl &) = default;
270b57cec5SDimitry Andric
280b57cec5SDimitry Andric ~VariablesOptionsImpl() = default;
290b57cec5SDimitry Andric
300b57cec5SDimitry Andric VariablesOptionsImpl &operator=(const VariablesOptionsImpl &) = default;
310b57cec5SDimitry Andric
GetIncludeArguments() const320b57cec5SDimitry Andric bool GetIncludeArguments() const { return m_include_arguments; }
330b57cec5SDimitry Andric
SetIncludeArguments(bool b)340b57cec5SDimitry Andric void SetIncludeArguments(bool b) { m_include_arguments = b; }
350b57cec5SDimitry Andric
GetIncludeRecognizedArguments(const lldb::TargetSP & target_sp) const360b57cec5SDimitry Andric bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const {
370b57cec5SDimitry Andric if (m_include_recognized_arguments != eLazyBoolCalculate)
380b57cec5SDimitry Andric return m_include_recognized_arguments;
390b57cec5SDimitry Andric return target_sp ? target_sp->GetDisplayRecognizedArguments() : false;
400b57cec5SDimitry Andric }
410b57cec5SDimitry Andric
SetIncludeRecognizedArguments(bool b)420b57cec5SDimitry Andric void SetIncludeRecognizedArguments(bool b) {
430b57cec5SDimitry Andric m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo;
440b57cec5SDimitry Andric }
450b57cec5SDimitry Andric
GetIncludeLocals() const460b57cec5SDimitry Andric bool GetIncludeLocals() const { return m_include_locals; }
470b57cec5SDimitry Andric
SetIncludeLocals(bool b)480b57cec5SDimitry Andric void SetIncludeLocals(bool b) { m_include_locals = b; }
490b57cec5SDimitry Andric
GetIncludeStatics() const500b57cec5SDimitry Andric bool GetIncludeStatics() const { return m_include_statics; }
510b57cec5SDimitry Andric
SetIncludeStatics(bool b)520b57cec5SDimitry Andric void SetIncludeStatics(bool b) { m_include_statics = b; }
530b57cec5SDimitry Andric
GetInScopeOnly() const540b57cec5SDimitry Andric bool GetInScopeOnly() const { return m_in_scope_only; }
550b57cec5SDimitry Andric
SetInScopeOnly(bool b)560b57cec5SDimitry Andric void SetInScopeOnly(bool b) { m_in_scope_only = b; }
570b57cec5SDimitry Andric
GetIncludeRuntimeSupportValues() const580b57cec5SDimitry Andric bool GetIncludeRuntimeSupportValues() const {
590b57cec5SDimitry Andric return m_include_runtime_support_values;
600b57cec5SDimitry Andric }
610b57cec5SDimitry Andric
SetIncludeRuntimeSupportValues(bool b)620b57cec5SDimitry Andric void SetIncludeRuntimeSupportValues(bool b) {
630b57cec5SDimitry Andric m_include_runtime_support_values = b;
640b57cec5SDimitry Andric }
650b57cec5SDimitry Andric
GetUseDynamic() const660b57cec5SDimitry Andric lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; }
670b57cec5SDimitry Andric
SetUseDynamic(lldb::DynamicValueType d)680b57cec5SDimitry Andric void SetUseDynamic(lldb::DynamicValueType d) { m_use_dynamic = d; }
690b57cec5SDimitry Andric
700b57cec5SDimitry Andric private:
710b57cec5SDimitry Andric bool m_include_arguments : 1;
720b57cec5SDimitry Andric bool m_include_locals : 1;
730b57cec5SDimitry Andric bool m_include_statics : 1;
740b57cec5SDimitry Andric bool m_in_scope_only : 1;
750b57cec5SDimitry Andric bool m_include_runtime_support_values : 1;
76*5f7ddb14SDimitry Andric LazyBool m_include_recognized_arguments =
77*5f7ddb14SDimitry Andric eLazyBoolCalculate; // can be overridden with a setting
78*5f7ddb14SDimitry Andric lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
790b57cec5SDimitry Andric };
800b57cec5SDimitry Andric
SBVariablesOptions()810b57cec5SDimitry Andric SBVariablesOptions::SBVariablesOptions()
820b57cec5SDimitry Andric : m_opaque_up(new VariablesOptionsImpl()) {
830b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBVariablesOptions);
840b57cec5SDimitry Andric }
850b57cec5SDimitry Andric
SBVariablesOptions(const SBVariablesOptions & options)860b57cec5SDimitry Andric SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options)
870b57cec5SDimitry Andric : m_opaque_up(new VariablesOptionsImpl(options.ref())) {
880b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR(SBVariablesOptions,
890b57cec5SDimitry Andric (const lldb::SBVariablesOptions &), options);
900b57cec5SDimitry Andric }
910b57cec5SDimitry Andric
920b57cec5SDimitry Andric SBVariablesOptions &SBVariablesOptions::
operator =(const SBVariablesOptions & options)930b57cec5SDimitry Andric operator=(const SBVariablesOptions &options) {
940b57cec5SDimitry Andric LLDB_RECORD_METHOD(
950b57cec5SDimitry Andric lldb::SBVariablesOptions &,
960b57cec5SDimitry Andric SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &),
970b57cec5SDimitry Andric options);
980b57cec5SDimitry Andric
995ffd83dbSDimitry Andric m_opaque_up = std::make_unique<VariablesOptionsImpl>(options.ref());
1000b57cec5SDimitry Andric return LLDB_RECORD_RESULT(*this);
1010b57cec5SDimitry Andric }
1020b57cec5SDimitry Andric
1030b57cec5SDimitry Andric SBVariablesOptions::~SBVariablesOptions() = default;
1040b57cec5SDimitry Andric
IsValid() const1050b57cec5SDimitry Andric bool SBVariablesOptions::IsValid() const {
1060b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, IsValid);
1070b57cec5SDimitry Andric return this->operator bool();
1080b57cec5SDimitry Andric }
operator bool() const1090b57cec5SDimitry Andric SBVariablesOptions::operator bool() const {
1100b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, operator bool);
1110b57cec5SDimitry Andric
1120b57cec5SDimitry Andric return m_opaque_up != nullptr;
1130b57cec5SDimitry Andric }
1140b57cec5SDimitry Andric
GetIncludeArguments() const1150b57cec5SDimitry Andric bool SBVariablesOptions::GetIncludeArguments() const {
1160b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions,
1170b57cec5SDimitry Andric GetIncludeArguments);
1180b57cec5SDimitry Andric
1190b57cec5SDimitry Andric return m_opaque_up->GetIncludeArguments();
1200b57cec5SDimitry Andric }
1210b57cec5SDimitry Andric
SetIncludeArguments(bool arguments)1220b57cec5SDimitry Andric void SBVariablesOptions::SetIncludeArguments(bool arguments) {
1230b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool),
1240b57cec5SDimitry Andric arguments);
1250b57cec5SDimitry Andric
1260b57cec5SDimitry Andric m_opaque_up->SetIncludeArguments(arguments);
1270b57cec5SDimitry Andric }
1280b57cec5SDimitry Andric
GetIncludeRecognizedArguments(const lldb::SBTarget & target) const1290b57cec5SDimitry Andric bool SBVariablesOptions::GetIncludeRecognizedArguments(
1300b57cec5SDimitry Andric const lldb::SBTarget &target) const {
1310b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST(bool, SBVariablesOptions,
1320b57cec5SDimitry Andric GetIncludeRecognizedArguments,
1330b57cec5SDimitry Andric (const lldb::SBTarget &), target);
1340b57cec5SDimitry Andric
1350b57cec5SDimitry Andric return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP());
1360b57cec5SDimitry Andric }
1370b57cec5SDimitry Andric
SetIncludeRecognizedArguments(bool arguments)1380b57cec5SDimitry Andric void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) {
1390b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRecognizedArguments,
1400b57cec5SDimitry Andric (bool), arguments);
1410b57cec5SDimitry Andric
1420b57cec5SDimitry Andric m_opaque_up->SetIncludeRecognizedArguments(arguments);
1430b57cec5SDimitry Andric }
1440b57cec5SDimitry Andric
GetIncludeLocals() const1450b57cec5SDimitry Andric bool SBVariablesOptions::GetIncludeLocals() const {
1460b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeLocals);
1470b57cec5SDimitry Andric
1480b57cec5SDimitry Andric return m_opaque_up->GetIncludeLocals();
1490b57cec5SDimitry Andric }
1500b57cec5SDimitry Andric
SetIncludeLocals(bool locals)1510b57cec5SDimitry Andric void SBVariablesOptions::SetIncludeLocals(bool locals) {
1520b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool),
1530b57cec5SDimitry Andric locals);
1540b57cec5SDimitry Andric
1550b57cec5SDimitry Andric m_opaque_up->SetIncludeLocals(locals);
1560b57cec5SDimitry Andric }
1570b57cec5SDimitry Andric
GetIncludeStatics() const1580b57cec5SDimitry Andric bool SBVariablesOptions::GetIncludeStatics() const {
1590b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeStatics);
1600b57cec5SDimitry Andric
1610b57cec5SDimitry Andric return m_opaque_up->GetIncludeStatics();
1620b57cec5SDimitry Andric }
1630b57cec5SDimitry Andric
SetIncludeStatics(bool statics)1640b57cec5SDimitry Andric void SBVariablesOptions::SetIncludeStatics(bool statics) {
1650b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool),
1660b57cec5SDimitry Andric statics);
1670b57cec5SDimitry Andric
1680b57cec5SDimitry Andric m_opaque_up->SetIncludeStatics(statics);
1690b57cec5SDimitry Andric }
1700b57cec5SDimitry Andric
GetInScopeOnly() const1710b57cec5SDimitry Andric bool SBVariablesOptions::GetInScopeOnly() const {
1720b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetInScopeOnly);
1730b57cec5SDimitry Andric
1740b57cec5SDimitry Andric return m_opaque_up->GetInScopeOnly();
1750b57cec5SDimitry Andric }
1760b57cec5SDimitry Andric
SetInScopeOnly(bool in_scope_only)1770b57cec5SDimitry Andric void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) {
1780b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool),
1790b57cec5SDimitry Andric in_scope_only);
1800b57cec5SDimitry Andric
1810b57cec5SDimitry Andric m_opaque_up->SetInScopeOnly(in_scope_only);
1820b57cec5SDimitry Andric }
1830b57cec5SDimitry Andric
GetIncludeRuntimeSupportValues() const1840b57cec5SDimitry Andric bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const {
1850b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions,
1860b57cec5SDimitry Andric GetIncludeRuntimeSupportValues);
1870b57cec5SDimitry Andric
1880b57cec5SDimitry Andric return m_opaque_up->GetIncludeRuntimeSupportValues();
1890b57cec5SDimitry Andric }
1900b57cec5SDimitry Andric
SetIncludeRuntimeSupportValues(bool runtime_support_values)1910b57cec5SDimitry Andric void SBVariablesOptions::SetIncludeRuntimeSupportValues(
1920b57cec5SDimitry Andric bool runtime_support_values) {
1930b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRuntimeSupportValues,
1940b57cec5SDimitry Andric (bool), runtime_support_values);
1950b57cec5SDimitry Andric
1960b57cec5SDimitry Andric m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values);
1970b57cec5SDimitry Andric }
1980b57cec5SDimitry Andric
GetUseDynamic() const1990b57cec5SDimitry Andric lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const {
2000b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBVariablesOptions,
2010b57cec5SDimitry Andric GetUseDynamic);
2020b57cec5SDimitry Andric
2030b57cec5SDimitry Andric return m_opaque_up->GetUseDynamic();
2040b57cec5SDimitry Andric }
2050b57cec5SDimitry Andric
SetUseDynamic(lldb::DynamicValueType dynamic)2060b57cec5SDimitry Andric void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) {
2070b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBVariablesOptions, SetUseDynamic,
2080b57cec5SDimitry Andric (lldb::DynamicValueType), dynamic);
2090b57cec5SDimitry Andric
2100b57cec5SDimitry Andric m_opaque_up->SetUseDynamic(dynamic);
2110b57cec5SDimitry Andric }
2120b57cec5SDimitry Andric
operator ->()2130b57cec5SDimitry Andric VariablesOptionsImpl *SBVariablesOptions::operator->() {
2140b57cec5SDimitry Andric return m_opaque_up.operator->();
2150b57cec5SDimitry Andric }
2160b57cec5SDimitry Andric
operator ->() const2170b57cec5SDimitry Andric const VariablesOptionsImpl *SBVariablesOptions::operator->() const {
2180b57cec5SDimitry Andric return m_opaque_up.operator->();
2190b57cec5SDimitry Andric }
2200b57cec5SDimitry Andric
get()2210b57cec5SDimitry Andric VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_up.get(); }
2220b57cec5SDimitry Andric
ref()2230b57cec5SDimitry Andric VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_up; }
2240b57cec5SDimitry Andric
ref() const2250b57cec5SDimitry Andric const VariablesOptionsImpl &SBVariablesOptions::ref() const {
2260b57cec5SDimitry Andric return *m_opaque_up;
2270b57cec5SDimitry Andric }
2280b57cec5SDimitry Andric
SBVariablesOptions(VariablesOptionsImpl * lldb_object_ptr)2290b57cec5SDimitry Andric SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr)
2300b57cec5SDimitry Andric : m_opaque_up(std::move(lldb_object_ptr)) {}
2310b57cec5SDimitry Andric
SetOptions(VariablesOptionsImpl * lldb_object_ptr)2320b57cec5SDimitry Andric void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) {
2330b57cec5SDimitry Andric m_opaque_up.reset(std::move(lldb_object_ptr));
2340b57cec5SDimitry Andric }
2350b57cec5SDimitry Andric
2360b57cec5SDimitry Andric namespace lldb_private {
2370b57cec5SDimitry Andric namespace repro {
2380b57cec5SDimitry Andric
2390b57cec5SDimitry Andric template <>
RegisterMethods(Registry & R)2400b57cec5SDimitry Andric void RegisterMethods<SBVariablesOptions>(Registry &R) {
2410b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions, ());
2420b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions,
2430b57cec5SDimitry Andric (const lldb::SBVariablesOptions &));
2440b57cec5SDimitry Andric LLDB_REGISTER_METHOD(
2450b57cec5SDimitry Andric lldb::SBVariablesOptions &,
2460b57cec5SDimitry Andric SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &));
2470b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, IsValid, ());
2480b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, operator bool, ());
2490b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeArguments,
2500b57cec5SDimitry Andric ());
2510b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool));
2520b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions,
2530b57cec5SDimitry Andric GetIncludeRecognizedArguments,
2540b57cec5SDimitry Andric (const lldb::SBTarget &));
2550b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBVariablesOptions,
2560b57cec5SDimitry Andric SetIncludeRecognizedArguments, (bool));
2570b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeLocals, ());
2580b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool));
2590b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeStatics, ());
2600b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool));
2610b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetInScopeOnly, ());
2620b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool));
2630b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions,
2640b57cec5SDimitry Andric GetIncludeRuntimeSupportValues, ());
2650b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBVariablesOptions,
2660b57cec5SDimitry Andric SetIncludeRuntimeSupportValues, (bool));
2670b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBVariablesOptions,
2680b57cec5SDimitry Andric GetUseDynamic, ());
2690b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetUseDynamic,
2700b57cec5SDimitry Andric (lldb::DynamicValueType));
2710b57cec5SDimitry Andric }
2720b57cec5SDimitry Andric
2730b57cec5SDimitry Andric }
2740b57cec5SDimitry Andric }
275