166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton//===-- ValueObjectConstResult.cpp ------------------------------*- C++ -*-===//
266ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton//
366ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton//                     The LLVM Compiler Infrastructure
466ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton//
566ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton// This file is distributed under the University of Illinois Open Source
666ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton// License. See LICENSE.TXT for details.
766ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton//
866ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton//===----------------------------------------------------------------------===//
966ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
1066ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Core/ValueObjectConstResult.h"
1166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
12915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata#include "lldb/Core/ValueObjectChild.h"
13915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata#include "lldb/Core/ValueObjectConstResultChild.h"
1466ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Core/DataExtractor.h"
1566ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Core/Module.h"
160d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton#include "lldb/Core/ValueObjectDynamicValue.h"
1766ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Core/ValueObjectList.h"
1866ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
1966ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Symbol/ClangASTType.h"
2066ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Symbol/ObjectFile.h"
2166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Symbol/SymbolContext.h"
2266ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Symbol/Type.h"
2366ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Symbol/Variable.h"
2466ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
2566ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Target/ExecutionContext.h"
2666ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Target/Process.h"
2766ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton#include "lldb/Target/Target.h"
2866ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
2966ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Claytonusing namespace lldb;
3066ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Claytonusing namespace lldb_private;
3166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
3247da810225d8674eb9158bcf5f1f5b847cbaeedfJim InghamValueObjectSP
3352f792329be5db8e38961350589e97e8f2823acdGreg ClaytonValueObjectConstResult::Create (ExecutionContextScope *exe_scope,
3452f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                ByteOrder byte_order,
3552f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                uint32_t addr_byte_size,
3652f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                lldb::addr_t address)
3747da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham{
3847da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham    return (new ValueObjectConstResult (exe_scope,
3947da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        byte_order,
40915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata                                        addr_byte_size,
41915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata                                        address))->GetSP();
4247da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham}
4347da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham
4452f792329be5db8e38961350589e97e8f2823acdGreg ClaytonValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope,
4552f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                ByteOrder byte_order,
4652f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                uint32_t addr_byte_size,
4752f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                lldb::addr_t address) :
48fa3a16a2ea380ef38388ebe323817bd1b32c20cdJim Ingham    ValueObject (exe_scope),
49427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_type_name (),
50915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_byte_size (0),
51915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_impl(this, address)
52427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton{
53427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    SetIsConstant ();
54427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    SetValueIsValid(true);
55427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_data.SetByteOrder(byte_order);
56427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_data.SetAddressByteSize(addr_byte_size);
57915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    SetAddressTypeOfChildren(eAddressTypeLoad);
58427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton}
59427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton
6047da810225d8674eb9158bcf5f1f5b847cbaeedfJim InghamValueObjectSP
6147da810225d8674eb9158bcf5f1f5b847cbaeedfJim InghamValueObjectConstResult::Create
6247da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham(
6347da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham    ExecutionContextScope *exe_scope,
6452f792329be5db8e38961350589e97e8f2823acdGreg Clayton    const ClangASTType &clang_type,
6547da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham    const ConstString &name,
66915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    const DataExtractor &data,
67915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    lldb::addr_t address
6847da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham)
6947da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham{
7047da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham    return (new ValueObjectConstResult (exe_scope,
7147da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        clang_type,
7247da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        name,
73915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata                                        data,
74915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata                                        address))->GetSP();
7547da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham}
7647da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham
7752f792329be5db8e38961350589e97e8f2823acdGreg ClaytonValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope,
7852f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const ClangASTType &clang_type,
7952f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const ConstString &name,
8052f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const DataExtractor &data,
8152f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                lldb::addr_t address) :
82fa3a16a2ea380ef38388ebe323817bd1b32c20cdJim Ingham    ValueObject (exe_scope),
83427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_type_name (),
84915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_byte_size (0),
85915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_impl(this, address)
86427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton{
87427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_data = data;
889ac3d8b086bbe0413fa85351383072e9ce8b4a60Sean Callanan
899ac3d8b086bbe0413fa85351383072e9ce8b4a60Sean Callanan    if (!m_data.GetSharedDataBuffer())
909ac3d8b086bbe0413fa85351383072e9ce8b4a60Sean Callanan    {
919ac3d8b086bbe0413fa85351383072e9ce8b4a60Sean Callanan        DataBufferSP shared_data_buffer(new DataBufferHeap(data.GetDataStart(), data.GetByteSize()));
929ac3d8b086bbe0413fa85351383072e9ce8b4a60Sean Callanan        m_data.SetData(shared_data_buffer);
939ac3d8b086bbe0413fa85351383072e9ce8b4a60Sean Callanan    }
949ac3d8b086bbe0413fa85351383072e9ce8b4a60Sean Callanan
95427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
96427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_value.SetValueType(Value::eValueTypeHostAddress);
9752f792329be5db8e38961350589e97e8f2823acdGreg Clayton    m_value.SetClangType(clang_type);
98427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_name = name;
99427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    SetIsConstant ();
100427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    SetValueIsValid(true);
101915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    SetAddressTypeOfChildren(eAddressTypeLoad);
102427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton}
103427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton
10447da810225d8674eb9158bcf5f1f5b847cbaeedfJim InghamValueObjectSP
10552f792329be5db8e38961350589e97e8f2823acdGreg ClaytonValueObjectConstResult::Create (ExecutionContextScope *exe_scope,
10652f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                const ClangASTType &clang_type,
10752f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                const ConstString &name,
10852f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                const lldb::DataBufferSP &data_sp,
10952f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                lldb::ByteOrder data_byte_order,
11052f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                uint32_t data_addr_size,
11152f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                lldb::addr_t address)
11247da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham{
11347da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham    return (new ValueObjectConstResult (exe_scope,
11447da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        clang_type,
11547da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        name,
11647da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        data_sp,
11747da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        data_byte_order,
118915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata                                        data_addr_size,
119915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata                                        address))->GetSP();
12047da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham}
12147da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham
1221586d9720002e407a3a097baf302de5fa4ca9c1bJim InghamValueObjectSP
1231586d9720002e407a3a097baf302de5fa4ca9c1bJim InghamValueObjectConstResult::Create (ExecutionContextScope *exe_scope,
12452f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                Value &value,
12552f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                const ConstString &name)
1261586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham{
12752f792329be5db8e38961350589e97e8f2823acdGreg Clayton    return (new ValueObjectConstResult (exe_scope, value, name))->GetSP();
1281586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham}
1291586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham
13052f792329be5db8e38961350589e97e8f2823acdGreg ClaytonValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope,
13152f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const ClangASTType &clang_type,
13252f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const ConstString &name,
13352f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const lldb::DataBufferSP &data_sp,
13452f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                lldb::ByteOrder data_byte_order,
13552f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                uint32_t data_addr_size,
13652f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                lldb::addr_t address) :
137fa3a16a2ea380ef38388ebe323817bd1b32c20cdJim Ingham    ValueObject (exe_scope),
138427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_type_name (),
139915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_byte_size (0),
140915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_impl(this, address)
14166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton{
14266ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    m_data.SetByteOrder(data_byte_order);
14366ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    m_data.SetAddressByteSize(data_addr_size);
14466ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    m_data.SetData(data_sp);
14566ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    m_value.GetScalar() = (uintptr_t)data_sp->GetBytes();
14666ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    m_value.SetValueType(Value::eValueTypeHostAddress);
14752f792329be5db8e38961350589e97e8f2823acdGreg Clayton    //m_value.SetContext(Value::eContextTypeClangType, clang_type);
14852f792329be5db8e38961350589e97e8f2823acdGreg Clayton    m_value.SetClangType (clang_type);
14966ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    m_name = name;
150d171972ecc7788bdb02d3e81420a24841e09a2bfGreg Clayton    SetIsConstant ();
15180c1f6f4de8655f80d3bb4fc29c4e69528285aa7Jim Ingham    SetValueIsValid(true);
152915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    SetAddressTypeOfChildren(eAddressTypeLoad);
153427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton}
154427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton
15547da810225d8674eb9158bcf5f1f5b847cbaeedfJim InghamValueObjectSP
15652f792329be5db8e38961350589e97e8f2823acdGreg ClaytonValueObjectConstResult::Create (ExecutionContextScope *exe_scope,
15752f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                const ClangASTType &clang_type,
15852f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                const ConstString &name,
15952f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                lldb::addr_t address,
16052f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                AddressType address_type,
16152f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                uint32_t addr_byte_size)
16247da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham{
16347da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham    return (new ValueObjectConstResult (exe_scope,
16447da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        clang_type,
16547da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        name,
16647da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        address,
16747da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        address_type,
16847da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        addr_byte_size))->GetSP();
16947da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham}
17047da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham
17152f792329be5db8e38961350589e97e8f2823acdGreg ClaytonValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope,
17252f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const ClangASTType &clang_type,
17352f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const ConstString &name,
17452f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                lldb::addr_t address,
17552f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                AddressType address_type,
17652f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                uint32_t addr_byte_size) :
177fa3a16a2ea380ef38388ebe323817bd1b32c20cdJim Ingham    ValueObject (exe_scope),
178427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_type_name (),
179915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_byte_size (0),
180915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_impl(this, address)
181427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton{
182427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_value.GetScalar() = address;
183427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_data.SetAddressByteSize(addr_byte_size);
184427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_value.GetScalar().GetData (m_data, addr_byte_size);
185427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    //m_value.SetValueType(Value::eValueTypeHostAddress);
186427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    switch (address_type)
187427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    {
188427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    case eAddressTypeInvalid:   m_value.SetValueType(Value::eValueTypeScalar);      break;
189427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    case eAddressTypeFile:      m_value.SetValueType(Value::eValueTypeFileAddress); break;
190427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    case eAddressTypeLoad:      m_value.SetValueType(Value::eValueTypeLoadAddress); break;
191427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    case eAddressTypeHost:      m_value.SetValueType(Value::eValueTypeHostAddress); break;
192427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    }
19352f792329be5db8e38961350589e97e8f2823acdGreg Clayton//    m_value.SetContext(Value::eContextTypeClangType, clang_type);
19452f792329be5db8e38961350589e97e8f2823acdGreg Clayton    m_value.SetClangType (clang_type);
195427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_name = name;
196427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    SetIsConstant ();
197427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    SetValueIsValid(true);
198915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    SetAddressTypeOfChildren(eAddressTypeLoad);
199d171972ecc7788bdb02d3e81420a24841e09a2bfGreg Clayton}
200d171972ecc7788bdb02d3e81420a24841e09a2bfGreg Clayton
20147da810225d8674eb9158bcf5f1f5b847cbaeedfJim InghamValueObjectSP
20247da810225d8674eb9158bcf5f1f5b847cbaeedfJim InghamValueObjectConstResult::Create
20347da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham(
20447da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham    ExecutionContextScope *exe_scope,
20547da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham    const Error& error
20647da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham)
20747da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham{
20847da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham    return (new ValueObjectConstResult (exe_scope,
20947da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham                                        error))->GetSP();
21047da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham}
21147da810225d8674eb9158bcf5f1f5b847cbaeedfJim Ingham
21252f792329be5db8e38961350589e97e8f2823acdGreg ClaytonValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope,
21352f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const Error& error) :
214fa3a16a2ea380ef38388ebe323817bd1b32c20cdJim Ingham    ValueObject (exe_scope),
215427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_type_name (),
216915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_byte_size (0),
217915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    m_impl(this)
218d171972ecc7788bdb02d3e81420a24841e09a2bfGreg Clayton{
219d171972ecc7788bdb02d3e81420a24841e09a2bfGreg Clayton    m_error = error;
220d171972ecc7788bdb02d3e81420a24841e09a2bfGreg Clayton    SetIsConstant ();
22166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton}
22266ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
22352f792329be5db8e38961350589e97e8f2823acdGreg ClaytonValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope,
22452f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const Value &value,
22552f792329be5db8e38961350589e97e8f2823acdGreg Clayton                                                const ConstString &name) :
2261586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham    ValueObject (exe_scope),
2271586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham    m_type_name (),
2281586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham    m_byte_size (0),
2291586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham    m_impl(this)
2301586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham{
2311586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham    m_value = value;
2321586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham    m_value.GetData(m_data);
2331586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham}
2341586d9720002e407a3a097baf302de5fa4ca9c1bJim Ingham
23566ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg ClaytonValueObjectConstResult::~ValueObjectConstResult()
23666ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton{
23766ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton}
23866ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
23952f792329be5db8e38961350589e97e8f2823acdGreg ClaytonClangASTType
240931acecd4e3af534028936431dc0f75a9fd6eb02Sean CallananValueObjectConstResult::GetClangTypeImpl()
24166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton{
24266ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    return m_value.GetClangType();
24366ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton}
24466ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
24566ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Claytonlldb::ValueType
24666ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg ClaytonValueObjectConstResult::GetValueType() const
24766ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton{
24866ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    return eValueTypeConstResult;
24966ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton}
25066ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
251fe6dc6e241c52822710380cec0931351a1d7b2d3Greg Claytonuint64_t
25266ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg ClaytonValueObjectConstResult::GetByteSize()
25366ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton{
254427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    if (m_byte_size == 0)
25552f792329be5db8e38961350589e97e8f2823acdGreg Clayton        m_byte_size = GetClangType().GetByteSize();
256427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    return m_byte_size;
257427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton}
258427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton
259427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Claytonvoid
260427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg ClaytonValueObjectConstResult::SetByteSize (size_t size)
261427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton{
262427f290ff96f3ab9f2cf3a1af7001d2c560424c7Greg Clayton    m_byte_size = size;
26366ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton}
26466ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
26536da2aa6dc5ad9994b638ed09eb81c44cc05540bGreg Claytonsize_t
26666ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg ClaytonValueObjectConstResult::CalculateNumChildren()
26766ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton{
26852f792329be5db8e38961350589e97e8f2823acdGreg Clayton    return GetClangType().GetNumChildren (true);
26966ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton}
27066ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
27166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg ClaytonConstString
27266ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg ClaytonValueObjectConstResult::GetTypeName()
27366ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton{
27466ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    if (m_type_name.IsEmpty())
27552f792329be5db8e38961350589e97e8f2823acdGreg Clayton        m_type_name = GetClangType().GetConstTypeName ();
27666ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    return m_type_name;
27766ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton}
27866ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
279fa3a16a2ea380ef38388ebe323817bd1b32c20cdJim Inghambool
280fa3a16a2ea380ef38388ebe323817bd1b32c20cdJim InghamValueObjectConstResult::UpdateValue ()
28166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton{
28266ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    // Const value is always valid
28366ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    SetValueIsValid (true);
284fa3a16a2ea380ef38388ebe323817bd1b32c20cdJim Ingham    return true;
28566ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton}
28666ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
28766ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton
28866ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Claytonbool
289fa3a16a2ea380ef38388ebe323817bd1b32c20cdJim InghamValueObjectConstResult::IsInScope ()
29066ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton{
29166ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    // A const result value is always in scope since it serializes all
29266ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    // information needed to contain the constant value.
29366ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton    return true;
29466ed2fbeaf588fe4105a1305f7e956dcf9fbe299Greg Clayton}
295915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata
296915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granatalldb::ValueObjectSP
297915448044bac6fdac22a33cc46697dcb771a8df2Enrico GranataValueObjectConstResult::Dereference (Error &error)
298915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata{
299915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    return m_impl.Dereference(error);
300915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata}
301915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata
302915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granatalldb::ValueObjectSP
303915448044bac6fdac22a33cc46697dcb771a8df2Enrico GranataValueObjectConstResult::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create)
304915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata{
305915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    return m_impl.GetSyntheticChildAtOffset(offset, type, can_create);
306915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata}
307915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata
308915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granatalldb::ValueObjectSP
309915448044bac6fdac22a33cc46697dcb771a8df2Enrico GranataValueObjectConstResult::AddressOf (Error &error)
310915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata{
311915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    return m_impl.AddressOf(error);
312915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata}
313915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata
314dfafa141aa9d0dd0596bf08b3f941be8c308316dJohnny Chenlldb::addr_t
315dfafa141aa9d0dd0596bf08b3f941be8c308316dJohnny ChenValueObjectConstResult::GetAddressOf (bool scalar_is_load_address,
316dfafa141aa9d0dd0596bf08b3f941be8c308316dJohnny Chen                                      AddressType *address_type)
317dfafa141aa9d0dd0596bf08b3f941be8c308316dJohnny Chen{
318dfafa141aa9d0dd0596bf08b3f941be8c308316dJohnny Chen    return m_impl.GetAddressOf(scalar_is_load_address, address_type);
319dfafa141aa9d0dd0596bf08b3f941be8c308316dJohnny Chen}
320dfafa141aa9d0dd0596bf08b3f941be8c308316dJohnny Chen
321915448044bac6fdac22a33cc46697dcb771a8df2Enrico GranataValueObject *
32236da2aa6dc5ad9994b638ed09eb81c44cc05540bGreg ClaytonValueObjectConstResult::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
323915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata{
324915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    return m_impl.CreateChildAtIndex(idx, synthetic_array_member, synthetic_index);
325915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata}
326915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata
327915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granatasize_t
328915448044bac6fdac22a33cc46697dcb771a8df2Enrico GranataValueObjectConstResult::GetPointeeData (DataExtractor& data,
329915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata                                        uint32_t item_idx,
330915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata                                        uint32_t item_count)
331915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata{
332915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata    return m_impl.GetPointeeData(data, item_idx, item_count);
333915448044bac6fdac22a33cc46697dcb771a8df2Enrico Granata}
3340d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton
3350d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Claytonlldb::ValueObjectSP
3360d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg ClaytonValueObjectConstResult::GetDynamicValue (lldb::DynamicValueType use_dynamic)
3370d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton{
3380d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton    // Always recalculate dynamic values for const results as the memory that
3390d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton    // they might point to might have changed at any time.
3400d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton    if (use_dynamic != eNoDynamicValues)
3410d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton    {
3420d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton        if (!IsDynamic())
3430d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton        {
3440d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton            ExecutionContext exe_ctx (GetExecutionContextRef());
3450d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton            Process *process = exe_ctx.GetProcessPtr();
3460d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton            if (process && process->IsPossibleDynamicValue(*this))
3470d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton                m_dynamic_value = new ValueObjectDynamicValue (*this, use_dynamic);
3480d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton        }
3490d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton        if (m_dynamic_value)
3500d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton            return m_dynamic_value->GetSP();
3510d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton    }
3520d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton    return ValueObjectSP();
3530d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton}
3540d0f56d5b81afb0f3d2e71c53947658a4c667f35Greg Clayton
355