1 //===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ValueObjectSyntheticFilter_h_
11 #define liblldb_ValueObjectSyntheticFilter_h_
13 #include "lldb/Core/ThreadSafeSTLMap.h"
14 #include "lldb/Core/ThreadSafeSTLVector.h"
15 #include "lldb/Core/ValueObject.h"
16 #include "lldb/Symbol/CompilerType.h" // for CompilerType
17 #include "lldb/Utility/ConstString.h" // for ConstString
18 #include "lldb/lldb-defines.h" // for ThreadSafeSTLMap::operator=
19 #include "lldb/lldb-enumerations.h" // for DynamicValueType, Langua...
20 #include "lldb/lldb-forward.h" // for ValueObjectSP, Synthetic...
21 #include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz...
23 #include <cstdint> // for uint32_t, uint64_t
26 #include <stddef.h> // for size_t
28 namespace lldb_private {
31 namespace lldb_private {
34 namespace lldb_private {
35 class SyntheticChildrenFrontEnd;
37 namespace lldb_private {
39 //----------------------------------------------------------------------
40 // A ValueObject that obtains its children from some source other than
42 // This is currently used to implement Python-based children and filters but
43 // you can bind it to any source of synthetic information and have it behave
45 //----------------------------------------------------------------------
46 class ValueObjectSynthetic : public ValueObject {
48 ~ValueObjectSynthetic() override;
50 uint64_t GetByteSize() override;
52 ConstString GetTypeName() override;
54 ConstString GetQualifiedTypeName() override;
56 ConstString GetDisplayTypeName() override;
58 bool MightHaveChildren() override;
60 size_t CalculateNumChildren(uint32_t max) override;
62 lldb::ValueType GetValueType() const override;
64 lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
66 lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
67 bool can_create) override;
69 size_t GetIndexOfChildWithName(const ConstString &name) override;
72 GetDynamicValue(lldb::DynamicValueType valueType) override;
74 bool IsInScope() override;
76 bool HasSyntheticValue() override { return false; }
78 bool IsSynthetic() override { return true; }
80 void CalculateSyntheticValue(bool use_synthetic) override {}
82 bool IsDynamic() override {
83 return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
86 lldb::ValueObjectSP GetStaticValue() override {
87 return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
90 virtual lldb::DynamicValueType GetDynamicValueType() {
91 return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
92 : lldb::eNoDynamicValues);
95 ValueObject *GetParent() override {
96 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
99 const ValueObject *GetParent() const override {
100 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
103 lldb::ValueObjectSP GetNonSyntheticValue() override;
105 bool CanProvideValue() override;
107 bool DoesProvideSyntheticValue() override {
108 return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
111 bool GetIsConstant() const override { return false; }
113 bool SetValueFromCString(const char *value_str, Status &error) override;
115 void SetFormat(lldb::Format format) override;
117 lldb::LanguageType GetPreferredDisplayLanguage() override;
119 void SetPreferredDisplayLanguage(lldb::LanguageType);
121 bool IsSyntheticChildrenGenerated() override;
123 void SetSyntheticChildrenGenerated(bool b) override;
125 bool GetDeclaration(Declaration &decl) override;
127 uint64_t GetLanguageFlags() override;
129 void SetLanguageFlags(uint64_t flags) override;
132 bool UpdateValue() override;
134 LazyBool CanUpdateWithInvalidExecutionContext() override {
138 CompilerType GetCompilerTypeImpl() override;
140 virtual void CreateSynthFilter();
142 // we need to hold on to the SyntheticChildren because someone might delete
143 // the type binding while we are alive
144 lldb::SyntheticChildrenSP m_synth_sp;
145 std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
147 typedef ThreadSafeSTLMap<uint32_t, ValueObject *> ByIndexMap;
148 typedef ThreadSafeSTLMap<const char *, uint32_t> NameToIndexMap;
149 typedef ThreadSafeSTLVector<lldb::ValueObjectSP> SyntheticChildrenCache;
151 typedef ByIndexMap::iterator ByIndexIterator;
152 typedef NameToIndexMap::iterator NameToIndexIterator;
154 ByIndexMap m_children_byindex;
155 NameToIndexMap m_name_toindex;
156 uint32_t m_synthetic_children_count; // FIXME use the ValueObject's
157 // ChildrenManager instead of a special
159 SyntheticChildrenCache m_synthetic_children_cache;
161 ConstString m_parent_type_name;
163 LazyBool m_might_have_children;
165 LazyBool m_provides_value;
168 friend class ValueObject;
169 ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
171 void CopyValueData(ValueObject *source);
173 DISALLOW_COPY_AND_ASSIGN(ValueObjectSynthetic);
176 } // namespace lldb_private
178 #endif // liblldb_ValueObjectSyntheticFilter_h_