ValueObjectSyntheticFilter.h revision 81a96aa6242f7b559770f5dc62316253cb8cb0d4
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 21namespace 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//---------------------------------------------------------------------- 30class ValueObjectSynthetic : public ValueObject 31{ 32public: 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 bool 46 MightHaveChildren(); 47 48 virtual size_t 49 CalculateNumChildren(); 50 51 virtual lldb::ValueType 52 GetValueType() const; 53 54 virtual lldb::ValueObjectSP 55 GetChildAtIndex (size_t idx, bool can_create); 56 57 virtual lldb::ValueObjectSP 58 GetChildMemberWithName (const ConstString &name, bool can_create); 59 60 virtual size_t 61 GetIndexOfChildWithName (const ConstString &name); 62 63 virtual lldb::ValueObjectSP 64 GetDynamicValue (lldb::DynamicValueType valueType); 65 66 virtual bool 67 IsInScope (); 68 69 virtual bool 70 HasSyntheticValue() 71 { 72 return false; 73 } 74 75 virtual bool 76 IsSynthetic() { return true; } 77 78 virtual void 79 CalculateSyntheticValue (bool use_synthetic) 80 { 81 } 82 83 virtual bool 84 IsDynamic () 85 { 86 if (m_parent) 87 return m_parent->IsDynamic(); 88 else 89 return false; 90 } 91 92 virtual lldb::ValueObjectSP 93 GetStaticValue () 94 { 95 if (m_parent) 96 return m_parent->GetStaticValue(); 97 else 98 return GetSP(); 99 } 100 101 virtual lldb::DynamicValueType 102 GetDynamicValueType () 103 { 104 if (m_parent) 105 return m_parent->GetDynamicValueType(); 106 else 107 return lldb::eNoDynamicValues; 108 } 109 110 virtual ValueObject * 111 GetParent() 112 { 113 if (m_parent) 114 return m_parent->GetParent(); 115 else 116 return NULL; 117 } 118 119 virtual const ValueObject * 120 GetParent() const 121 { 122 if (m_parent) 123 return m_parent->GetParent(); 124 else 125 return NULL; 126 } 127 128 virtual lldb::ValueObjectSP 129 GetNonSyntheticValue (); 130 131 virtual bool 132 ResolveValue (Scalar &scalar) 133 { 134 if (m_parent) 135 return m_parent->ResolveValue(scalar); 136 return false; 137 } 138 139protected: 140 virtual bool 141 UpdateValue (); 142 143 virtual clang::ASTContext * 144 GetClangASTImpl (); 145 146 virtual lldb::clang_type_t 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 170private: 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_ 186