Greg Clayton | 1d3afba | 2010-10-05 00:00:42 +0000 | [diff] [blame] | 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 | ) : |
Greg Clayton | 8f92f0a | 2010-10-14 22:52:14 +0000 | [diff] [blame^] | 38 | ValueObject (NULL), |
Greg Clayton | 1d3afba | 2010-10-05 00:00:42 +0000 | [diff] [blame] | 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; |
Greg Clayton | b71f384 | 2010-10-05 03:13:51 +0000 | [diff] [blame] | 49 | SetIsConstant (); |
| 50 | } |
| 51 | |
| 52 | ValueObjectConstResult::ValueObjectConstResult (const Error& error) : |
Greg Clayton | 8f92f0a | 2010-10-14 22:52:14 +0000 | [diff] [blame^] | 53 | ValueObject (NULL), |
Greg Clayton | b71f384 | 2010-10-05 03:13:51 +0000 | [diff] [blame] | 54 | m_clang_ast (NULL), |
| 55 | m_type_name () |
| 56 | { |
| 57 | m_error = error; |
| 58 | SetIsConstant (); |
Greg Clayton | 1d3afba | 2010-10-05 00:00:42 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | ValueObjectConstResult::~ValueObjectConstResult() |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | void * |
| 66 | ValueObjectConstResult::GetClangType() |
| 67 | { |
| 68 | return m_value.GetClangType(); |
| 69 | } |
| 70 | |
| 71 | lldb::ValueType |
| 72 | ValueObjectConstResult::GetValueType() const |
| 73 | { |
| 74 | return eValueTypeConstResult; |
| 75 | } |
| 76 | |
| 77 | size_t |
| 78 | ValueObjectConstResult::GetByteSize() |
| 79 | { |
| 80 | // We stored all the data for this const object in our data |
| 81 | return m_data.GetByteSize(); |
| 82 | } |
| 83 | |
| 84 | uint32_t |
| 85 | ValueObjectConstResult::CalculateNumChildren() |
| 86 | { |
| 87 | return ClangASTContext::GetNumChildren (GetClangType(), true); |
| 88 | } |
| 89 | |
| 90 | clang::ASTContext * |
| 91 | ValueObjectConstResult::GetClangAST () |
| 92 | { |
| 93 | return m_clang_ast; |
| 94 | } |
| 95 | |
| 96 | ConstString |
| 97 | ValueObjectConstResult::GetTypeName() |
| 98 | { |
| 99 | if (m_type_name.IsEmpty()) |
| 100 | m_type_name = ClangASTType::GetClangTypeName (GetClangType()); |
| 101 | return m_type_name; |
| 102 | } |
| 103 | |
| 104 | void |
| 105 | ValueObjectConstResult::UpdateValue (ExecutionContextScope *exe_scope) |
| 106 | { |
| 107 | m_error.Clear(); |
| 108 | // Const value is always valid |
| 109 | SetValueIsValid (true); |
| 110 | } |
| 111 | |
| 112 | |
| 113 | bool |
| 114 | ValueObjectConstResult::IsInScope (StackFrame *frame) |
| 115 | { |
| 116 | // A const result value is always in scope since it serializes all |
| 117 | // information needed to contain the constant value. |
| 118 | return true; |
| 119 | } |