ValueObjectSyntheticFilter.h revision f509c5ec066599a3399fced39ea36996184939e8
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 size_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 return false; 87 } 88 89 virtual ValueObject * 90 GetParent() 91 { 92 if (m_parent) 93 return m_parent->GetParent(); 94 else 95 return NULL; 96 } 97 98 virtual const ValueObject * 99 GetParent() const 100 { 101 if (m_parent) 102 return m_parent->GetParent(); 103 else 104 return NULL; 105 } 106 107 virtual lldb::ValueObjectSP 108 GetNonSyntheticValue (); 109 110 virtual bool 111 ResolveValue (Scalar &scalar) 112 { 113 if (m_parent) 114 return m_parent->ResolveValue(scalar); 115 return false; 116 } 117 118protected: 119 virtual bool 120 UpdateValue (); 121 122 virtual clang::ASTContext * 123 GetClangASTImpl (); 124 125 virtual lldb::clang_type_t 126 GetClangTypeImpl (); 127 128 virtual void 129 CreateSynthFilter (); 130 131 // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive 132 lldb::SyntheticChildrenSP m_synth_sp; 133 std::auto_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap; 134 135 typedef std::map<uint32_t, ValueObject*> ByIndexMap; 136 typedef std::map<const char*, uint32_t> NameToIndexMap; 137 138 typedef ByIndexMap::iterator ByIndexIterator; 139 typedef NameToIndexMap::iterator NameToIndexIterator; 140 141 ByIndexMap m_children_byindex; 142 NameToIndexMap m_name_toindex; 143 uint32_t m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution 144 145 ConstString m_parent_type_name; 146 147 LazyBool m_might_have_children; 148 149private: 150 friend class ValueObject; 151 ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter); 152 153 void 154 CopyParentData (); 155 156 //------------------------------------------------------------------ 157 // For ValueObject only 158 //------------------------------------------------------------------ 159 DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic); 160}; 161 162} // namespace lldb_private 163 164#endif // liblldb_ValueObjectSyntheticFilter_h_ 165