1 //===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H
10 #define LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H
12 #include "lldb/Core/Address.h"
13 #include "lldb/Core/ValueObject.h"
14 #include "lldb/Symbol/CompilerType.h"
15 #include "lldb/Symbol/Type.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 #include "lldb/lldb-private-enumerations.h"
26 namespace lldb_private {
31 // A ValueObject that represents memory at a given address, viewed as some
33 class ValueObjectDynamicValue : public ValueObject {
35 ~ValueObjectDynamicValue() override;
37 uint64_t GetByteSize() override;
39 ConstString GetTypeName() override;
41 ConstString GetQualifiedTypeName() override;
43 ConstString GetDisplayTypeName() override;
45 size_t CalculateNumChildren(uint32_t max) override;
47 lldb::ValueType GetValueType() const override;
49 bool IsInScope() override;
51 bool IsDynamic() override { return true; }
53 bool IsBaseClass() override {
55 return m_parent->IsBaseClass();
59 bool GetIsConstant() const override { return false; }
61 ValueObject *GetParent() override {
62 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
65 const ValueObject *GetParent() const override {
66 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
69 lldb::ValueObjectSP GetStaticValue() override { return m_parent->GetSP(); }
71 void SetOwningSP(lldb::ValueObjectSP &owning_sp) {
72 if (m_owning_valobj_sp == owning_sp)
75 assert(m_owning_valobj_sp.get() == nullptr);
76 m_owning_valobj_sp = owning_sp;
79 bool SetValueFromCString(const char *value_str, Status &error) override;
81 bool SetData(DataExtractor &data, Status &error) override;
83 TypeImpl GetTypeImpl() override;
85 lldb::VariableSP GetVariable() override {
86 return m_parent ? m_parent->GetVariable() : nullptr;
89 lldb::LanguageType GetPreferredDisplayLanguage() override;
91 void SetPreferredDisplayLanguage(lldb::LanguageType);
93 bool IsSyntheticChildrenGenerated() override;
95 void SetSyntheticChildrenGenerated(bool b) override;
97 bool GetDeclaration(Declaration &decl) override;
99 uint64_t GetLanguageFlags() override;
101 void SetLanguageFlags(uint64_t flags) override;
104 bool UpdateValue() override;
106 LazyBool CanUpdateWithInvalidExecutionContext() override {
110 lldb::DynamicValueType GetDynamicValueTypeImpl() override {
111 return m_use_dynamic;
114 bool HasDynamicValueTypeInfo() override { return true; }
116 CompilerType GetCompilerTypeImpl() override;
118 Address m_address; ///< The variable that this value object is based upon
119 TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name
120 lldb::ValueObjectSP m_owning_valobj_sp;
121 lldb::DynamicValueType m_use_dynamic;
122 TypeImpl m_type_impl;
125 friend class ValueObject;
126 friend class ValueObjectConstResult;
127 ValueObjectDynamicValue(ValueObject &parent,
128 lldb::DynamicValueType use_dynamic);
130 ValueObjectDynamicValue(const ValueObjectDynamicValue &) = delete;
131 const ValueObjectDynamicValue &
132 operator=(const ValueObjectDynamicValue &) = delete;
135 } // namespace lldb_private
137 #endif // LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H