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 <stddef.h> 22 #include <stdint.h> 23 24 namespace lldb_private { 25 class DataExtractor; 26 class Declaration; 27 class Status; 28 class ExecutionContextScope; 29 class SymbolContextScope; 30 31 // A ValueObject that contains a root variable that may or may not 32 // have children. 33 class ValueObjectVariable : public ValueObject { 34 public: 35 ~ValueObjectVariable() override; 36 37 static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, 38 const lldb::VariableSP &var_sp); 39 40 llvm::Optional<uint64_t> GetByteSize() override; 41 42 ConstString GetTypeName() override; 43 44 ConstString GetQualifiedTypeName() override; 45 46 ConstString GetDisplayTypeName() override; 47 48 size_t CalculateNumChildren(uint32_t max) override; 49 50 lldb::ValueType GetValueType() const override; 51 52 bool IsInScope() override; 53 54 lldb::ModuleSP GetModule() override; 55 56 SymbolContextScope *GetSymbolContextScope() override; 57 58 bool GetDeclaration(Declaration &decl) override; 59 60 const char *GetLocationAsCString() override; 61 62 bool SetValueFromCString(const char *value_str, Status &error) override; 63 64 bool SetData(DataExtractor &data, Status &error) override; 65 GetVariable()66 lldb::VariableSP GetVariable() override { return m_variable_sp; } 67 68 protected: 69 bool UpdateValue() override; 70 71 void DoUpdateChildrenAddressType(ValueObject &valobj) override; 72 73 CompilerType GetCompilerTypeImpl() override; 74 75 lldb::VariableSP 76 m_variable_sp; ///< The variable that this value object is based upon 77 Value m_resolved_value; ///< The value that DWARFExpression resolves this 78 ///variable to before we patch it up 79 80 private: 81 ValueObjectVariable(ExecutionContextScope *exe_scope, 82 ValueObjectManager &manager, 83 const lldb::VariableSP &var_sp); 84 // For ValueObject only 85 ValueObjectVariable(const ValueObjectVariable &) = delete; 86 const ValueObjectVariable &operator=(const ValueObjectVariable &) = delete; 87 }; 88 89 } // namespace lldb_private 90 91 #endif // LLDB_CORE_VALUEOBJECTVARIABLE_H 92