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