1 //===-- ValueObjectDynamicValue.cpp ---------------------------------*- 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 11 #include "lldb/Core/ValueObjectCast.h" 12 13 // C Includes 14 // C++ Includes 15 // Other libraries and framework includes 16 // Project includes 17 #include "lldb/Core/Log.h" 18 #include "lldb/Core/Module.h" 19 #include "lldb/Core/ValueObjectList.h" 20 #include "lldb/Core/Value.h" 21 #include "lldb/Core/ValueObject.h" 22 23 #include "lldb/Symbol/CompilerType.h" 24 #include "lldb/Symbol/ObjectFile.h" 25 #include "lldb/Symbol/SymbolContext.h" 26 #include "lldb/Symbol/Type.h" 27 #include "lldb/Symbol/Variable.h" 28 29 #include "lldb/Target/ExecutionContext.h" 30 #include "lldb/Target/Process.h" 31 #include "lldb/Target/RegisterContext.h" 32 #include "lldb/Target/Target.h" 33 #include "lldb/Target/Thread.h" 34 35 using namespace lldb_private; 36 37 lldb::ValueObjectSP 38 ValueObjectCast::Create (ValueObject &parent, 39 const ConstString &name, 40 const CompilerType &cast_type) 41 { 42 ValueObjectCast *cast_valobj_ptr = new ValueObjectCast (parent, name, cast_type); 43 return cast_valobj_ptr->GetSP(); 44 } 45 46 ValueObjectCast::ValueObjectCast 47 ( 48 ValueObject &parent, 49 const ConstString &name, 50 const CompilerType &cast_type 51 ) : 52 ValueObject(parent), 53 m_cast_type (cast_type) 54 { 55 SetName (name); 56 //m_value.SetContext (Value::eContextTypeClangType, cast_type.GetOpaqueQualType()); 57 m_value.SetCompilerType (cast_type); 58 } 59 60 ValueObjectCast::~ValueObjectCast() 61 { 62 } 63 64 CompilerType 65 ValueObjectCast::GetCompilerTypeImpl () 66 { 67 return m_cast_type; 68 } 69 70 size_t 71 ValueObjectCast::CalculateNumChildren() 72 { 73 return GetCompilerType().GetNumChildren (true); 74 } 75 76 uint64_t 77 ValueObjectCast::GetByteSize() 78 { 79 ExecutionContext exe_ctx (GetExecutionContextRef()); 80 return m_value.GetValueByteSize(nullptr, &exe_ctx); 81 } 82 83 lldb::ValueType 84 ValueObjectCast::GetValueType() const 85 { 86 // Let our parent answer global, local, argument, etc... 87 return m_parent->GetValueType(); 88 } 89 90 bool 91 ValueObjectCast::UpdateValue () 92 { 93 SetValueIsValid (false); 94 m_error.Clear(); 95 96 if (m_parent->UpdateValueIfNeeded(false)) 97 { 98 Value old_value(m_value); 99 m_update_point.SetUpdated(); 100 m_value = m_parent->GetValue(); 101 CompilerType compiler_type (GetCompilerType()); 102 //m_value.SetContext (Value::eContextTypeClangType, compiler_type); 103 m_value.SetCompilerType (compiler_type); 104 SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren()); 105 if (!CanProvideValue()) 106 { 107 // this value object represents an aggregate type whose 108 // children have values, but this object does not. So we 109 // say we are changed if our location has changed. 110 SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); 111 } 112 ExecutionContext exe_ctx (GetExecutionContextRef()); 113 m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get()); 114 SetValueDidChange (m_parent->GetValueDidChange()); 115 return true; 116 } 117 118 // The dynamic value failed to get an error, pass the error along 119 if (m_error.Success() && m_parent->GetError().Fail()) 120 m_error = m_parent->GetError(); 121 SetValueIsValid (false); 122 return false; 123 } 124 125 bool 126 ValueObjectCast::IsInScope () 127 { 128 return m_parent->IsInScope(); 129 } 130