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 <stddef.h>
25#include <stdint.h>
26
27namespace lldb_private {
28class DataExtractor;
29class ExecutionContextScope;
30class Module;
31
32/// A frozen ValueObject copied into host memory.
33class ValueObjectConstResult : public ValueObject {
34public:
35 ~ValueObjectConstResult() override;
36
37 static lldb::ValueObjectSP
38 Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order,
39 uint32_t addr_byte_size, lldb::addr_t address = LLDB_INVALID_ADDRESS);
40
41 static lldb::ValueObjectSP
42 Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
43 ConstString name, const DataExtractor &data,
44 lldb::addr_t address = LLDB_INVALID_ADDRESS);
45
46 static lldb::ValueObjectSP
47 Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
48 ConstString name, const lldb::DataBufferSP &result_data_sp,
49 lldb::ByteOrder byte_order, uint32_t addr_size,
50 lldb::addr_t address = LLDB_INVALID_ADDRESS);
51
52 static lldb::ValueObjectSP
53 Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
54 ConstString name, lldb::addr_t address,
55 AddressType address_type, uint32_t addr_byte_size);
56
57 static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
58 Value &value, ConstString name,
59 Module *module = nullptr);
60
61 // When an expression fails to evaluate, we return an error
62 static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
63 const Status &error);
64
65 llvm::Optional<uint64_t> GetByteSize() override;
66
67 lldb::ValueType GetValueType() const override;
68
69 size_t CalculateNumChildren(uint32_t max) override;
70
71 ConstString GetTypeName() override;
72
73 ConstString GetDisplayTypeName() override;
74
75 bool IsInScope() override;
76
77 void SetByteSize(size_t size);
78
79 lldb::ValueObjectSP Dereference(Status &error) override;
80
81 ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
82 int32_t synthetic_index) override;
83
84 lldb::ValueObjectSP GetSyntheticChildAtOffset(
85 uint32_t offset, const CompilerType &type, bool can_create,
86 ConstString name_const_str = ConstString()) override;
87
88 lldb::ValueObjectSP AddressOf(Status &error) override;
89
90 lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
91 AddressType *address_type = nullptr) override;
92
93 size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
94 uint32_t item_count = 1) override;
95
96 lldb::addr_t GetLiveAddress() override { return m_impl.GetLiveAddress(); }
97
98 void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
99 AddressType address_type = eAddressTypeLoad) override {
100 m_impl.SetLiveAddress(addr, address_type);
101 }
102
103 lldb::ValueObjectSP
104 GetDynamicValue(lldb::DynamicValueType valueType) override;
105
106 lldb::LanguageType GetPreferredDisplayLanguage() override;
107
108 lldb::ValueObjectSP Cast(const CompilerType &compiler_type) override;
109
110protected:
111 bool UpdateValue() override;
112
113 CompilerType GetCompilerTypeImpl() override;
114
115 ConstString m_type_name;
116 llvm::Optional<uint64_t> m_byte_size;
117
118 ValueObjectConstResultImpl m_impl;
119
120private:
121 friend class ValueObjectConstResultImpl;
122
123 ValueObjectConstResult(ExecutionContextScope *exe_scope,
124 ValueObjectManager &manager,
125 lldb::ByteOrder byte_order, uint32_t addr_byte_size,
126 lldb::addr_t address);
127
128 ValueObjectConstResult(ExecutionContextScope *exe_scope,
129 ValueObjectManager &manager,
130 const CompilerType &compiler_type, ConstString name,
131 const DataExtractor &data, lldb::addr_t address);
132
133 ValueObjectConstResult(ExecutionContextScope *exe_scope,
134 ValueObjectManager &manager,
135 const CompilerType &compiler_type, ConstString name,
136 const lldb::DataBufferSP &result_data_sp,
137 lldb::ByteOrder byte_order, uint32_t addr_size,
138 lldb::addr_t address);
139
140 ValueObjectConstResult(ExecutionContextScope *exe_scope,
141 ValueObjectManager &manager,
142 const CompilerType &compiler_type, ConstString name,
143 lldb::addr_t address, AddressType address_type,
144 uint32_t addr_byte_size);
145
146 ValueObjectConstResult(ExecutionContextScope *exe_scope,
147 ValueObjectManager &manager, const Value &value,
148 ConstString name, Module *module = nullptr);
149
150 ValueObjectConstResult(ExecutionContextScope *exe_scope,
151 ValueObjectManager &manager, const Status &error);
152
153 ValueObjectConstResult(const ValueObjectConstResult &) = delete;
154 const ValueObjectConstResult &
155 operator=(const ValueObjectConstResult &) = delete;
156};
157
158} // namespace lldb_private
159
160#endif // LLDB_CORE_VALUEOBJECTCONSTRESULT_H
161