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 "SBReproducerPrivate.h" 12 #include "lldb/API/SBTarget.h" 13 #include "lldb/Target/Target.h" 14 15 #include "lldb/lldb-private.h" 16 17 using namespace lldb; 18 using namespace lldb_private; 19 20 class VariablesOptionsImpl { 21 public: 22 VariablesOptionsImpl() 23 : m_include_arguments(false), m_include_locals(false), 24 m_include_statics(false), m_in_scope_only(false), 25 m_include_runtime_support_values(false), 26 m_include_recognized_arguments(eLazyBoolCalculate), 27 m_use_dynamic(lldb::eNoDynamicValues) {} 28 29 VariablesOptionsImpl(const VariablesOptionsImpl &) = default; 30 31 ~VariablesOptionsImpl() = default; 32 33 VariablesOptionsImpl &operator=(const VariablesOptionsImpl &) = default; 34 35 bool GetIncludeArguments() const { return m_include_arguments; } 36 37 void SetIncludeArguments(bool b) { m_include_arguments = b; } 38 39 bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const { 40 if (m_include_recognized_arguments != eLazyBoolCalculate) 41 return m_include_recognized_arguments; 42 return target_sp ? target_sp->GetDisplayRecognizedArguments() : false; 43 } 44 45 void SetIncludeRecognizedArguments(bool b) { 46 m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo; 47 } 48 49 bool GetIncludeLocals() const { return m_include_locals; } 50 51 void SetIncludeLocals(bool b) { m_include_locals = b; } 52 53 bool GetIncludeStatics() const { return m_include_statics; } 54 55 void SetIncludeStatics(bool b) { m_include_statics = b; } 56 57 bool GetInScopeOnly() const { return m_in_scope_only; } 58 59 void SetInScopeOnly(bool b) { m_in_scope_only = b; } 60 61 bool GetIncludeRuntimeSupportValues() const { 62 return m_include_runtime_support_values; 63 } 64 65 void SetIncludeRuntimeSupportValues(bool b) { 66 m_include_runtime_support_values = b; 67 } 68 69 lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; } 70 71 void SetUseDynamic(lldb::DynamicValueType d) { m_use_dynamic = d; } 72 73 private: 74 bool m_include_arguments : 1; 75 bool m_include_locals : 1; 76 bool m_include_statics : 1; 77 bool m_in_scope_only : 1; 78 bool m_include_runtime_support_values : 1; 79 LazyBool m_include_recognized_arguments; // can be overridden with a setting 80 lldb::DynamicValueType m_use_dynamic; 81 }; 82 83 SBVariablesOptions::SBVariablesOptions() 84 : m_opaque_up(new VariablesOptionsImpl()) { 85 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBVariablesOptions); 86 } 87 88 SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options) 89 : m_opaque_up(new VariablesOptionsImpl(options.ref())) { 90 LLDB_RECORD_CONSTRUCTOR(SBVariablesOptions, 91 (const lldb::SBVariablesOptions &), options); 92 } 93 94 SBVariablesOptions &SBVariablesOptions:: 95 operator=(const SBVariablesOptions &options) { 96 LLDB_RECORD_METHOD( 97 lldb::SBVariablesOptions &, 98 SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &), 99 options); 100 101 m_opaque_up.reset(new VariablesOptionsImpl(options.ref())); 102 return *this; 103 } 104 105 SBVariablesOptions::~SBVariablesOptions() = default; 106 107 bool SBVariablesOptions::IsValid() const { 108 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, IsValid); 109 110 return m_opaque_up != nullptr; 111 } 112 113 bool SBVariablesOptions::GetIncludeArguments() const { 114 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, 115 GetIncludeArguments); 116 117 return m_opaque_up->GetIncludeArguments(); 118 } 119 120 void SBVariablesOptions::SetIncludeArguments(bool arguments) { 121 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool), 122 arguments); 123 124 m_opaque_up->SetIncludeArguments(arguments); 125 } 126 127 bool SBVariablesOptions::GetIncludeRecognizedArguments( 128 const lldb::SBTarget &target) const { 129 LLDB_RECORD_METHOD_CONST(bool, SBVariablesOptions, 130 GetIncludeRecognizedArguments, 131 (const lldb::SBTarget &), target); 132 133 return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP()); 134 } 135 136 void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) { 137 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRecognizedArguments, 138 (bool), arguments); 139 140 m_opaque_up->SetIncludeRecognizedArguments(arguments); 141 } 142 143 bool SBVariablesOptions::GetIncludeLocals() const { 144 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeLocals); 145 146 return m_opaque_up->GetIncludeLocals(); 147 } 148 149 void SBVariablesOptions::SetIncludeLocals(bool locals) { 150 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool), 151 locals); 152 153 m_opaque_up->SetIncludeLocals(locals); 154 } 155 156 bool SBVariablesOptions::GetIncludeStatics() const { 157 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeStatics); 158 159 return m_opaque_up->GetIncludeStatics(); 160 } 161 162 void SBVariablesOptions::SetIncludeStatics(bool statics) { 163 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool), 164 statics); 165 166 m_opaque_up->SetIncludeStatics(statics); 167 } 168 169 bool SBVariablesOptions::GetInScopeOnly() const { 170 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetInScopeOnly); 171 172 return m_opaque_up->GetInScopeOnly(); 173 } 174 175 void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) { 176 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool), 177 in_scope_only); 178 179 m_opaque_up->SetInScopeOnly(in_scope_only); 180 } 181 182 bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const { 183 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, 184 GetIncludeRuntimeSupportValues); 185 186 return m_opaque_up->GetIncludeRuntimeSupportValues(); 187 } 188 189 void SBVariablesOptions::SetIncludeRuntimeSupportValues( 190 bool runtime_support_values) { 191 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRuntimeSupportValues, 192 (bool), runtime_support_values); 193 194 m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values); 195 } 196 197 lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const { 198 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBVariablesOptions, 199 GetUseDynamic); 200 201 return m_opaque_up->GetUseDynamic(); 202 } 203 204 void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) { 205 LLDB_RECORD_METHOD(void, SBVariablesOptions, SetUseDynamic, 206 (lldb::DynamicValueType), dynamic); 207 208 m_opaque_up->SetUseDynamic(dynamic); 209 } 210 211 VariablesOptionsImpl *SBVariablesOptions::operator->() { 212 return m_opaque_up.operator->(); 213 } 214 215 const VariablesOptionsImpl *SBVariablesOptions::operator->() const { 216 return m_opaque_up.operator->(); 217 } 218 219 VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_up.get(); } 220 221 VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_up; } 222 223 const VariablesOptionsImpl &SBVariablesOptions::ref() const { 224 return *m_opaque_up; 225 } 226 227 SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr) 228 : m_opaque_up(std::move(lldb_object_ptr)) {} 229 230 void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) { 231 m_opaque_up.reset(std::move(lldb_object_ptr)); 232 } 233