1 //===-- ValueObjectConstResult.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 #include "lldb/Core/ValueObjectConstResult.h" 11 12 #include "lldb/Core/DataExtractor.h" 13 #include "lldb/Core/Module.h" 14 #include "lldb/Core/ValueObjectList.h" 15 16 #include "lldb/Symbol/ClangASTType.h" 17 #include "lldb/Symbol/ObjectFile.h" 18 #include "lldb/Symbol/SymbolContext.h" 19 #include "lldb/Symbol/Type.h" 20 #include "lldb/Symbol/Variable.h" 21 22 #include "lldb/Target/ExecutionContext.h" 23 #include "lldb/Target/Process.h" 24 #include "lldb/Target/Target.h" 25 26 using namespace lldb; 27 using namespace lldb_private; 28 29 ValueObjectConstResult::ValueObjectConstResult 30 ( 31 clang::ASTContext *clang_ast, 32 void *clang_type, 33 const ConstString &name, 34 const lldb::DataBufferSP &data_sp, 35 lldb::ByteOrder data_byte_order, 36 uint8_t data_addr_size 37 ) : 38 ValueObject (NULL), 39 m_clang_ast (clang_ast), 40 m_type_name () 41 { 42 m_data.SetByteOrder(data_byte_order); 43 m_data.SetAddressByteSize(data_addr_size); 44 m_data.SetData(data_sp); 45 m_value.GetScalar() = (uintptr_t)data_sp->GetBytes(); 46 m_value.SetValueType(Value::eValueTypeHostAddress); 47 m_value.SetContext(Value::eContextTypeOpaqueClangQualType, clang_type); 48 m_name = name; 49 SetIsConstant (); 50 SetValueIsValid(true); 51 } 52 53 ValueObjectConstResult::ValueObjectConstResult (const Error& error) : 54 ValueObject (NULL), 55 m_clang_ast (NULL), 56 m_type_name () 57 { 58 m_error = error; 59 SetIsConstant (); 60 } 61 62 ValueObjectConstResult::~ValueObjectConstResult() 63 { 64 } 65 66 void * 67 ValueObjectConstResult::GetClangType() 68 { 69 return m_value.GetClangType(); 70 } 71 72 lldb::ValueType 73 ValueObjectConstResult::GetValueType() const 74 { 75 return eValueTypeConstResult; 76 } 77 78 size_t 79 ValueObjectConstResult::GetByteSize() 80 { 81 // We stored all the data for this const object in our data 82 return m_data.GetByteSize(); 83 } 84 85 uint32_t 86 ValueObjectConstResult::CalculateNumChildren() 87 { 88 return ClangASTContext::GetNumChildren (GetClangType(), true); 89 } 90 91 clang::ASTContext * 92 ValueObjectConstResult::GetClangAST () 93 { 94 return m_clang_ast; 95 } 96 97 ConstString 98 ValueObjectConstResult::GetTypeName() 99 { 100 if (m_type_name.IsEmpty()) 101 m_type_name = ClangASTType::GetClangTypeName (GetClangType()); 102 return m_type_name; 103 } 104 105 void 106 ValueObjectConstResult::UpdateValue (ExecutionContextScope *exe_scope) 107 { 108 m_error.Clear(); 109 // Const value is always valid 110 SetValueIsValid (true); 111 } 112 113 114 bool 115 ValueObjectConstResult::IsInScope (StackFrame *frame) 116 { 117 // A const result value is always in scope since it serializes all 118 // information needed to contain the constant value. 119 return true; 120 } 121