blob: d2317dfde411eb11c773b79bbce6d389e6f07d4b [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) :
38 ValueObject (),
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}
50
51ValueObjectConstResult::~ValueObjectConstResult()
52{
53}
54
55void *
56ValueObjectConstResult::GetClangType()
57{
58 return m_value.GetClangType();
59}
60
61lldb::ValueType
62ValueObjectConstResult::GetValueType() const
63{
64 return eValueTypeConstResult;
65}
66
67size_t
68ValueObjectConstResult::GetByteSize()
69{
70 // We stored all the data for this const object in our data
71 return m_data.GetByteSize();
72}
73
74uint32_t
75ValueObjectConstResult::CalculateNumChildren()
76{
77 return ClangASTContext::GetNumChildren (GetClangType(), true);
78}
79
80clang::ASTContext *
81ValueObjectConstResult::GetClangAST ()
82{
83 return m_clang_ast;
84}
85
86ConstString
87ValueObjectConstResult::GetTypeName()
88{
89 if (m_type_name.IsEmpty())
90 m_type_name = ClangASTType::GetClangTypeName (GetClangType());
91 return m_type_name;
92}
93
94void
95ValueObjectConstResult::UpdateValue (ExecutionContextScope *exe_scope)
96{
97 m_error.Clear();
98 // Const value is always valid
99 SetValueIsValid (true);
100}
101
102
103bool
104ValueObjectConstResult::IsInScope (StackFrame *frame)
105{
106 // A const result value is always in scope since it serializes all
107 // information needed to contain the constant value.
108 return true;
109}