ValueObjectConstResult.h revision 0d0f56d5b81afb0f3d2e71c53947658a4c667f35
1//===-- ValueObjectConstResult.h --------------------------------*- 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#ifndef liblldb_ValueObjectConstResult_h_
11#define liblldb_ValueObjectConstResult_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/Core/ValueObject.h"
18
19#include "lldb/Core/ValueObjectConstResultImpl.h"
20
21namespace lldb_private {
22
23//----------------------------------------------------------------------
24// A frozen ValueObject copied into host memory
25//----------------------------------------------------------------------
26class ValueObjectConstResult : public ValueObject
27{
28public:
29    static lldb::ValueObjectSP
30    Create (ExecutionContextScope *exe_scope,
31            lldb::ByteOrder byte_order,
32            uint32_t addr_byte_size,
33            lldb::addr_t address = LLDB_INVALID_ADDRESS);
34
35    static lldb::ValueObjectSP
36    Create (ExecutionContextScope *exe_scope,
37            clang::ASTContext *clang_ast,
38            void *clang_type,
39            const ConstString &name,
40            const DataExtractor &data,
41            lldb::addr_t address = LLDB_INVALID_ADDRESS);
42
43    static lldb::ValueObjectSP
44    Create (ExecutionContextScope *exe_scope,
45            clang::ASTContext *clang_ast,
46            void *clang_type,
47            const ConstString &name,
48            const lldb::DataBufferSP &result_data_sp,
49            lldb::ByteOrder byte_order,
50            uint8_t addr_size,
51            lldb::addr_t address = LLDB_INVALID_ADDRESS);
52
53    static lldb::ValueObjectSP
54    Create (ExecutionContextScope *exe_scope,
55            clang::ASTContext *clang_ast,
56            void *clang_type,
57            const ConstString &name,
58            lldb::addr_t address,
59            AddressType address_type,
60            uint8_t addr_byte_size);
61
62    static lldb::ValueObjectSP
63    Create (ExecutionContextScope *exe_scope,
64            clang::ASTContext *clang_ast,
65            Value &value,
66            const ConstString &name);
67
68    // When an expression fails to evaluate, we return an error
69    static lldb::ValueObjectSP
70    Create (ExecutionContextScope *exe_scope,
71            const Error& error);
72
73    virtual ~ValueObjectConstResult();
74
75    virtual size_t
76    GetByteSize();
77
78    virtual lldb::ValueType
79    GetValueType() const;
80
81    virtual uint32_t
82    CalculateNumChildren();
83
84    virtual ConstString
85    GetTypeName();
86
87    virtual bool
88    IsInScope ();
89
90    virtual bool
91    SetClangAST (clang::ASTContext *ast)
92    {
93        m_clang_ast = ast;
94        return true;
95    }
96
97    void
98    SetByteSize (size_t size);
99
100    virtual lldb::ValueObjectSP
101    Dereference (Error &error);
102
103    virtual ValueObject *
104    CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index);
105
106    virtual lldb::ValueObjectSP
107    GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create);
108
109    virtual lldb::ValueObjectSP
110    AddressOf (Error &error);
111
112    virtual lldb::addr_t
113    GetAddressOf (bool scalar_is_load_address = true,
114                  AddressType *address_type = NULL);
115
116    virtual size_t
117    GetPointeeData (DataExtractor& data,
118                    uint32_t item_idx = 0,
119					uint32_t item_count = 1);
120
121    virtual lldb::addr_t
122    GetLiveAddress()
123    {
124        return m_impl.GetLiveAddress();
125    }
126
127    virtual void
128    SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
129                   AddressType address_type = eAddressTypeLoad)
130    {
131        m_impl.SetLiveAddress(addr,
132                              address_type);
133    }
134
135    virtual lldb::ValueObjectSP
136    GetDynamicValue (lldb::DynamicValueType valueType);
137
138protected:
139    virtual bool
140    UpdateValue ();
141
142    virtual clang::ASTContext *
143    GetClangASTImpl ();
144
145    virtual lldb::clang_type_t
146    GetClangTypeImpl ();
147
148    clang::ASTContext *m_clang_ast; // The clang AST that the clang type comes from
149    ConstString m_type_name;
150    uint32_t m_byte_size;
151
152    ValueObjectConstResultImpl m_impl;
153
154private:
155    friend class ValueObjectConstResultImpl;
156    ValueObjectConstResult (ExecutionContextScope *exe_scope,
157                            lldb::ByteOrder byte_order,
158                            uint32_t addr_byte_size,
159                            lldb::addr_t address);
160
161    ValueObjectConstResult (ExecutionContextScope *exe_scope,
162                            clang::ASTContext *clang_ast,
163                            void *clang_type,
164                            const ConstString &name,
165                            const DataExtractor &data,
166                            lldb::addr_t address);
167
168    ValueObjectConstResult (ExecutionContextScope *exe_scope,
169                            clang::ASTContext *clang_ast,
170                            void *clang_type,
171                            const ConstString &name,
172                            const lldb::DataBufferSP &result_data_sp,
173                            lldb::ByteOrder byte_order,
174                            uint8_t addr_size,
175                            lldb::addr_t address);
176
177    ValueObjectConstResult (ExecutionContextScope *exe_scope,
178                            clang::ASTContext *clang_ast,
179                            void *clang_type,
180                            const ConstString &name,
181                            lldb::addr_t address,
182                            AddressType address_type,
183                            uint8_t addr_byte_size);
184
185    ValueObjectConstResult (ExecutionContextScope *exe_scope,
186                            clang::ASTContext *clang_ast,
187                            const Value &value,
188                            const ConstString &name);
189
190    ValueObjectConstResult (ExecutionContextScope *exe_scope,
191                            const Error& error);
192
193    DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResult);
194};
195
196} // namespace lldb_private
197
198#endif  // liblldb_ValueObjectConstResult_h_
199