[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBMemoryRegionInfoList.cpp
blob32a3afb84af0e172fb0351f5c22d2b599f65596b
1 //===-- SBMemoryRegionInfoList.cpp ------------------------------*- 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 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBMemoryRegionInfoList.h"
10 #include "SBReproducerPrivate.h"
11 #include "lldb/API/SBMemoryRegionInfo.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/Target/MemoryRegionInfo.h"
15 #include <vector>
17 using namespace lldb;
18 using namespace lldb_private;
20 class MemoryRegionInfoListImpl {
21 public:
22 MemoryRegionInfoListImpl() : m_regions() {}
24 MemoryRegionInfoListImpl(const MemoryRegionInfoListImpl &rhs)
25 : m_regions(rhs.m_regions) {}
27 MemoryRegionInfoListImpl &operator=(const MemoryRegionInfoListImpl &rhs) {
28 if (this == &rhs)
29 return *this;
30 m_regions = rhs.m_regions;
31 return *this;
34 size_t GetSize() const { return m_regions.size(); }
36 void Reserve(size_t capacity) { return m_regions.reserve(capacity); }
38 void Append(const MemoryRegionInfo &sb_region) {
39 m_regions.push_back(sb_region);
42 void Append(const MemoryRegionInfoListImpl &list) {
43 Reserve(GetSize() + list.GetSize());
45 for (const auto &val : list.m_regions)
46 Append(val);
49 void Clear() { m_regions.clear(); }
51 bool GetMemoryRegionInfoAtIndex(size_t index,
52 MemoryRegionInfo &region_info) {
53 if (index >= GetSize())
54 return false;
55 region_info = m_regions[index];
56 return true;
59 MemoryRegionInfos &Ref() { return m_regions; }
61 const MemoryRegionInfos &Ref() const { return m_regions; }
63 private:
64 MemoryRegionInfos m_regions;
67 MemoryRegionInfos &SBMemoryRegionInfoList::ref() { return m_opaque_up->Ref(); }
69 const MemoryRegionInfos &SBMemoryRegionInfoList::ref() const {
70 return m_opaque_up->Ref();
73 SBMemoryRegionInfoList::SBMemoryRegionInfoList()
74 : m_opaque_up(new MemoryRegionInfoListImpl()) {
75 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBMemoryRegionInfoList);
78 SBMemoryRegionInfoList::SBMemoryRegionInfoList(
79 const SBMemoryRegionInfoList &rhs)
80 : m_opaque_up(new MemoryRegionInfoListImpl(*rhs.m_opaque_up)) {
81 LLDB_RECORD_CONSTRUCTOR(SBMemoryRegionInfoList,
82 (const lldb::SBMemoryRegionInfoList &), rhs);
85 SBMemoryRegionInfoList::~SBMemoryRegionInfoList() {}
87 const SBMemoryRegionInfoList &SBMemoryRegionInfoList::
88 operator=(const SBMemoryRegionInfoList &rhs) {
89 LLDB_RECORD_METHOD(
90 const lldb::SBMemoryRegionInfoList &,
91 SBMemoryRegionInfoList, operator=,(const lldb::SBMemoryRegionInfoList &),
92 rhs);
94 if (this != &rhs) {
95 *m_opaque_up = *rhs.m_opaque_up;
97 return LLDB_RECORD_RESULT(*this);
100 uint32_t SBMemoryRegionInfoList::GetSize() const {
101 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBMemoryRegionInfoList, GetSize);
103 return m_opaque_up->GetSize();
106 bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex(
107 uint32_t idx, SBMemoryRegionInfo &region_info) {
108 LLDB_RECORD_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex,
109 (uint32_t, lldb::SBMemoryRegionInfo &), idx, region_info);
111 return m_opaque_up->GetMemoryRegionInfoAtIndex(idx, region_info.ref());
114 void SBMemoryRegionInfoList::Clear() {
115 LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfoList, Clear);
117 m_opaque_up->Clear();
120 void SBMemoryRegionInfoList::Append(SBMemoryRegionInfo &sb_region) {
121 LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append,
122 (lldb::SBMemoryRegionInfo &), sb_region);
124 m_opaque_up->Append(sb_region.ref());
127 void SBMemoryRegionInfoList::Append(SBMemoryRegionInfoList &sb_region_list) {
128 LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append,
129 (lldb::SBMemoryRegionInfoList &), sb_region_list);
131 m_opaque_up->Append(*sb_region_list);
134 const MemoryRegionInfoListImpl *SBMemoryRegionInfoList::operator->() const {
135 return m_opaque_up.get();
138 const MemoryRegionInfoListImpl &SBMemoryRegionInfoList::operator*() const {
139 assert(m_opaque_up.get());
140 return *m_opaque_up;
143 namespace lldb_private {
144 namespace repro {
146 template <>
147 void RegisterMethods<SBMemoryRegionInfoList>(Registry &R) {
148 LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList, ());
149 LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList,
150 (const lldb::SBMemoryRegionInfoList &));
151 LLDB_REGISTER_METHOD(
152 const lldb::SBMemoryRegionInfoList &,
153 SBMemoryRegionInfoList, operator=,(
154 const lldb::SBMemoryRegionInfoList &));
155 LLDB_REGISTER_METHOD_CONST(uint32_t, SBMemoryRegionInfoList, GetSize, ());
156 LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex,
157 (uint32_t, lldb::SBMemoryRegionInfo &));
158 LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Clear, ());
159 LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append,
160 (lldb::SBMemoryRegionInfo &));
161 LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append,
162 (lldb::SBMemoryRegionInfoList &));