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