ValueObjectSyntheticFilter.h revision 931acecd4e3af534028936431dc0f75a9fd6eb02
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 <ostream> 17#include <vector> 18// Other libraries and framework includes 19// Project includes 20#include "lldb/Core/ValueObject.h" 21 22namespace lldb_private { 23 24//---------------------------------------------------------------------- 25// A ValueObject that obtains its children from some source other than 26// real information 27// This is currently used to implement Python-based children and filters 28// but you can bind it to any source of synthetic information and have 29// it behave accordingly 30//---------------------------------------------------------------------- 31class ValueObjectSynthetic : public ValueObject 32{ 33public: 34 virtual 35 ~ValueObjectSynthetic(); 36 37 virtual size_t 38 GetByteSize(); 39 40 virtual ConstString 41 GetTypeName(); 42 43 virtual uint32_t 44 CalculateNumChildren(); 45 46 virtual lldb::ValueType 47 GetValueType() const; 48 49 virtual lldb::ValueObjectSP 50 GetChildAtIndex (uint32_t idx, bool can_create); 51 52 virtual lldb::ValueObjectSP 53 GetChildMemberWithName (const ConstString &name, bool can_create); 54 55 virtual uint32_t 56 GetIndexOfChildWithName (const ConstString &name); 57 58 virtual bool 59 IsInScope (); 60 61 virtual bool 62 HasSyntheticValue() 63 { 64 return true; // we are our own synthetic value 65 } 66 67 virtual void 68 CalculateSyntheticValue (lldb::SyntheticValueType use_synthetic) 69 { 70 m_synthetic_value = this; 71 } 72 73 virtual bool 74 IsDynamic () 75 { 76 if (m_parent) 77 return m_parent->IsDynamic(); 78 else 79 return false; 80 } 81 82 virtual ValueObject * 83 GetParent() 84 { 85 if (m_parent) 86 return m_parent->GetParent(); 87 else 88 return NULL; 89 } 90 91 virtual const ValueObject * 92 GetParent() const 93 { 94 if (m_parent) 95 return m_parent->GetParent(); 96 else 97 return NULL; 98 } 99 100 void 101 SetOwningSP (lldb::ValueObjectSP &owning_sp) 102 { 103 if (m_owning_valobj_sp == owning_sp) 104 return; 105 106 assert (m_owning_valobj_sp.get() == NULL); 107 m_owning_valobj_sp = owning_sp; 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 Address m_address; ///< The variable that this value object is based upon 121 lldb::TypeSP m_type_sp; 122 lldb::ValueObjectSP m_owning_valobj_sp; 123 lldb::SyntheticValueType m_use_synthetic; 124 lldb::SyntheticChildrenSP m_synth_sp; // hold on to your synthetic children provider 125 lldb::SyntheticChildrenFrontEndSP m_synth_filter; 126 127 typedef std::map<uint32_t, lldb::ValueObjectSP> 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 136private: 137 friend class ValueObject; 138 ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter); 139 140 //------------------------------------------------------------------ 141 // For ValueObject only 142 //------------------------------------------------------------------ 143 DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic); 144}; 145 146} // namespace lldb_private 147 148#endif // liblldb_ValueObjectSyntheticFilter_h_ 149