• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- ValueObjectDynamicValue.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_VALUEOBJECTDYNAMICVALUE_H
10 #define LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H
11 
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"
21 
22 #include <assert.h>
23 #include <stddef.h>
24 #include <stdint.h>
25 
26 namespace lldb_private {
27 class DataExtractor;
28 class Declaration;
29 class Status;
30 
31 // A ValueObject that represents memory at a given address, viewed as some
32 // set lldb type.
33 class ValueObjectDynamicValue : public ValueObject {
34 public:
35   ~ValueObjectDynamicValue() override;
36 
37   llvm::Optional<uint64_t> GetByteSize() override;
38 
39   ConstString GetTypeName() override;
40 
41   ConstString GetQualifiedTypeName() override;
42 
43   ConstString GetDisplayTypeName() override;
44 
45   size_t CalculateNumChildren(uint32_t max) override;
46 
47   lldb::ValueType GetValueType() const override;
48 
49   bool IsInScope() override;
50 
IsDynamic()51   bool IsDynamic() override { return true; }
52 
IsBaseClass()53   bool IsBaseClass() override {
54     if (m_parent)
55       return m_parent->IsBaseClass();
56     return false;
57   }
58 
GetIsConstant()59   bool GetIsConstant() const override { return false; }
60 
GetParent()61   ValueObject *GetParent() override {
62     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
63   }
64 
GetParent()65   const ValueObject *GetParent() const override {
66     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
67   }
68 
GetStaticValue()69   lldb::ValueObjectSP GetStaticValue() override { return m_parent->GetSP(); }
70 
SetOwningSP(lldb::ValueObjectSP & owning_sp)71   void SetOwningSP(lldb::ValueObjectSP &owning_sp) {
72     if (m_owning_valobj_sp == owning_sp)
73       return;
74 
75     assert(m_owning_valobj_sp.get() == nullptr);
76     m_owning_valobj_sp = owning_sp;
77   }
78 
79   bool SetValueFromCString(const char *value_str, Status &error) override;
80 
81   bool SetData(DataExtractor &data, Status &error) override;
82 
83   TypeImpl GetTypeImpl() override;
84 
GetVariable()85   lldb::VariableSP GetVariable() override {
86     return m_parent ? m_parent->GetVariable() : nullptr;
87   }
88 
89   lldb::LanguageType GetPreferredDisplayLanguage() override;
90 
91   void SetPreferredDisplayLanguage(lldb::LanguageType);
92 
93   bool IsSyntheticChildrenGenerated() override;
94 
95   void SetSyntheticChildrenGenerated(bool b) override;
96 
97   bool GetDeclaration(Declaration &decl) override;
98 
99   uint64_t GetLanguageFlags() override;
100 
101   void SetLanguageFlags(uint64_t flags) override;
102 
103 protected:
104   bool UpdateValue() override;
105 
CanUpdateWithInvalidExecutionContext()106   LazyBool CanUpdateWithInvalidExecutionContext() override {
107     return eLazyBoolYes;
108   }
109 
GetDynamicValueTypeImpl()110   lldb::DynamicValueType GetDynamicValueTypeImpl() override {
111     return m_use_dynamic;
112   }
113 
HasDynamicValueTypeInfo()114   bool HasDynamicValueTypeInfo() override { return true; }
115 
116   CompilerType GetCompilerTypeImpl() override;
117 
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;
123 
124 private:
125   friend class ValueObject;
126   friend class ValueObjectConstResult;
127   ValueObjectDynamicValue(ValueObject &parent,
128                           lldb::DynamicValueType use_dynamic);
129 
130   ValueObjectDynamicValue(const ValueObjectDynamicValue &) = delete;
131   const ValueObjectDynamicValue &
132   operator=(const ValueObjectDynamicValue &) = delete;
133 };
134 
135 } // namespace lldb_private
136 
137 #endif // LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H
138