]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
Merge ACPICA 20150619.
[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 <vector>
16 // Other libraries and framework includes
17 // Project includes
18 #include "lldb/Core/ThreadSafeSTLMap.h"
19 #include "lldb/Core/ValueObject.h"
20
21 namespace lldb_private {
22
23 //----------------------------------------------------------------------
24 // A ValueObject that obtains its children from some source other than
25 // real information
26 // This is currently used to implement Python-based children and filters
27 // but you can bind it to any source of synthetic information and have
28 // it behave accordingly
29 //----------------------------------------------------------------------
30 class ValueObjectSynthetic : public ValueObject
31 {
32 public:
33     virtual
34     ~ValueObjectSynthetic();
35
36     virtual uint64_t
37     GetByteSize();
38     
39     virtual ConstString
40     GetTypeName();
41     
42     virtual ConstString
43     GetQualifiedTypeName();
44     
45     virtual ConstString
46     GetDisplayTypeName();
47
48     virtual bool
49     MightHaveChildren();
50
51     virtual size_t
52     CalculateNumChildren();
53
54     virtual lldb::ValueType
55     GetValueType() const;
56     
57     virtual lldb::ValueObjectSP
58     GetChildAtIndex (size_t idx, bool can_create);
59     
60     virtual lldb::ValueObjectSP
61     GetChildMemberWithName (const ConstString &name, bool can_create);
62     
63     virtual size_t
64     GetIndexOfChildWithName (const ConstString &name);
65
66     virtual lldb::ValueObjectSP
67     GetDynamicValue (lldb::DynamicValueType valueType);
68     
69     virtual bool
70     IsInScope ();
71     
72     virtual bool
73     HasSyntheticValue()
74     {
75         return false;
76     }
77     
78     virtual bool
79     IsSynthetic() { return true; }
80     
81     virtual void
82     CalculateSyntheticValue (bool use_synthetic)
83     {
84     }
85     
86     virtual bool
87     IsDynamic ()
88     {
89         if (m_parent)
90             return m_parent->IsDynamic();
91         else
92             return false;
93     }
94     
95     virtual lldb::ValueObjectSP
96     GetStaticValue ()
97     {
98         if (m_parent)
99             return m_parent->GetStaticValue();
100         else
101             return GetSP();
102     }
103     
104     virtual lldb::DynamicValueType
105     GetDynamicValueType ()
106     {
107         if (m_parent)
108             return m_parent->GetDynamicValueType();
109         else
110             return lldb::eNoDynamicValues;
111     }
112
113     virtual ValueObject *
114     GetParent()
115     {
116         if (m_parent)
117             return m_parent->GetParent();
118         else
119             return NULL;
120     }
121
122     virtual const ValueObject *
123     GetParent() const
124     {
125         if (m_parent)
126             return m_parent->GetParent();
127         else
128             return NULL;
129     }
130     
131     virtual lldb::ValueObjectSP
132     GetNonSyntheticValue ();
133     
134     virtual bool
135     CanProvideValue ();
136     
137     virtual bool
138     DoesProvideSyntheticValue ()
139     {
140         return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
141     }
142     
143 protected:
144     virtual bool
145     UpdateValue ();
146     
147     virtual ClangASTType
148     GetClangTypeImpl ();
149     
150     virtual void
151     CreateSynthFilter ();
152
153     // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive
154     lldb::SyntheticChildrenSP m_synth_sp;
155     std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
156     
157     typedef ThreadSafeSTLMap<uint32_t, ValueObject*> ByIndexMap;
158     typedef ThreadSafeSTLMap<const char*, uint32_t> NameToIndexMap;
159     
160     typedef ByIndexMap::iterator ByIndexIterator;
161     typedef NameToIndexMap::iterator NameToIndexIterator;
162
163     ByIndexMap      m_children_byindex;
164     NameToIndexMap  m_name_toindex;
165     uint32_t        m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution
166     
167     ConstString     m_parent_type_name;
168
169     LazyBool        m_might_have_children;
170     
171     LazyBool        m_provides_value;
172     
173 private:
174     friend class ValueObject;
175     ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter);
176     
177     void
178     CopyValueData (ValueObject *source);
179     
180     //------------------------------------------------------------------
181     // For ValueObject only
182     //------------------------------------------------------------------
183     DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic);
184 };
185
186 } // namespace lldb_private
187
188 #endif  // liblldb_ValueObjectSyntheticFilter_h_