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 liblldb_ValueObjectConstResult_h_ 10#define liblldb_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 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 uint64_t m_byte_size; 117 118 ValueObjectConstResultImpl m_impl; 119 120private: 121 friend class ValueObjectConstResultImpl; 122 123 ValueObjectConstResult(ExecutionContextScope *exe_scope, 124 lldb::ByteOrder byte_order, uint32_t addr_byte_size, 125 lldb::addr_t address); 126 127 ValueObjectConstResult(ExecutionContextScope *exe_scope, 128 const CompilerType &compiler_type, 129 ConstString name, const DataExtractor &data, 130 lldb::addr_t address); 131 132 ValueObjectConstResult(ExecutionContextScope *exe_scope, 133 const CompilerType &compiler_type, 134 ConstString name, 135 const lldb::DataBufferSP &result_data_sp, 136 lldb::ByteOrder byte_order, uint32_t addr_size, 137 lldb::addr_t address); 138 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); 143 144 ValueObjectConstResult(ExecutionContextScope *exe_scope, const Value &value, 145 ConstString name, Module *module = nullptr); 146 147 ValueObjectConstResult(ExecutionContextScope *exe_scope, const Status &error); 148 149 DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResult); 150}; 151 152} // namespace lldb_private 153 154#endif // liblldb_ValueObjectConstResult_h_ 155