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 
10 #include "SBReproducerPrivate.h"
12 #include "lldb/API/SBStream.h"
14 
15 #include <vector>
16 
17 using namespace lldb;
18 using namespace lldb_private;
19 
21 public:
22  MemoryRegionInfoListImpl() : m_regions() {}
23 
25  : m_regions(rhs.m_regions) {}
26 
28  if (this == &rhs)
29  return *this;
30  m_regions = rhs.m_regions;
31  return *this;
32  }
33 
34  size_t GetSize() const { return m_regions.size(); }
35 
36  void Reserve(size_t capacity) { return m_regions.reserve(capacity); }
37 
38  void Append(const MemoryRegionInfo &sb_region) {
39  m_regions.push_back(sb_region);
40  }
41 
42  void Append(const MemoryRegionInfoListImpl &list) {
43  Reserve(GetSize() + list.GetSize());
44 
45  for (const auto &val : list.m_regions)
46  Append(val);
47  }
48 
49  void Clear() { m_regions.clear(); }
50 
52  MemoryRegionInfo &region_info) {
53  for (auto &region : m_regions) {
54  if (region.GetRange().Contains(addr)) {
55  region_info = region;
56  return true;
57  }
58  }
59  return false;
60  }
61 
62  bool GetMemoryRegionInfoAtIndex(size_t index,
63  MemoryRegionInfo &region_info) {
64  if (index >= GetSize())
65  return false;
66  region_info = m_regions[index];
67  return true;
68  }
69 
70  MemoryRegionInfos &Ref() { return m_regions; }
71 
72  const MemoryRegionInfos &Ref() const { return m_regions; }
73 
74 private:
76 };
77 
78 MemoryRegionInfos &SBMemoryRegionInfoList::ref() { return m_opaque_up->Ref(); }
79 
81  return m_opaque_up->Ref();
82 }
83 
85  : m_opaque_up(new MemoryRegionInfoListImpl()) {
87 }
88 
90  const SBMemoryRegionInfoList &rhs)
91  : m_opaque_up(new MemoryRegionInfoListImpl(*rhs.m_opaque_up)) {
93  (const lldb::SBMemoryRegionInfoList &), rhs);
94 }
95 
97 
103  rhs);
104 
105  if (this != &rhs) {
106  *m_opaque_up = *rhs.m_opaque_up;
107  }
108  return LLDB_RECORD_RESULT(*this);
109 }
110 
113 
114  return m_opaque_up->GetSize();
115 }
116 
118  lldb::addr_t addr, SBMemoryRegionInfo &region_info) {
121  (lldb::addr_t, lldb::SBMemoryRegionInfo &), addr, region_info);
122 
123  return m_opaque_up->GetMemoryRegionContainingAddress(addr, region_info.ref());
124 }
125 
127  uint32_t idx, SBMemoryRegionInfo &region_info) {
129  (uint32_t, lldb::SBMemoryRegionInfo &), idx, region_info);
130 
131  return m_opaque_up->GetMemoryRegionInfoAtIndex(idx, region_info.ref());
132 }
133 
136 
137  m_opaque_up->Clear();
138 }
139 
142  (lldb::SBMemoryRegionInfo &), sb_region);
143 
144  m_opaque_up->Append(sb_region.ref());
145 }
146 
149  (lldb::SBMemoryRegionInfoList &), sb_region_list);
150 
151  m_opaque_up->Append(*sb_region_list);
152 }
153 
155  return m_opaque_up.get();
156 }
157 
159  assert(m_opaque_up.get());
160  return *m_opaque_up;
161 }
162 
163 namespace lldb_private {
164 namespace repro {
165 
166 template <>
170  (const lldb::SBMemoryRegionInfoList &));
173  SBMemoryRegionInfoList, operator=,(
177  GetMemoryRegionContainingAddress,
179  LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex,
186 }
187 
188 }
189 }
MemoryRegionInfoListImpl::Ref
MemoryRegionInfos & Ref()
Definition: SBMemoryRegionInfoList.cpp:70
lldb::SBMemoryRegionInfoList::operator=
const SBMemoryRegionInfoList & operator=(const SBMemoryRegionInfoList &rhs)
Definition: SBMemoryRegionInfoList.cpp:99
MemoryRegionInfoListImpl::MemoryRegionInfoListImpl
MemoryRegionInfoListImpl()
Definition: SBMemoryRegionInfoList.cpp:22
LLDB_RECORD_RESULT
#define LLDB_RECORD_RESULT(Result)
Definition: ReproducerInstrumentation.h:211
LLDB_RECORD_METHOD_CONST_NO_ARGS
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:168
MemoryRegionInfoListImpl::Reserve
void Reserve(size_t capacity)
Definition: SBMemoryRegionInfoList.cpp:36
LLDB_RECORD_METHOD_NO_ARGS
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:165
LLDB_RECORD_CONSTRUCTOR_NO_ARGS
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
Definition: ReproducerInstrumentation.h:136
lldb::SBMemoryRegionInfoList::operator->
const MemoryRegionInfoListImpl * operator->() const
Definition: SBMemoryRegionInfoList.cpp:154
LLDB_REGISTER_METHOD_CONST
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:98
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb::SBMemoryRegionInfoList::GetSize
uint32_t GetSize() const
Definition: SBMemoryRegionInfoList.cpp:111
MemoryRegionInfoListImpl::Clear
void Clear()
Definition: SBMemoryRegionInfoList.cpp:49
lldb::SBMemoryRegionInfoList::ref
lldb_private::MemoryRegionInfos & ref()
Definition: SBMemoryRegionInfoList.cpp:78
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
SBReproducerPrivate.h
SBMemoryRegionInfo.h
LLDB_REGISTER_CONSTRUCTOR
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
Definition: ReproducerInstrumentation.h:89
lldb::SBMemoryRegionInfoList::m_opaque_up
std::unique_ptr< MemoryRegionInfoListImpl > m_opaque_up
Definition: SBMemoryRegionInfoList.h:53
MemoryRegionInfoListImpl::GetMemoryRegionInfoAtIndex
bool GetMemoryRegionInfoAtIndex(size_t index, MemoryRegionInfo &region_info)
Definition: SBMemoryRegionInfoList.cpp:62
MemoryRegionInfoListImpl::Ref
const MemoryRegionInfos & Ref() const
Definition: SBMemoryRegionInfoList.cpp:72
lldb::SBMemoryRegionInfo::ref
lldb_private::MemoryRegionInfo & ref()
Definition: SBMemoryRegionInfo.cpp:91
lldb::SBMemoryRegionInfoList
Definition: SBMemoryRegionInfoList.h:18
SBStream.h
lldb::SBMemoryRegionInfoList::GetMemoryRegionContainingAddress
bool GetMemoryRegionContainingAddress(lldb::addr_t addr, SBMemoryRegionInfo &region_info)
Definition: SBMemoryRegionInfoList.cpp:117
MemoryRegionInfoListImpl::m_regions
MemoryRegionInfos m_regions
Definition: SBMemoryRegionInfoList.cpp:75
LLDB_RECORD_METHOD
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
Definition: ReproducerInstrumentation.h:158
MemoryRegionInfo.h
MemoryRegionInfoListImpl
Definition: SBMemoryRegionInfoList.cpp:20
MemoryRegionInfoListImpl::GetMemoryRegionContainingAddress
bool GetMemoryRegionContainingAddress(lldb::addr_t addr, MemoryRegionInfo &region_info)
Definition: SBMemoryRegionInfoList.cpp:51
lldb::SBMemoryRegionInfoList::~SBMemoryRegionInfoList
~SBMemoryRegionInfoList()
lldb_private::MemoryRegionInfos
Definition: MemoryRegionInfo.h:164
SBMemoryRegionInfoList.h
LLDB_RECORD_CONSTRUCTOR
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
Definition: ReproducerInstrumentation.h:133
lldb::SBMemoryRegionInfoList::Clear
void Clear()
Definition: SBMemoryRegionInfoList.cpp:134
lldb::SBMemoryRegionInfoList::operator*
const MemoryRegionInfoListImpl & operator*() const
Definition: SBMemoryRegionInfoList.cpp:158
lldb_private::repro::Registry
The registry contains a unique mapping between functions and their ID.
Definition: ReproducerInstrumentation.h:517
lldb::SBMemoryRegionInfoList::SBMemoryRegionInfoList
SBMemoryRegionInfoList()
Definition: SBMemoryRegionInfoList.cpp:84
uint32_t
lldb::SBMemoryRegionInfoList::GetMemoryRegionAtIndex
bool GetMemoryRegionAtIndex(uint32_t idx, SBMemoryRegionInfo &region_info)
Definition: SBMemoryRegionInfoList.cpp:126
MemoryRegionInfoListImpl::MemoryRegionInfoListImpl
MemoryRegionInfoListImpl(const MemoryRegionInfoListImpl &rhs)
Definition: SBMemoryRegionInfoList.cpp:24
lldb::SBMemoryRegionInfo
Definition: SBMemoryRegionInfo.h:17
MemoryRegionInfoListImpl::GetSize
size_t GetSize() const
Definition: SBMemoryRegionInfoList.cpp:34
MemoryRegionInfoListImpl::Append
void Append(const MemoryRegionInfoListImpl &list)
Definition: SBMemoryRegionInfoList.cpp:42
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::SBMemoryRegionInfoList::Append
void Append(lldb::SBMemoryRegionInfo &region)
Definition: SBMemoryRegionInfoList.cpp:140
lldb_private::repro::RegisterMethods< SBMemoryRegionInfoList >
void RegisterMethods< SBMemoryRegionInfoList >(Registry &R)
Definition: SBMemoryRegionInfoList.cpp:167
MemoryRegionInfoListImpl::operator=
MemoryRegionInfoListImpl & operator=(const MemoryRegionInfoListImpl &rhs)
Definition: SBMemoryRegionInfoList.cpp:27
lldb
Definition: SBAddress.h:15
MemoryRegionInfoListImpl::Append
void Append(const MemoryRegionInfo &sb_region)
Definition: SBMemoryRegionInfoList.cpp:38
LLDB_REGISTER_METHOD
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:93