]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
MFV r308954:
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Core / ValueObjectSyntheticFilter.h
1 //===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_ValueObjectSyntheticFilter_h_
11 #define liblldb_ValueObjectSyntheticFilter_h_
12
13 // C Includes
14 // C++ Includes
15 #include <memory>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Core/ThreadSafeSTLMap.h"
20 #include "lldb/Core/ValueObject.h"
21
22 namespace lldb_private {
23
24 //----------------------------------------------------------------------
25 // A ValueObject that obtains its children from some source other than
26 // real information
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
32 {
33 public:
34     ~ValueObjectSynthetic() override;
35
36     uint64_t
37     GetByteSize() override;
38     
39     ConstString
40     GetTypeName() override;
41     
42     ConstString
43     GetQualifiedTypeName() override;
44     
45     ConstString
46     GetDisplayTypeName() override;
47
48     bool
49     MightHaveChildren() override;
50
51     size_t
52     CalculateNumChildren(uint32_t max) override;
53
54     lldb::ValueType
55     GetValueType() const override;
56     
57     lldb::ValueObjectSP
58     GetChildAtIndex(size_t idx, bool can_create) override;
59     
60     lldb::ValueObjectSP
61     GetChildMemberWithName(const ConstString &name, bool can_create) override;
62     
63     size_t
64     GetIndexOfChildWithName(const ConstString &name) override;
65
66     lldb::ValueObjectSP
67     GetDynamicValue(lldb::DynamicValueType valueType) override;
68     
69     bool
70     IsInScope() override;
71     
72     bool
73     HasSyntheticValue() override
74     {
75         return false;
76     }
77     
78     bool
79     IsSynthetic() override
80     {
81         return true;
82     }
83     
84     void
85     CalculateSyntheticValue(bool use_synthetic) override
86     {
87     }
88     
89     bool
90     IsDynamic() override
91     {
92         return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
93     }
94     
95     lldb::ValueObjectSP
96     GetStaticValue() override
97     {
98         return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
99     }
100     
101     virtual lldb::DynamicValueType
102     GetDynamicValueType ()
103     {
104         return ((m_parent != nullptr) ? m_parent->GetDynamicValueType() : lldb::eNoDynamicValues);
105     }
106
107     ValueObject *
108     GetParent() override
109     {
110         return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
111     }
112
113     const ValueObject *
114     GetParent() const override
115     {
116         return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
117     }
118     
119     lldb::ValueObjectSP
120     GetNonSyntheticValue() override;
121     
122     bool
123     CanProvideValue() override;
124     
125     bool
126     DoesProvideSyntheticValue() override
127     {
128         return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
129     }
130     
131     bool
132     GetIsConstant() const override
133     {
134         return false;
135     }
136
137     bool
138     SetValueFromCString(const char *value_str, Error& error) override;
139     
140     void
141     SetFormat(lldb::Format format) override;
142     
143     lldb::LanguageType
144     GetPreferredDisplayLanguage() override;
145     
146     void
147     SetPreferredDisplayLanguage (lldb::LanguageType);
148     
149     bool
150     GetDeclaration(Declaration &decl) override;
151
152     uint64_t
153     GetLanguageFlags () override;
154     
155     void
156     SetLanguageFlags (uint64_t flags) override;
157     
158 protected:
159     bool
160     UpdateValue() override;
161     
162     LazyBool
163     CanUpdateWithInvalidExecutionContext() override
164     {
165         return eLazyBoolYes;
166     }
167     
168     CompilerType
169     GetCompilerTypeImpl() override;
170     
171     virtual void
172     CreateSynthFilter ();
173
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;
177     
178     typedef ThreadSafeSTLMap<uint32_t, ValueObject*> ByIndexMap;
179     typedef ThreadSafeSTLMap<const char*, uint32_t> NameToIndexMap;
180     
181     typedef ByIndexMap::iterator ByIndexIterator;
182     typedef NameToIndexMap::iterator NameToIndexIterator;
183
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
187     
188     ConstString     m_parent_type_name;
189
190     LazyBool        m_might_have_children;
191     
192     LazyBool        m_provides_value;
193     
194 private:
195     friend class ValueObject;
196     ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter);
197     
198     void
199     CopyValueData (ValueObject *source);
200     
201     DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic);
202 };
203
204 } // namespace lldb_private
205
206 #endif // liblldb_ValueObjectSyntheticFilter_h_