ValueObjectConstResult.h revision dfafa141aa9d0dd0596bf08b3f941be8c308316d
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    // When an expression fails to evaluate, we return an error
63    static lldb::ValueObjectSP
64    Create (ExecutionContextScope *exe_scope,
65            const Error& error);
66
67    virtual ~ValueObjectConstResult();
68
69    virtual size_t
70    GetByteSize();
71
72    virtual clang::ASTContext *
73    GetClangAST ();
74
75    virtual lldb::clang_type_t
76    GetClangType ();
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
135protected:
136    virtual bool
137    UpdateValue ();
138
139    // CalculateDynamicValue doesn't change the dynamic value, since this can get
140    // called at any time and you can't reliably fetch the dynamic value at any time.
141    // If we want to have dynamic values for ConstResults, then we'll need to make them
142    // up when we make the const result & stuff them in by hand.
143    virtual void
144    CalculateDynamicValue (lldb::DynamicValueType use_dynamic) {}
145
146    clang::ASTContext *m_clang_ast; // The clang AST that the clang type comes from
147    ConstString m_type_name;
148    uint32_t m_byte_size;
149
150    ValueObjectConstResultImpl m_impl;
151
152private:
153    friend class ValueObjectConstResultImpl;
154    ValueObjectConstResult (ExecutionContextScope *exe_scope,
155                            lldb::ByteOrder byte_order,
156                            uint32_t addr_byte_size,
157                            lldb::addr_t address);
158
159    ValueObjectConstResult (ExecutionContextScope *exe_scope,
160                            clang::ASTContext *clang_ast,
161                            void *clang_type,
162                            const ConstString &name,
163                            const DataExtractor &data,
164                            lldb::addr_t address);
165
166    ValueObjectConstResult (ExecutionContextScope *exe_scope,
167                            clang::ASTContext *clang_ast,
168                            void *clang_type,
169                            const ConstString &name,
170                            const lldb::DataBufferSP &result_data_sp,
171                            lldb::ByteOrder byte_order,
172                            uint8_t addr_size,
173                            lldb::addr_t address);
174
175    ValueObjectConstResult (ExecutionContextScope *exe_scope,
176                            clang::ASTContext *clang_ast,
177                            void *clang_type,
178                            const ConstString &name,
179                            lldb::addr_t address,
180                            AddressType address_type,
181                            uint8_t addr_byte_size);
182
183    ValueObjectConstResult (ExecutionContextScope *exe_scope,
184                            const Error& error);
185
186    DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResult);
187};
188
189} // namespace lldb_private
190
191#endif  // liblldb_ValueObjectConstResult_h_
192