LLDB mainline
SBMemoryRegionInfoList.cpp
Go to the documentation of this file.
1//===-- SBMemoryRegionInfoList.cpp ----------------------------------------===//
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
11#include "lldb/API/SBStream.h"
14
15#include <vector>
16
17using namespace lldb;
18using namespace lldb_private;
19
21public:
23
25
27 if (this == &rhs)
28 return *this;
29 m_regions = rhs.m_regions;
30 return *this;
31 }
32
33 size_t GetSize() const { return m_regions.size(); }
34
35 void Reserve(size_t capacity) { return m_regions.reserve(capacity); }
36
37 void Append(const MemoryRegionInfo &sb_region) {
38 m_regions.push_back(sb_region);
39 }
40
41 void Append(const MemoryRegionInfoListImpl &list) {
42 Reserve(GetSize() + list.GetSize());
43
44 for (const auto &val : list.m_regions)
45 Append(val);
46 }
47
48 void Clear() { m_regions.clear(); }
49
51 MemoryRegionInfo &region_info) {
52 for (auto &region : m_regions) {
53 if (region.GetRange().Contains(addr)) {
54 region_info = region;
55 return true;
56 }
57 }
58 return false;
59 }
60
61 bool GetMemoryRegionInfoAtIndex(size_t index,
62 MemoryRegionInfo &region_info) {
63 if (index >= GetSize())
64 return false;
65 region_info = m_regions[index];
66 return true;
67 }
68
70
71 const MemoryRegionInfos &Ref() const { return m_regions; }
72
73private:
75};
76
78
80 return m_opaque_up->Ref();
81}
82
84 : m_opaque_up(new MemoryRegionInfoListImpl()) {
86}
87
89 const SBMemoryRegionInfoList &rhs)
90 : m_opaque_up(new MemoryRegionInfoListImpl(*rhs.m_opaque_up)) {
91 LLDB_INSTRUMENT_VA(this, rhs);
92}
93
95
98 LLDB_INSTRUMENT_VA(this, rhs);
99
100 if (this != &rhs) {
101 *m_opaque_up = *rhs.m_opaque_up;
102 }
103 return *this;
104}
105
107 LLDB_INSTRUMENT_VA(this);
108
109 return m_opaque_up->GetSize();
110}
111
113 lldb::addr_t addr, SBMemoryRegionInfo &region_info) {
114 LLDB_INSTRUMENT_VA(this, addr, region_info);
115
116 return m_opaque_up->GetMemoryRegionContainingAddress(addr, region_info.ref());
117}
118
120 uint32_t idx, SBMemoryRegionInfo &region_info) {
121 LLDB_INSTRUMENT_VA(this, idx, region_info);
122
123 return m_opaque_up->GetMemoryRegionInfoAtIndex(idx, region_info.ref());
124}
125
127 LLDB_INSTRUMENT_VA(this);
128
129 m_opaque_up->Clear();
130}
131
133 LLDB_INSTRUMENT_VA(this, sb_region);
134
135 m_opaque_up->Append(sb_region.ref());
136}
137
139 LLDB_INSTRUMENT_VA(this, sb_region_list);
140
141 m_opaque_up->Append(*sb_region_list);
142}
143
145 return m_opaque_up.get();
146}
147
149 assert(m_opaque_up.get());
150 return *m_opaque_up;
151}
#define LLDB_INSTRUMENT_VA(...)
bool GetMemoryRegionContainingAddress(lldb::addr_t addr, MemoryRegionInfo &region_info)
MemoryRegionInfoListImpl & operator=(const MemoryRegionInfoListImpl &rhs)
bool GetMemoryRegionInfoAtIndex(size_t index, MemoryRegionInfo &region_info)
const MemoryRegionInfos & Ref() const
void Append(const MemoryRegionInfoListImpl &list)
MemoryRegionInfoListImpl(const MemoryRegionInfoListImpl &rhs)=default
void Append(const MemoryRegionInfo &sb_region)
const MemoryRegionInfoListImpl & operator*() const
std::unique_ptr< MemoryRegionInfoListImpl > m_opaque_up
const SBMemoryRegionInfoList & operator=(const SBMemoryRegionInfoList &rhs)
const MemoryRegionInfoListImpl * operator->() const
bool GetMemoryRegionAtIndex(uint32_t idx, SBMemoryRegionInfo &region_info)
bool GetMemoryRegionContainingAddress(lldb::addr_t addr, SBMemoryRegionInfo &region_info)
lldb_private::MemoryRegionInfos & ref()
void Append(lldb::SBMemoryRegionInfo &region)
lldb_private::MemoryRegionInfo & ref()
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
uint64_t addr_t
Definition: lldb-types.h:80