ValueObjectDynamicValue.h revision 0d0f56d5b81afb0f3d2e71c53947658a4c667f35
1//===-- ValueObjectDynamicValue.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_ValueObjectDynamicValue_h_ 11#define liblldb_ValueObjectDynamicValue_h_ 12 13// C Includes 14// C++ Includes 15// Other libraries and framework includes 16// Project includes 17#include "lldb/Core/ValueObject.h" 18#include "lldb/Symbol/ClangASTType.h" 19 20namespace lldb_private { 21 22 class ValueObjectCast : public ValueObject 23 { 24 public: 25 static lldb::ValueObjectSP 26 Create (ValueObject &parent, 27 const ConstString &name, 28 const ClangASTType &cast_type); 29 30 virtual 31 ~ValueObjectCast(); 32 33 virtual size_t 34 GetByteSize(); 35 36 virtual uint32_t 37 CalculateNumChildren(); 38 39 virtual lldb::ValueType 40 GetValueType() const; 41 42 virtual bool 43 IsInScope (); 44 45 virtual bool 46 IsDynamic () 47 { 48 return true; 49 } 50 51 virtual ValueObject * 52 GetParent() 53 { 54 if (m_parent) 55 return m_parent->GetParent(); 56 else 57 return NULL; 58 } 59 60 virtual const ValueObject * 61 GetParent() const 62 { 63 if (m_parent) 64 return m_parent->GetParent(); 65 else 66 return NULL; 67 } 68 69 virtual lldb::ValueObjectSP 70 GetStaticValue () 71 { 72 return m_parent->GetSP(); 73 } 74 75 protected: 76 virtual bool 77 UpdateValue (); 78 79 virtual clang::ASTContext * 80 GetClangASTImpl (); 81 82 virtual lldb::clang_type_t 83 GetClangTypeImpl (); 84 85 ClangASTType m_cast_type; 86 87 private: 88 ValueObjectCast (ValueObject &parent, 89 const ConstString &name, 90 const ClangASTType &cast_type); 91 92 //------------------------------------------------------------------ 93 // For ValueObject only 94 //------------------------------------------------------------------ 95 DISALLOW_COPY_AND_ASSIGN (ValueObjectCast); 96 }; 97 98//---------------------------------------------------------------------- 99// A ValueObject that represents memory at a given address, viewed as some 100// set lldb type. 101//---------------------------------------------------------------------- 102class ValueObjectDynamicValue : public ValueObject 103{ 104public: 105 virtual 106 ~ValueObjectDynamicValue(); 107 108 virtual size_t 109 GetByteSize(); 110 111 virtual ConstString 112 GetTypeName(); 113 114 virtual uint32_t 115 CalculateNumChildren(); 116 117 virtual lldb::ValueType 118 GetValueType() const; 119 120 virtual bool 121 IsInScope (); 122 123 virtual bool 124 IsDynamic () 125 { 126 return true; 127 } 128 129 virtual ValueObject * 130 GetParent() 131 { 132 if (m_parent) 133 return m_parent->GetParent(); 134 else 135 return NULL; 136 } 137 138 virtual const ValueObject * 139 GetParent() const 140 { 141 if (m_parent) 142 return m_parent->GetParent(); 143 else 144 return NULL; 145 } 146 147 virtual lldb::ValueObjectSP 148 GetStaticValue () 149 { 150 return m_parent->GetSP(); 151 } 152 153 void 154 SetOwningSP (lldb::ValueObjectSP &owning_sp) 155 { 156 if (m_owning_valobj_sp == owning_sp) 157 return; 158 159 assert (m_owning_valobj_sp.get() == NULL); 160 m_owning_valobj_sp = owning_sp; 161 } 162 163 virtual bool 164 SetValueFromCString (const char *value_str, Error& error); 165 166protected: 167 virtual bool 168 UpdateValue (); 169 170 virtual clang::ASTContext * 171 GetClangASTImpl (); 172 173 virtual lldb::clang_type_t 174 GetClangTypeImpl (); 175 176 Address m_address; ///< The variable that this value object is based upon 177 lldb::TypeSP m_type_sp; 178 lldb::ValueObjectSP m_owning_valobj_sp; 179 lldb::DynamicValueType m_use_dynamic; 180 181private: 182 friend class ValueObject; 183 friend class ValueObjectConstResult; 184 ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic); 185 186 //------------------------------------------------------------------ 187 // For ValueObject only 188 //------------------------------------------------------------------ 189 DISALLOW_COPY_AND_ASSIGN (ValueObjectDynamicValue); 190}; 191 192} // namespace lldb_private 193 194#endif // liblldb_ValueObjectDynamicValue_h_ 195