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/ThreadSafeSTLVector.h"
21 #include "lldb/Core/ValueObject.h"
23 namespace lldb_private {
25 //----------------------------------------------------------------------
26 // A ValueObject that obtains its children from some source other than
28 // This is currently used to implement Python-based children and filters
29 // but you can bind it to any source of synthetic information and have
30 // it behave accordingly
31 //----------------------------------------------------------------------
32 class ValueObjectSynthetic : public ValueObject {
34 ~ValueObjectSynthetic() override;
36 uint64_t GetByteSize() override;
38 ConstString GetTypeName() override;
40 ConstString GetQualifiedTypeName() override;
42 ConstString GetDisplayTypeName() override;
44 bool MightHaveChildren() override;
46 size_t CalculateNumChildren(uint32_t max) override;
48 lldb::ValueType GetValueType() const override;
50 lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
52 lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
53 bool can_create) override;
55 size_t GetIndexOfChildWithName(const ConstString &name) override;
58 GetDynamicValue(lldb::DynamicValueType valueType) override;
60 bool IsInScope() override;
62 bool HasSyntheticValue() override { return false; }
64 bool IsSynthetic() override { return true; }
66 void CalculateSyntheticValue(bool use_synthetic) override {}
68 bool IsDynamic() override {
69 return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
72 lldb::ValueObjectSP GetStaticValue() override {
73 return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
76 virtual lldb::DynamicValueType GetDynamicValueType() {
77 return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
78 : lldb::eNoDynamicValues);
81 ValueObject *GetParent() override {
82 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
85 const ValueObject *GetParent() const override {
86 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
89 lldb::ValueObjectSP GetNonSyntheticValue() override;
91 bool CanProvideValue() override;
93 bool DoesProvideSyntheticValue() override {
94 return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
97 bool GetIsConstant() const override { return false; }
99 bool SetValueFromCString(const char *value_str, Error &error) override;
101 void SetFormat(lldb::Format format) override;
103 lldb::LanguageType GetPreferredDisplayLanguage() override;
105 void SetPreferredDisplayLanguage(lldb::LanguageType);
107 bool IsSyntheticChildrenGenerated() override;
109 void SetSyntheticChildrenGenerated(bool b) override;
111 bool GetDeclaration(Declaration &decl) override;
113 uint64_t GetLanguageFlags() override;
115 void SetLanguageFlags(uint64_t flags) override;
118 bool UpdateValue() override;
120 LazyBool CanUpdateWithInvalidExecutionContext() override {
124 CompilerType GetCompilerTypeImpl() override;
126 virtual void CreateSynthFilter();
128 // we need to hold on to the SyntheticChildren because someone might delete
129 // the type binding while we are alive
130 lldb::SyntheticChildrenSP m_synth_sp;
131 std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
133 typedef ThreadSafeSTLMap<uint32_t, ValueObject *> ByIndexMap;
134 typedef ThreadSafeSTLMap<const char *, uint32_t> NameToIndexMap;
135 typedef ThreadSafeSTLVector<lldb::ValueObjectSP> SyntheticChildrenCache;
137 typedef ByIndexMap::iterator ByIndexIterator;
138 typedef NameToIndexMap::iterator NameToIndexIterator;
140 ByIndexMap m_children_byindex;
141 NameToIndexMap m_name_toindex;
142 uint32_t m_synthetic_children_count; // FIXME use the ValueObject's
143 // ChildrenManager instead of a special
145 SyntheticChildrenCache m_synthetic_children_cache;
147 ConstString m_parent_type_name;
149 LazyBool m_might_have_children;
151 LazyBool m_provides_value;
154 friend class ValueObject;
155 ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
157 void CopyValueData(ValueObject *source);
159 DISALLOW_COPY_AND_ASSIGN(ValueObjectSynthetic);
162 } // namespace lldb_private
164 #endif // liblldb_ValueObjectSyntheticFilter_h_