2016-06-23 16:35:37 +08:00
|
|
|
//===-- SBMemoryRegionInfoList.cpp ------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-06-23 16:35:37 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBMemoryRegionInfoList.h"
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2017-03-04 04:56:28 +08:00
|
|
|
#include "lldb/API/SBMemoryRegionInfo.h"
|
2016-06-23 16:35:37 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
|
|
|
#include "lldb/Target/MemoryRegionInfo.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
class MemoryRegionInfoListImpl {
|
|
|
|
public:
|
|
|
|
MemoryRegionInfoListImpl() : m_regions() {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-06-23 16:35:37 +08:00
|
|
|
MemoryRegionInfoListImpl(const MemoryRegionInfoListImpl &rhs)
|
|
|
|
: m_regions(rhs.m_regions) {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-06-23 16:35:37 +08:00
|
|
|
MemoryRegionInfoListImpl &operator=(const MemoryRegionInfoListImpl &rhs) {
|
|
|
|
if (this == &rhs)
|
|
|
|
return *this;
|
|
|
|
m_regions = rhs.m_regions;
|
|
|
|
return *this;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-12-20 23:02:58 +08:00
|
|
|
size_t GetSize() const { return m_regions.size(); }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-12-20 23:02:58 +08:00
|
|
|
void Reserve(size_t capacity) { return m_regions.reserve(capacity); }
|
|
|
|
|
|
|
|
void Append(const MemoryRegionInfo &sb_region) {
|
2016-06-23 16:35:37 +08:00
|
|
|
m_regions.push_back(sb_region);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-06-23 16:35:37 +08:00
|
|
|
void Append(const MemoryRegionInfoListImpl &list) {
|
2018-12-20 23:02:58 +08:00
|
|
|
Reserve(GetSize() + list.GetSize());
|
|
|
|
|
|
|
|
for (const auto &val : list.m_regions)
|
2016-06-23 16:35:37 +08:00
|
|
|
Append(val);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-06-23 16:35:37 +08:00
|
|
|
void Clear() { m_regions.clear(); }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-12-20 23:02:58 +08:00
|
|
|
bool GetMemoryRegionInfoAtIndex(size_t index,
|
|
|
|
MemoryRegionInfo ®ion_info) {
|
2016-06-23 16:35:37 +08:00
|
|
|
if (index >= GetSize())
|
|
|
|
return false;
|
|
|
|
region_info = m_regions[index];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-12-20 23:02:58 +08:00
|
|
|
MemoryRegionInfos &Ref() { return m_regions; }
|
|
|
|
|
|
|
|
const MemoryRegionInfos &Ref() const { return m_regions; }
|
|
|
|
|
2016-06-23 16:35:37 +08:00
|
|
|
private:
|
2018-12-20 23:02:58 +08:00
|
|
|
MemoryRegionInfos m_regions;
|
2016-06-23 16:35:37 +08:00
|
|
|
};
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
MemoryRegionInfos &SBMemoryRegionInfoList::ref() { return m_opaque_up->Ref(); }
|
2018-12-20 23:02:58 +08:00
|
|
|
|
|
|
|
const MemoryRegionInfos &SBMemoryRegionInfoList::ref() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up->Ref();
|
2018-12-20 23:02:58 +08:00
|
|
|
}
|
|
|
|
|
2016-06-23 16:35:37 +08:00
|
|
|
SBMemoryRegionInfoList::SBMemoryRegionInfoList()
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_up(new MemoryRegionInfoListImpl()) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBMemoryRegionInfoList);
|
|
|
|
}
|
2016-06-23 16:35:37 +08:00
|
|
|
|
|
|
|
SBMemoryRegionInfoList::SBMemoryRegionInfoList(
|
|
|
|
const SBMemoryRegionInfoList &rhs)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_up(new MemoryRegionInfoListImpl(*rhs.m_opaque_up)) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBMemoryRegionInfoList,
|
|
|
|
(const lldb::SBMemoryRegionInfoList &), rhs);
|
|
|
|
}
|
2016-06-23 16:35:37 +08:00
|
|
|
|
|
|
|
SBMemoryRegionInfoList::~SBMemoryRegionInfoList() {}
|
|
|
|
|
|
|
|
const SBMemoryRegionInfoList &SBMemoryRegionInfoList::
|
|
|
|
operator=(const SBMemoryRegionInfoList &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
const lldb::SBMemoryRegionInfoList &,
|
|
|
|
SBMemoryRegionInfoList, operator=,(const lldb::SBMemoryRegionInfoList &),
|
|
|
|
rhs);
|
|
|
|
|
2016-06-23 16:35:37 +08:00
|
|
|
if (this != &rhs) {
|
2019-02-13 14:25:41 +08:00
|
|
|
*m_opaque_up = *rhs.m_opaque_up;
|
2016-06-23 16:35:37 +08:00
|
|
|
}
|
2019-04-04 05:31:22 +08:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2016-06-23 16:35:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBMemoryRegionInfoList::GetSize() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBMemoryRegionInfoList, GetSize);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up->GetSize();
|
2016-06-23 16:35:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex(
|
|
|
|
uint32_t idx, SBMemoryRegionInfo ®ion_info) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex,
|
|
|
|
(uint32_t, lldb::SBMemoryRegionInfo &), idx, region_info);
|
|
|
|
|
2019-03-08 06:47:13 +08:00
|
|
|
return m_opaque_up->GetMemoryRegionInfoAtIndex(idx, region_info.ref());
|
2016-06-23 16:35:37 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBMemoryRegionInfoList::Clear() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfoList, Clear);
|
|
|
|
|
|
|
|
m_opaque_up->Clear();
|
|
|
|
}
|
2016-06-23 16:35:37 +08:00
|
|
|
|
|
|
|
void SBMemoryRegionInfoList::Append(SBMemoryRegionInfo &sb_region) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append,
|
|
|
|
(lldb::SBMemoryRegionInfo &), sb_region);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->Append(sb_region.ref());
|
2016-06-23 16:35:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBMemoryRegionInfoList::Append(SBMemoryRegionInfoList &sb_region_list) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append,
|
|
|
|
(lldb::SBMemoryRegionInfoList &), sb_region_list);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->Append(*sb_region_list);
|
2016-06-23 16:35:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const MemoryRegionInfoListImpl *SBMemoryRegionInfoList::operator->() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up.get();
|
2016-06-23 16:35:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const MemoryRegionInfoListImpl &SBMemoryRegionInfoList::operator*() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
assert(m_opaque_up.get());
|
|
|
|
return *m_opaque_up;
|
2016-06-23 16:35:37 +08:00
|
|
|
}
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBMemoryRegionInfoList>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList,
|
|
|
|
(const lldb::SBMemoryRegionInfoList &));
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
const lldb::SBMemoryRegionInfoList &,
|
|
|
|
SBMemoryRegionInfoList, operator=,(
|
|
|
|
const lldb::SBMemoryRegionInfoList &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint32_t, SBMemoryRegionInfoList, GetSize, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex,
|
|
|
|
(uint32_t, lldb::SBMemoryRegionInfo &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Clear, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append,
|
|
|
|
(lldb::SBMemoryRegionInfo &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append,
|
|
|
|
(lldb::SBMemoryRegionInfoList &));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|