ValueObjectSyntheticFilter.h revision 36da2aa6dc5ad9994b638ed09eb81c44cc05540b
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 bool 43 MightHaveChildren(); 44 45 virtual size_t 46 CalculateNumChildren(); 47 48 virtual lldb::ValueType 49 GetValueType() const; 50 51 virtual lldb::ValueObjectSP 52 GetChildAtIndex (size_t idx, bool can_create); 53 54 virtual lldb::ValueObjectSP 55 GetChildMemberWithName (const ConstString &name, bool can_create); 56 57 virtual size_t 58 GetIndexOfChildWithName (const ConstString &name); 59 60 virtual bool 61 IsInScope (); 62 63 virtual bool 64 HasSyntheticValue() 65 { 66 return false; 67 } 68 69 virtual bool 70 IsSynthetic() { return true; } 71 72 virtual void 73 CalculateSyntheticValue (bool use_synthetic) 74 { 75 } 76 77 virtual bool 78 IsDynamic () 79 { 80 return false; 81 } 82 83 virtual ValueObject * 84 GetParent() 85 { 86 if (m_parent) 87 return m_parent->GetParent(); 88 else 89 return NULL; 90 } 91 92 virtual const ValueObject * 93 GetParent() const 94 { 95 if (m_parent) 96 return m_parent->GetParent(); 97 else 98 return NULL; 99 } 100 101 virtual lldb::ValueObjectSP 102 GetNonSyntheticValue (); 103 104 virtual bool 105 ResolveValue (Scalar &scalar) 106 { 107 if (m_parent) 108 return m_parent->ResolveValue(scalar); 109 return false; 110 } 111 112protected: 113 virtual bool 114 UpdateValue (); 115 116 virtual clang::ASTContext * 117 GetClangASTImpl (); 118 119 virtual lldb::clang_type_t 120 GetClangTypeImpl (); 121 122 virtual void 123 CreateSynthFilter (); 124 125 // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive 126 lldb::SyntheticChildrenSP m_synth_sp; 127 std::auto_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap; 128 129 typedef std::map<uint32_t, ValueObject*> ByIndexMap; 130 typedef std::map<const char*, uint32_t> NameToIndexMap; 131 132 typedef ByIndexMap::iterator ByIndexIterator; 133 typedef NameToIndexMap::iterator NameToIndexIterator; 134 135 ByIndexMap m_children_byindex; 136 NameToIndexMap m_name_toindex; 137 uint32_t m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution 138 139 ConstString m_parent_type_name; 140 141 LazyBool m_might_have_children; 142 143private: 144 friend class ValueObject; 145 ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter); 146 147 void 148 CopyParentData (); 149 150 //------------------------------------------------------------------ 151 // For ValueObject only 152 //------------------------------------------------------------------ 153 DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic); 154}; 155 156} // namespace lldb_private 157 158#endif // liblldb_ValueObjectSyntheticFilter_h_ 159