]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
Merge llvm, clang, lld and lldb release_40 branch r292009. Also update
[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/ThreadSafeSTLVector.h"
21 #include "lldb/Core/ValueObject.h"
22
23 namespace lldb_private {
24
25 //----------------------------------------------------------------------
26 // A ValueObject that obtains its children from some source other than
27 // real information
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 {
33 public:
34   ~ValueObjectSynthetic() override;
35
36   uint64_t GetByteSize() override;
37
38   ConstString GetTypeName() override;
39
40   ConstString GetQualifiedTypeName() override;
41
42   ConstString GetDisplayTypeName() override;
43
44   bool MightHaveChildren() override;
45
46   size_t CalculateNumChildren(uint32_t max) override;
47
48   lldb::ValueType GetValueType() const override;
49
50   lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
51
52   lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
53                                              bool can_create) override;
54
55   size_t GetIndexOfChildWithName(const ConstString &name) override;
56
57   lldb::ValueObjectSP
58   GetDynamicValue(lldb::DynamicValueType valueType) override;
59
60   bool IsInScope() override;
61
62   bool HasSyntheticValue() override { return false; }
63
64   bool IsSynthetic() override { return true; }
65
66   void CalculateSyntheticValue(bool use_synthetic) override {}
67
68   bool IsDynamic() override {
69     return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
70   }
71
72   lldb::ValueObjectSP GetStaticValue() override {
73     return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
74   }
75
76   virtual lldb::DynamicValueType GetDynamicValueType() {
77     return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
78                                   : lldb::eNoDynamicValues);
79   }
80
81   ValueObject *GetParent() override {
82     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
83   }
84
85   const ValueObject *GetParent() const override {
86     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
87   }
88
89   lldb::ValueObjectSP GetNonSyntheticValue() override;
90
91   bool CanProvideValue() override;
92
93   bool DoesProvideSyntheticValue() override {
94     return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
95   }
96
97   bool GetIsConstant() const override { return false; }
98
99   bool SetValueFromCString(const char *value_str, Error &error) override;
100
101   void SetFormat(lldb::Format format) override;
102
103   lldb::LanguageType GetPreferredDisplayLanguage() override;
104
105   void SetPreferredDisplayLanguage(lldb::LanguageType);
106
107   bool IsSyntheticChildrenGenerated() override;
108
109   void SetSyntheticChildrenGenerated(bool b) override;
110
111   bool GetDeclaration(Declaration &decl) override;
112
113   uint64_t GetLanguageFlags() override;
114
115   void SetLanguageFlags(uint64_t flags) override;
116
117 protected:
118   bool UpdateValue() override;
119
120   LazyBool CanUpdateWithInvalidExecutionContext() override {
121     return eLazyBoolYes;
122   }
123
124   CompilerType GetCompilerTypeImpl() override;
125
126   virtual void CreateSynthFilter();
127
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;
132
133   typedef ThreadSafeSTLMap<uint32_t, ValueObject *> ByIndexMap;
134   typedef ThreadSafeSTLMap<const char *, uint32_t> NameToIndexMap;
135   typedef ThreadSafeSTLVector<lldb::ValueObjectSP> SyntheticChildrenCache;
136
137   typedef ByIndexMap::iterator ByIndexIterator;
138   typedef NameToIndexMap::iterator NameToIndexIterator;
139
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
144                                        // purpose solution
145   SyntheticChildrenCache m_synthetic_children_cache;
146
147   ConstString m_parent_type_name;
148
149   LazyBool m_might_have_children;
150
151   LazyBool m_provides_value;
152
153 private:
154   friend class ValueObject;
155   ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
156
157   void CopyValueData(ValueObject *source);
158
159   DISALLOW_COPY_AND_ASSIGN(ValueObjectSynthetic);
160 };
161
162 } // namespace lldb_private
163
164 #endif // liblldb_ValueObjectSyntheticFilter_h_