1 //===-- SBMemoryRegionInfoList.cpp ------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SBMemoryRegionInfo.h"
11 #include "lldb/API/SBMemoryRegionInfoList.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/Core/Log.h"
14 #include "lldb/Target/MemoryRegionInfo.h"
19 using namespace lldb_private;
21 class MemoryRegionInfoListImpl {
23 MemoryRegionInfoListImpl() : m_regions() {}
25 MemoryRegionInfoListImpl(const MemoryRegionInfoListImpl &rhs)
26 : m_regions(rhs.m_regions) {}
28 MemoryRegionInfoListImpl &operator=(const MemoryRegionInfoListImpl &rhs) {
31 m_regions = rhs.m_regions;
35 uint32_t GetSize() { return m_regions.size(); }
37 void Append(const lldb::SBMemoryRegionInfo &sb_region) {
38 m_regions.push_back(sb_region);
41 void Append(const MemoryRegionInfoListImpl &list) {
42 for (auto val : list.m_regions)
46 void Clear() { m_regions.clear(); }
48 bool GetMemoryRegionInfoAtIndex(uint32_t index,
49 SBMemoryRegionInfo ®ion_info) {
50 if (index >= GetSize())
52 region_info = m_regions[index];
57 std::vector<lldb::SBMemoryRegionInfo> m_regions;
60 SBMemoryRegionInfoList::SBMemoryRegionInfoList()
61 : m_opaque_ap(new MemoryRegionInfoListImpl()) {}
63 SBMemoryRegionInfoList::SBMemoryRegionInfoList(
64 const SBMemoryRegionInfoList &rhs)
65 : m_opaque_ap(new MemoryRegionInfoListImpl(*rhs.m_opaque_ap)) {}
67 SBMemoryRegionInfoList::~SBMemoryRegionInfoList() {}
69 const SBMemoryRegionInfoList &SBMemoryRegionInfoList::
70 operator=(const SBMemoryRegionInfoList &rhs) {
72 *m_opaque_ap = *rhs.m_opaque_ap;
77 uint32_t SBMemoryRegionInfoList::GetSize() const {
78 return m_opaque_ap->GetSize();
81 bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex(
82 uint32_t idx, SBMemoryRegionInfo ®ion_info) {
83 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
85 bool result = m_opaque_ap->GetMemoryRegionInfoAtIndex(idx, region_info);
89 region_info.GetDescription(sstr);
90 log->Printf("SBMemoryRegionInfoList::GetMemoryRegionAtIndex (this.ap=%p, "
91 "idx=%d) => SBMemoryRegionInfo (this.ap=%p, '%s')",
92 static_cast<void *>(m_opaque_ap.get()), idx,
93 static_cast<void *>(region_info.m_opaque_ap.get()),
100 void SBMemoryRegionInfoList::Clear() { m_opaque_ap->Clear(); }
102 void SBMemoryRegionInfoList::Append(SBMemoryRegionInfo &sb_region) {
103 m_opaque_ap->Append(sb_region);
106 void SBMemoryRegionInfoList::Append(SBMemoryRegionInfoList &sb_region_list) {
107 m_opaque_ap->Append(*sb_region_list);
110 const MemoryRegionInfoListImpl *SBMemoryRegionInfoList::operator->() const {
111 return m_opaque_ap.get();
114 const MemoryRegionInfoListImpl &SBMemoryRegionInfoList::operator*() const {
115 assert(m_opaque_ap.get());
116 return *m_opaque_ap.get();