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_
17 // Other libraries and framework includes
19 #include "lldb/Core/ThreadSafeSTLMap.h"
20 #include "lldb/Core/ValueObject.h"
22 namespace lldb_private {
24 //----------------------------------------------------------------------
25 // A ValueObject that obtains its children from some source other than
27 // This is currently used to implement Python-based children and filters
28 // but you can bind it to any source of synthetic information and have
29 // it behave accordingly
30 //----------------------------------------------------------------------
31 class ValueObjectSynthetic : public ValueObject
34 ~ValueObjectSynthetic() override;
37 GetByteSize() override;
40 GetTypeName() override;
43 GetQualifiedTypeName() override;
46 GetDisplayTypeName() override;
49 MightHaveChildren() override;
52 CalculateNumChildren(uint32_t max) override;
55 GetValueType() const override;
58 GetChildAtIndex(size_t idx, bool can_create) override;
61 GetChildMemberWithName(const ConstString &name, bool can_create) override;
64 GetIndexOfChildWithName(const ConstString &name) override;
67 GetDynamicValue(lldb::DynamicValueType valueType) override;
73 HasSyntheticValue() override
79 IsSynthetic() override
85 CalculateSyntheticValue(bool use_synthetic) override
92 return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
96 GetStaticValue() override
98 return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
101 virtual lldb::DynamicValueType
102 GetDynamicValueType ()
104 return ((m_parent != nullptr) ? m_parent->GetDynamicValueType() : lldb::eNoDynamicValues);
110 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
114 GetParent() const override
116 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
120 GetNonSyntheticValue() override;
123 CanProvideValue() override;
126 DoesProvideSyntheticValue() override
128 return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
132 GetIsConstant() const override
138 SetValueFromCString(const char *value_str, Error& error) override;
141 SetFormat(lldb::Format format) override;
144 GetPreferredDisplayLanguage() override;
147 SetPreferredDisplayLanguage (lldb::LanguageType);
150 GetDeclaration(Declaration &decl) override;
153 GetLanguageFlags () override;
156 SetLanguageFlags (uint64_t flags) override;
160 UpdateValue() override;
163 CanUpdateWithInvalidExecutionContext() override
169 GetCompilerTypeImpl() override;
172 CreateSynthFilter ();
174 // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive
175 lldb::SyntheticChildrenSP m_synth_sp;
176 std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
178 typedef ThreadSafeSTLMap<uint32_t, ValueObject*> ByIndexMap;
179 typedef ThreadSafeSTLMap<const char*, uint32_t> NameToIndexMap;
181 typedef ByIndexMap::iterator ByIndexIterator;
182 typedef NameToIndexMap::iterator NameToIndexIterator;
184 ByIndexMap m_children_byindex;
185 NameToIndexMap m_name_toindex;
186 uint32_t m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution
188 ConstString m_parent_type_name;
190 LazyBool m_might_have_children;
192 LazyBool m_provides_value;
195 friend class ValueObject;
196 ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter);
199 CopyValueData (ValueObject *source);
201 DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic);
204 } // namespace lldb_private
206 #endif // liblldb_ValueObjectSyntheticFilter_h_