1 //===-- SBVariablesOptions.cpp --------------------------------------*- C++ 2 //-*-===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/API/SBVariablesOptions.h" 11 #include "lldb/API/SBTarget.h" 12 #include "lldb/Target/Target.h" 13 14 #include "lldb/lldb-private.h" 15 16 using namespace lldb; 17 using namespace lldb_private; 18 19 class VariablesOptionsImpl { 20 public: 21 VariablesOptionsImpl() 22 : m_include_arguments(false), m_include_locals(false), 23 m_include_statics(false), m_in_scope_only(false), 24 m_include_runtime_support_values(false), 25 m_include_recognized_arguments(eLazyBoolCalculate), 26 m_use_dynamic(lldb::eNoDynamicValues) {} 27 28 VariablesOptionsImpl(const VariablesOptionsImpl &) = default; 29 30 ~VariablesOptionsImpl() = default; 31 32 VariablesOptionsImpl &operator=(const VariablesOptionsImpl &) = default; 33 34 bool GetIncludeArguments() const { return m_include_arguments; } 35 36 void SetIncludeArguments(bool b) { m_include_arguments = b; } 37 38 bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const { 39 if (m_include_recognized_arguments != eLazyBoolCalculate) 40 return m_include_recognized_arguments; 41 return target_sp ? target_sp->GetDisplayRecognizedArguments() : false; 42 } 43 44 void SetIncludeRecognizedArguments(bool b) { 45 m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo; 46 } 47 48 bool GetIncludeLocals() const { return m_include_locals; } 49 50 void SetIncludeLocals(bool b) { m_include_locals = b; } 51 52 bool GetIncludeStatics() const { return m_include_statics; } 53 54 void SetIncludeStatics(bool b) { m_include_statics = b; } 55 56 bool GetInScopeOnly() const { return m_in_scope_only; } 57 58 void SetInScopeOnly(bool b) { m_in_scope_only = b; } 59 60 bool GetIncludeRuntimeSupportValues() const { 61 return m_include_runtime_support_values; 62 } 63 64 void SetIncludeRuntimeSupportValues(bool b) { 65 m_include_runtime_support_values = b; 66 } 67 68 lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; } 69 70 void SetUseDynamic(lldb::DynamicValueType d) { m_use_dynamic = d; } 71 72 private: 73 bool m_include_arguments : 1; 74 bool m_include_locals : 1; 75 bool m_include_statics : 1; 76 bool m_in_scope_only : 1; 77 bool m_include_runtime_support_values : 1; 78 LazyBool m_include_recognized_arguments; // can be overridden with a setting 79 lldb::DynamicValueType m_use_dynamic; 80 }; 81 82 SBVariablesOptions::SBVariablesOptions() 83 : m_opaque_up(new VariablesOptionsImpl()) {} 84 85 SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options) 86 : m_opaque_up(new VariablesOptionsImpl(options.ref())) {} 87 88 SBVariablesOptions &SBVariablesOptions:: 89 operator=(const SBVariablesOptions &options) { 90 m_opaque_up.reset(new VariablesOptionsImpl(options.ref())); 91 return *this; 92 } 93 94 SBVariablesOptions::~SBVariablesOptions() = default; 95 96 bool SBVariablesOptions::IsValid() const { return m_opaque_up != nullptr; } 97 98 bool SBVariablesOptions::GetIncludeArguments() const { 99 return m_opaque_up->GetIncludeArguments(); 100 } 101 102 void SBVariablesOptions::SetIncludeArguments(bool arguments) { 103 m_opaque_up->SetIncludeArguments(arguments); 104 } 105 106 bool SBVariablesOptions::GetIncludeRecognizedArguments( 107 const lldb::SBTarget &target) const { 108 return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP()); 109 } 110 111 void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) { 112 m_opaque_up->SetIncludeRecognizedArguments(arguments); 113 } 114 115 bool SBVariablesOptions::GetIncludeLocals() const { 116 return m_opaque_up->GetIncludeLocals(); 117 } 118 119 void SBVariablesOptions::SetIncludeLocals(bool locals) { 120 m_opaque_up->SetIncludeLocals(locals); 121 } 122 123 bool SBVariablesOptions::GetIncludeStatics() const { 124 return m_opaque_up->GetIncludeStatics(); 125 } 126 127 void SBVariablesOptions::SetIncludeStatics(bool statics) { 128 m_opaque_up->SetIncludeStatics(statics); 129 } 130 131 bool SBVariablesOptions::GetInScopeOnly() const { 132 return m_opaque_up->GetInScopeOnly(); 133 } 134 135 void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) { 136 m_opaque_up->SetInScopeOnly(in_scope_only); 137 } 138 139 bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const { 140 return m_opaque_up->GetIncludeRuntimeSupportValues(); 141 } 142 143 void SBVariablesOptions::SetIncludeRuntimeSupportValues( 144 bool runtime_support_values) { 145 m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values); 146 } 147 148 lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const { 149 return m_opaque_up->GetUseDynamic(); 150 } 151 152 void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) { 153 m_opaque_up->SetUseDynamic(dynamic); 154 } 155 156 VariablesOptionsImpl *SBVariablesOptions::operator->() { 157 return m_opaque_up.operator->(); 158 } 159 160 const VariablesOptionsImpl *SBVariablesOptions::operator->() const { 161 return m_opaque_up.operator->(); 162 } 163 164 VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_up.get(); } 165 166 VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_up; } 167 168 const VariablesOptionsImpl &SBVariablesOptions::ref() const { 169 return *m_opaque_up; 170 } 171 172 SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr) 173 : m_opaque_up(std::move(lldb_object_ptr)) {} 174 175 void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) { 176 m_opaque_up.reset(std::move(lldb_object_ptr)); 177 } 178