Path: blob/main/contrib/llvm-project/lldb/source/API/SBAddressRangeList.cpp
39587 views
//===-- SBAddressRangeList.cpp --------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/API/SBAddressRangeList.h"9#include "Utils.h"10#include "lldb/API/SBAddressRange.h"11#include "lldb/API/SBStream.h"12#include "lldb/API/SBTarget.h"13#include "lldb/Core/AddressRangeListImpl.h"14#include "lldb/Utility/Instrumentation.h"15#include "lldb/Utility/Stream.h"1617#include <memory>1819using namespace lldb;20using namespace lldb_private;2122SBAddressRangeList::SBAddressRangeList()23: m_opaque_up(std::make_unique<AddressRangeListImpl>()) {24LLDB_INSTRUMENT_VA(this);25}2627SBAddressRangeList::SBAddressRangeList(const SBAddressRangeList &rhs)28: m_opaque_up(std::make_unique<AddressRangeListImpl>(*rhs.m_opaque_up)) {29LLDB_INSTRUMENT_VA(this, rhs);30}3132SBAddressRangeList::~SBAddressRangeList() = default;3334const SBAddressRangeList &35SBAddressRangeList::operator=(const SBAddressRangeList &rhs) {36LLDB_INSTRUMENT_VA(this, rhs);3738if (this != &rhs)39ref() = rhs.ref();40return *this;41}4243uint32_t SBAddressRangeList::GetSize() const {44LLDB_INSTRUMENT_VA(this);4546return ref().GetSize();47}4849SBAddressRange SBAddressRangeList::GetAddressRangeAtIndex(uint64_t idx) {50LLDB_INSTRUMENT_VA(this, idx);5152SBAddressRange sb_addr_range;53(*sb_addr_range.m_opaque_up) = ref().GetAddressRangeAtIndex(idx);54return sb_addr_range;55}5657void SBAddressRangeList::Clear() {58LLDB_INSTRUMENT_VA(this);5960ref().Clear();61}6263void SBAddressRangeList::Append(const SBAddressRange &sb_addr_range) {64LLDB_INSTRUMENT_VA(this, sb_addr_range);6566ref().Append(*sb_addr_range.m_opaque_up);67}6869void SBAddressRangeList::Append(const SBAddressRangeList &sb_addr_range_list) {70LLDB_INSTRUMENT_VA(this, sb_addr_range_list);7172ref().Append(*sb_addr_range_list.m_opaque_up);73}7475bool SBAddressRangeList::GetDescription(SBStream &description,76const SBTarget &target) {77LLDB_INSTRUMENT_VA(this, description, target);7879const uint32_t num_ranges = GetSize();80bool is_first = true;81Stream &stream = description.ref();82stream << "[";83for (uint32_t i = 0; i < num_ranges; ++i) {84if (is_first) {85is_first = false;86} else {87stream.Printf(", ");88}89GetAddressRangeAtIndex(i).GetDescription(description, target);90}91stream << "]";92return true;93}9495lldb_private::AddressRangeListImpl &SBAddressRangeList::ref() const {96assert(m_opaque_up && "opaque pointer must always be valid");97return *m_opaque_up;98}99100101