1 //===-- ValueObjectConstResult.h --------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_ValueObjectConstResult_h_
10 #define liblldb_ValueObjectConstResult_h_
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"
27 namespace lldb_private {
29 class ExecutionContextScope;
32 // A frozen ValueObject copied into host memory
33 class ValueObjectConstResult : public ValueObject {
35 ~ValueObjectConstResult() override;
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);
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);
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);
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);
57 static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
58 Value &value, ConstString name,
59 Module *module = nullptr);
61 // When an expression fails to evaluate, we return an error
62 static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
65 uint64_t GetByteSize() override;
67 lldb::ValueType GetValueType() const override;
69 size_t CalculateNumChildren(uint32_t max) override;
71 ConstString GetTypeName() override;
73 ConstString GetDisplayTypeName() override;
75 bool IsInScope() override;
77 void SetByteSize(size_t size);
79 lldb::ValueObjectSP Dereference(Status &error) override;
81 ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
82 int32_t synthetic_index) override;
84 lldb::ValueObjectSP GetSyntheticChildAtOffset(
85 uint32_t offset, const CompilerType &type, bool can_create,
86 ConstString name_const_str = ConstString()) override;
88 lldb::ValueObjectSP AddressOf(Status &error) override;
90 lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
91 AddressType *address_type = nullptr) override;
93 size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
94 uint32_t item_count = 1) override;
96 lldb::addr_t GetLiveAddress() override { return m_impl.GetLiveAddress(); }
98 void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
99 AddressType address_type = eAddressTypeLoad) override {
100 m_impl.SetLiveAddress(addr, address_type);
104 GetDynamicValue(lldb::DynamicValueType valueType) override;
106 lldb::LanguageType GetPreferredDisplayLanguage() override;
108 lldb::ValueObjectSP Cast(const CompilerType &compiler_type) override;
111 bool UpdateValue() override;
113 CompilerType GetCompilerTypeImpl() override;
115 ConstString m_type_name;
116 uint64_t m_byte_size;
118 ValueObjectConstResultImpl m_impl;
121 friend class ValueObjectConstResultImpl;
123 ValueObjectConstResult(ExecutionContextScope *exe_scope,
124 lldb::ByteOrder byte_order, uint32_t addr_byte_size,
125 lldb::addr_t address);
127 ValueObjectConstResult(ExecutionContextScope *exe_scope,
128 const CompilerType &compiler_type,
129 ConstString name, const DataExtractor &data,
130 lldb::addr_t address);
132 ValueObjectConstResult(ExecutionContextScope *exe_scope,
133 const CompilerType &compiler_type,
135 const lldb::DataBufferSP &result_data_sp,
136 lldb::ByteOrder byte_order, uint32_t addr_size,
137 lldb::addr_t address);
139 ValueObjectConstResult(ExecutionContextScope *exe_scope,
140 const CompilerType &compiler_type,
141 ConstString name, lldb::addr_t address,
142 AddressType address_type, uint32_t addr_byte_size);
144 ValueObjectConstResult(ExecutionContextScope *exe_scope, const Value &value,
145 ConstString name, Module *module = nullptr);
147 ValueObjectConstResult(ExecutionContextScope *exe_scope, const Status &error);
149 DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResult);
152 } // namespace lldb_private
154 #endif // liblldb_ValueObjectConstResult_h_