1 | //===-- ValueObjectConstResult.h --------------------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLDB_CORE_VALUEOBJECTCONSTRESULT_H |
10 | #define LLDB_CORE_VALUEOBJECTCONSTRESULT_H |
11 | |
12 | #include "lldb/Core/Value.h" |
13 | #include "lldb/Core/ValueObject.h" |
14 | #include "lldb/Core/ValueObjectConstResultImpl.h" |
15 | #include "lldb/Symbol/CompilerType.h" |
16 | #include "lldb/Utility/ConstString.h" |
17 | #include "lldb/Utility/Status.h" |
18 | #include "lldb/lldb-defines.h" |
19 | #include "lldb/lldb-enumerations.h" |
20 | #include "lldb/lldb-forward.h" |
21 | #include "lldb/lldb-private-enumerations.h" |
22 | #include "lldb/lldb-types.h" |
23 | |
24 | #include <cstddef> |
25 | #include <cstdint> |
26 | #include <optional> |
27 | |
28 | namespace lldb_private { |
29 | class ; |
30 | class ExecutionContextScope; |
31 | class Module; |
32 | |
33 | /// A frozen ValueObject copied into host memory. |
34 | class ValueObjectConstResult : public ValueObject { |
35 | public: |
36 | ~ValueObjectConstResult() override; |
37 | |
38 | static lldb::ValueObjectSP |
39 | Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, |
40 | uint32_t addr_byte_size, lldb::addr_t address = LLDB_INVALID_ADDRESS); |
41 | |
42 | static lldb::ValueObjectSP |
43 | (ExecutionContextScope *exe_scope, const CompilerType &compiler_type, |
44 | ConstString name, const DataExtractor &data, |
45 | lldb::addr_t address = LLDB_INVALID_ADDRESS); |
46 | |
47 | static lldb::ValueObjectSP |
48 | Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type, |
49 | ConstString name, const lldb::DataBufferSP &result_data_sp, |
50 | lldb::ByteOrder byte_order, uint32_t addr_size, |
51 | lldb::addr_t address = LLDB_INVALID_ADDRESS); |
52 | |
53 | static lldb::ValueObjectSP |
54 | Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type, |
55 | ConstString name, lldb::addr_t address, |
56 | AddressType address_type, uint32_t addr_byte_size); |
57 | |
58 | static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, |
59 | Value &value, ConstString name, |
60 | Module *module = nullptr); |
61 | |
62 | // When an expression fails to evaluate, we return an error |
63 | static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, |
64 | const Status &error); |
65 | |
66 | std::optional<uint64_t> GetByteSize() override; |
67 | |
68 | lldb::ValueType GetValueType() const override; |
69 | |
70 | size_t CalculateNumChildren(uint32_t max) override; |
71 | |
72 | ConstString GetTypeName() override; |
73 | |
74 | ConstString GetDisplayTypeName() override; |
75 | |
76 | bool IsInScope() override; |
77 | |
78 | void SetByteSize(size_t size); |
79 | |
80 | lldb::ValueObjectSP Dereference(Status &error) override; |
81 | |
82 | ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member, |
83 | int32_t synthetic_index) override; |
84 | |
85 | lldb::ValueObjectSP GetSyntheticChildAtOffset( |
86 | uint32_t offset, const CompilerType &type, bool can_create, |
87 | ConstString name_const_str = ConstString()) override; |
88 | |
89 | lldb::ValueObjectSP AddressOf(Status &error) override; |
90 | |
91 | lldb::addr_t GetAddressOf(bool scalar_is_load_address = true, |
92 | AddressType *address_type = nullptr) override; |
93 | |
94 | size_t (DataExtractor &data, uint32_t item_idx = 0, |
95 | uint32_t item_count = 1) override; |
96 | |
97 | lldb::addr_t GetLiveAddress() override { return m_impl.GetLiveAddress(); } |
98 | |
99 | void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS, |
100 | AddressType address_type = eAddressTypeLoad) override { |
101 | m_impl.SetLiveAddress(addr, address_type); |
102 | } |
103 | |
104 | lldb::ValueObjectSP |
105 | GetDynamicValue(lldb::DynamicValueType valueType) override; |
106 | |
107 | lldb::LanguageType GetPreferredDisplayLanguage() override; |
108 | |
109 | lldb::ValueObjectSP DoCast(const CompilerType &compiler_type) override; |
110 | |
111 | protected: |
112 | bool UpdateValue() override; |
113 | |
114 | CompilerType GetCompilerTypeImpl() override; |
115 | |
116 | ConstString m_type_name; |
117 | std::optional<uint64_t> m_byte_size; |
118 | |
119 | ValueObjectConstResultImpl m_impl; |
120 | |
121 | private: |
122 | friend class ValueObjectConstResultImpl; |
123 | |
124 | ValueObjectConstResult(ExecutionContextScope *exe_scope, |
125 | ValueObjectManager &manager, |
126 | lldb::ByteOrder byte_order, uint32_t addr_byte_size, |
127 | lldb::addr_t address); |
128 | |
129 | ValueObjectConstResult(ExecutionContextScope *exe_scope, |
130 | ValueObjectManager &manager, |
131 | const CompilerType &compiler_type, ConstString name, |
132 | const DataExtractor &data, lldb::addr_t address); |
133 | |
134 | ValueObjectConstResult(ExecutionContextScope *exe_scope, |
135 | ValueObjectManager &manager, |
136 | const CompilerType &compiler_type, ConstString name, |
137 | const lldb::DataBufferSP &result_data_sp, |
138 | lldb::ByteOrder byte_order, uint32_t addr_size, |
139 | lldb::addr_t address); |
140 | |
141 | ValueObjectConstResult(ExecutionContextScope *exe_scope, |
142 | ValueObjectManager &manager, |
143 | const CompilerType &compiler_type, ConstString name, |
144 | lldb::addr_t address, AddressType address_type, |
145 | uint32_t addr_byte_size); |
146 | |
147 | ValueObjectConstResult(ExecutionContextScope *exe_scope, |
148 | ValueObjectManager &manager, const Value &value, |
149 | ConstString name, Module *module = nullptr); |
150 | |
151 | ValueObjectConstResult(ExecutionContextScope *exe_scope, |
152 | ValueObjectManager &manager, const Status &error); |
153 | |
154 | ValueObjectConstResult(const ValueObjectConstResult &) = delete; |
155 | const ValueObjectConstResult & |
156 | operator=(const ValueObjectConstResult &) = delete; |
157 | }; |
158 | |
159 | } // namespace lldb_private |
160 | |
161 | #endif // LLDB_CORE_VALUEOBJECTCONSTRESULT_H |
162 | |