1 //===-- ValueObjectVariable.h -----------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_CORE_VALUEOBJECTVARIABLE_H 10 #define LLDB_CORE_VALUEOBJECTVARIABLE_H 11 12 #include "lldb/Core/ValueObject.h" 13 14 #include "lldb/Core/Value.h" 15 #include "lldb/Symbol/CompilerType.h" 16 #include "lldb/Utility/ConstString.h" 17 #include "lldb/lldb-defines.h" 18 #include "lldb/lldb-enumerations.h" 19 #include "lldb/lldb-forward.h" 20 21 #include <cstddef> 22 #include <cstdint> 23 #include <optional> 24 25 namespace lldb_private { 26 class DataExtractor; 27 class Declaration; 28 class Status; 29 class ExecutionContextScope; 30 class SymbolContextScope; 31 32 /// A ValueObject that contains a root variable that may or may not 33 /// have children. 34 class ValueObjectVariable : public ValueObject { 35 public: 36 ~ValueObjectVariable() override; 37 38 static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, 39 const lldb::VariableSP &var_sp); 40 41 std::optional<uint64_t> GetByteSize() override; 42 43 ConstString GetTypeName() override; 44 45 ConstString GetQualifiedTypeName() override; 46 47 ConstString GetDisplayTypeName() override; 48 49 size_t CalculateNumChildren(uint32_t max) override; 50 51 lldb::ValueType GetValueType() const override; 52 53 bool IsInScope() override; 54 55 lldb::ModuleSP GetModule() override; 56 57 SymbolContextScope *GetSymbolContextScope() override; 58 59 bool GetDeclaration(Declaration &decl) override; 60 61 const char *GetLocationAsCString() override; 62 63 bool SetValueFromCString(const char *value_str, Status &error) override; 64 65 bool SetData(DataExtractor &data, Status &error) override; 66 GetVariable()67 lldb::VariableSP GetVariable() override { return m_variable_sp; } 68 69 protected: 70 bool UpdateValue() override; 71 72 void DoUpdateChildrenAddressType(ValueObject &valobj) override; 73 74 CompilerType GetCompilerTypeImpl() override; 75 76 /// The variable that this value object is based upon. 77 lldb::VariableSP m_variable_sp; 78 ///< The value that DWARFExpression resolves this variable to before we patch 79 ///< it up. 80 Value m_resolved_value; 81 82 private: 83 ValueObjectVariable(ExecutionContextScope *exe_scope, 84 ValueObjectManager &manager, 85 const lldb::VariableSP &var_sp); 86 // For ValueObject only 87 ValueObjectVariable(const ValueObjectVariable &) = delete; 88 const ValueObjectVariable &operator=(const ValueObjectVariable &) = delete; 89 }; 90 91 } // namespace lldb_private 92 93 #endif // LLDB_CORE_VALUEOBJECTVARIABLE_H 94