1//===-- ValueObjectConstResultImpl.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_ValueObjectConstResultImpl_h_
10#define liblldb_ValueObjectConstResultImpl_h_
11
12#include "lldb/Utility/ConstString.h"
13#include "lldb/lldb-defines.h"
14#include "lldb/lldb-forward.h"
15#include "lldb/lldb-private-enumerations.h"
16#include "lldb/lldb-types.h"
17
18#include <stddef.h>
19#include <stdint.h>
20namespace lldb_private {
21class CompilerType;
22class DataExtractor;
23class Status;
24class ValueObject;
25}
26
27namespace lldb_private {
28
29// A class wrapping common implementation details for operations in
30// ValueObjectConstResult ( & Child ) that may need to jump from the host
31// memory space into the target's memory space
32class ValueObjectConstResultImpl {
33public:
34  ValueObjectConstResultImpl(ValueObject *valobj,
35                             lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
36
37  virtual ~ValueObjectConstResultImpl() = default;
38
39  lldb::ValueObjectSP Dereference(Status &error);
40
41  ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
42                                  int32_t synthetic_index);
43
44  lldb::ValueObjectSP
45  GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
46                            bool can_create,
47                            ConstString name_const_str = ConstString());
48
49  lldb::ValueObjectSP AddressOf(Status &error);
50
51  lldb::addr_t GetLiveAddress() { return m_live_address; }
52
53  lldb::ValueObjectSP Cast(const CompilerType &compiler_type);
54
55  void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
56                      AddressType address_type = eAddressTypeLoad) {
57    m_live_address = addr;
58    m_live_address_type = address_type;
59  }
60
61  virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
62                                    AddressType *address_type = nullptr);
63
64  virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
65                                uint32_t item_count = 1);
66
67private:
68  ValueObject *m_impl_backend;
69  lldb::addr_t m_live_address;
70  AddressType m_live_address_type;
71  lldb::ValueObjectSP m_load_addr_backend;
72  lldb::ValueObjectSP m_address_of_backend;
73
74  DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultImpl);
75};
76
77} // namespace lldb_private
78
79#endif // liblldb_ValueObjectConstResultImpl_h_
80