blob: 93e2d3eb05a37fbf0851ef4507a3c0433483793b [file] [log] [blame]
Greg Clayton1d3afba2010-10-05 00:00:42 +00001//===-- 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
26using namespace lldb;
27using namespace lldb_private;
28
29ValueObjectConstResult::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 Clayton8f92f0a2010-10-14 22:52:14 +000038 ValueObject (NULL),
Greg Clayton1d3afba2010-10-05 00:00:42 +000039 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 Claytonb71f3842010-10-05 03:13:51 +000049 SetIsConstant ();
Jim Inghame2f88412010-10-15 22:47:36 +000050 SetValueIsValid(true);
Greg Claytonb71f3842010-10-05 03:13:51 +000051}
52
53ValueObjectConstResult::ValueObjectConstResult (const Error& error) :
Greg Clayton8f92f0a2010-10-14 22:52:14 +000054 ValueObject (NULL),
Greg Claytonb71f3842010-10-05 03:13:51 +000055 m_clang_ast (NULL),
56 m_type_name ()
57{
58 m_error = error;
59 SetIsConstant ();
Greg Clayton1d3afba2010-10-05 00:00:42 +000060}
61
62ValueObjectConstResult::~ValueObjectConstResult()
63{
64}
65
66void *
67ValueObjectConstResult::GetClangType()
68{
69 return m_value.GetClangType();
70}
71
72lldb::ValueType
73ValueObjectConstResult::GetValueType() const
74{
75 return eValueTypeConstResult;
76}
77
78size_t
79ValueObjectConstResult::GetByteSize()
80{
81 // We stored all the data for this const object in our data
82 return m_data.GetByteSize();
83}
84
85uint32_t
86ValueObjectConstResult::CalculateNumChildren()
87{
88 return ClangASTContext::GetNumChildren (GetClangType(), true);
89}
90
91clang::ASTContext *
92ValueObjectConstResult::GetClangAST ()
93{
94 return m_clang_ast;
95}
96
97ConstString
98ValueObjectConstResult::GetTypeName()
99{
100 if (m_type_name.IsEmpty())
101 m_type_name = ClangASTType::GetClangTypeName (GetClangType());
102 return m_type_name;
103}
104
105void
106ValueObjectConstResult::UpdateValue (ExecutionContextScope *exe_scope)
107{
108 m_error.Clear();
109 // Const value is always valid
110 SetValueIsValid (true);
111}
112
113
114bool
115ValueObjectConstResult::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}