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 
17 using namespace lldb;
18 using namespace lldb_private;
19 
21 public:
22  MemoryRegionInfoListImpl() : m_regions() {}
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 
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 
69  MemoryRegionInfos &Ref() { return m_regions; }
70 
71  const MemoryRegionInfos &Ref() const { return m_regions; }
72 
73 private:
75 };
76 
77 MemoryRegionInfos &SBMemoryRegionInfoList::ref() { return m_opaque_up->Ref(); }
78 
80  return m_opaque_up->Ref();
81 }
82 
84  : m_opaque_up(new MemoryRegionInfoListImpl()) {
85  LLDB_INSTRUMENT_VA(this);
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 }
Instrumentation.h
list
MATCHES FreeBSD list(APPEND FBSDKERNEL_LIBS kvm) endif() if(NOT FBSDKERNEL_LIBS) message(STATUS "Skipping FreeBSDKernel plugin due to missing libfbsdvmcore") return() endif() add_lldb_library(lldbPluginProcessFreeBSDKernel PLUGIN ProcessFreeBSDKernel.cpp RegisterContextFreeBSDKernel_arm64.cpp RegisterContextFreeBSDKernel_i386.cpp RegisterContextFreeBSDKernel_x86_64.cpp ThreadFreeBSDKernel.cpp LINK_LIBS lldbCore lldbTarget $
Definition: Plugins/Process/FreeBSDKernel/CMakeLists.txt:6
MemoryRegionInfoListImpl::Ref
MemoryRegionInfos & Ref()
Definition: SBMemoryRegionInfoList.cpp:69
lldb::SBMemoryRegionInfoList::operator=
const SBMemoryRegionInfoList & operator=(const SBMemoryRegionInfoList &rhs)
Definition: SBMemoryRegionInfoList.cpp:97
MemoryRegionInfoListImpl::MemoryRegionInfoListImpl
MemoryRegionInfoListImpl()
Definition: SBMemoryRegionInfoList.cpp:22
MemoryRegionInfoListImpl::Reserve
void Reserve(size_t capacity)
Definition: SBMemoryRegionInfoList.cpp:35
lldb::SBMemoryRegionInfoList::operator->
const MemoryRegionInfoListImpl * operator->() const
Definition: SBMemoryRegionInfoList.cpp:144
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb::SBMemoryRegionInfoList::GetSize
uint32_t GetSize() const
Definition: SBMemoryRegionInfoList.cpp:106
MemoryRegionInfoListImpl::Clear
void Clear()
Definition: SBMemoryRegionInfoList.cpp:48
lldb::SBMemoryRegionInfoList::ref
lldb_private::MemoryRegionInfos & ref()
Definition: SBMemoryRegionInfoList.cpp:77
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
SBMemoryRegionInfo.h
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:61
MemoryRegionInfoListImpl::Ref
const MemoryRegionInfos & Ref() const
Definition: SBMemoryRegionInfoList.cpp:71
lldb::SBMemoryRegionInfo::ref
lldb_private::MemoryRegionInfo & ref()
Definition: SBMemoryRegionInfo.cpp:80
lldb::SBMemoryRegionInfoList
Definition: SBMemoryRegionInfoList.h:18
SBStream.h
lldb::SBMemoryRegionInfoList::GetMemoryRegionContainingAddress
bool GetMemoryRegionContainingAddress(lldb::addr_t addr, SBMemoryRegionInfo &region_info)
Definition: SBMemoryRegionInfoList.cpp:112
MemoryRegionInfoListImpl::m_regions
MemoryRegionInfos m_regions
Definition: SBMemoryRegionInfoList.cpp:74
MemoryRegionInfo.h
MemoryRegionInfoListImpl
Definition: SBMemoryRegionInfoList.cpp:20
MemoryRegionInfoListImpl::GetMemoryRegionContainingAddress
bool GetMemoryRegionContainingAddress(lldb::addr_t addr, MemoryRegionInfo &region_info)
Definition: SBMemoryRegionInfoList.cpp:50
lldb::SBMemoryRegionInfoList::~SBMemoryRegionInfoList
~SBMemoryRegionInfoList()
lldb_private::MemoryRegionInfos
Definition: MemoryRegionInfo.h:172
SBMemoryRegionInfoList.h
lldb::SBMemoryRegionInfoList::Clear
void Clear()
Definition: SBMemoryRegionInfoList.cpp:126
lldb::SBMemoryRegionInfoList::operator*
const MemoryRegionInfoListImpl & operator*() const
Definition: SBMemoryRegionInfoList.cpp:148
lldb::SBMemoryRegionInfoList::SBMemoryRegionInfoList
SBMemoryRegionInfoList()
Definition: SBMemoryRegionInfoList.cpp:83
uint32_t
lldb::SBMemoryRegionInfoList::GetMemoryRegionAtIndex
bool GetMemoryRegionAtIndex(uint32_t idx, SBMemoryRegionInfo &region_info)
Definition: SBMemoryRegionInfoList.cpp:119
lldb::SBMemoryRegionInfo
Definition: SBMemoryRegionInfo.h:17
MemoryRegionInfoListImpl::GetSize
size_t GetSize() const
Definition: SBMemoryRegionInfoList.cpp:33
MemoryRegionInfoListImpl::Append
void Append(const MemoryRegionInfoListImpl &list)
Definition: SBMemoryRegionInfoList.cpp:41
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:132
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:98
MemoryRegionInfoListImpl::operator=
MemoryRegionInfoListImpl & operator=(const MemoryRegionInfoListImpl &rhs)
Definition: SBMemoryRegionInfoList.cpp:26
lldb
Definition: SBAddress.h:15
MemoryRegionInfoListImpl::Append
void Append(const MemoryRegionInfo &sb_region)
Definition: SBMemoryRegionInfoList.cpp:37