]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
MFV r277981:
[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 <map>
16 #include <vector>
17 // Other libraries and framework includes
18 // Project includes
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     ResolveValue (Scalar &scalar)
136     {
137         if (m_parent)
138             return m_parent->ResolveValue(scalar);
139         return false;
140     }
141     
142 protected:
143     virtual bool
144     UpdateValue ();
145     
146     virtual ClangASTType
147     GetClangTypeImpl ();
148     
149     virtual void
150     CreateSynthFilter ();
151
152     // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive
153     lldb::SyntheticChildrenSP m_synth_sp;
154     std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
155     
156     typedef std::map<uint32_t, ValueObject*> ByIndexMap;
157     typedef std::map<const char*, uint32_t> NameToIndexMap;
158     
159     typedef ByIndexMap::iterator ByIndexIterator;
160     typedef NameToIndexMap::iterator NameToIndexIterator;
161
162     ByIndexMap      m_children_byindex;
163     NameToIndexMap  m_name_toindex;
164     uint32_t        m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution
165     
166     ConstString     m_parent_type_name;
167
168     LazyBool        m_might_have_children;
169     
170 private:
171     friend class ValueObject;
172     ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter);
173     
174     void
175     CopyParentData ();
176     
177     //------------------------------------------------------------------
178     // For ValueObject only
179     //------------------------------------------------------------------
180     DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic);
181 };
182
183 } // namespace lldb_private
184
185 #endif  // liblldb_ValueObjectSyntheticFilter_h_