Path: blob/main/contrib/llvm-project/lldb/source/API/SBAddressRange.cpp
39587 views
//===-- SBAddressRange.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/SBAddressRange.h"9#include "Utils.h"10#include "lldb/API/SBAddress.h"11#include "lldb/API/SBStream.h"12#include "lldb/API/SBTarget.h"13#include "lldb/Core/AddressRange.h"14#include "lldb/Core/Section.h"15#include "lldb/Utility/Instrumentation.h"16#include "lldb/Utility/Stream.h"17#include <cstddef>18#include <memory>1920using namespace lldb;21using namespace lldb_private;2223SBAddressRange::SBAddressRange()24: m_opaque_up(std::make_unique<AddressRange>()) {25LLDB_INSTRUMENT_VA(this);26}2728SBAddressRange::SBAddressRange(const SBAddressRange &rhs) {29LLDB_INSTRUMENT_VA(this, rhs);3031m_opaque_up = clone(rhs.m_opaque_up);32}3334SBAddressRange::SBAddressRange(lldb::SBAddress addr, lldb::addr_t byte_size)35: m_opaque_up(std::make_unique<AddressRange>(addr.ref(), byte_size)) {36LLDB_INSTRUMENT_VA(this, addr, byte_size);37}3839SBAddressRange::~SBAddressRange() = default;4041const SBAddressRange &SBAddressRange::operator=(const SBAddressRange &rhs) {42LLDB_INSTRUMENT_VA(this, rhs);4344if (this != &rhs)45m_opaque_up = clone(rhs.m_opaque_up);46return *this;47}4849bool SBAddressRange::operator==(const SBAddressRange &rhs) {50LLDB_INSTRUMENT_VA(this, rhs);5152return ref().operator==(rhs.ref());53}5455bool SBAddressRange::operator!=(const SBAddressRange &rhs) {56LLDB_INSTRUMENT_VA(this, rhs);5758return !(*this == rhs);59}6061void SBAddressRange::Clear() {62LLDB_INSTRUMENT_VA(this);6364ref().Clear();65}6667bool SBAddressRange::IsValid() const {68LLDB_INSTRUMENT_VA(this);6970return ref().IsValid();71}7273lldb::SBAddress SBAddressRange::GetBaseAddress() const {74LLDB_INSTRUMENT_VA(this);7576return lldb::SBAddress(ref().GetBaseAddress());77}7879lldb::addr_t SBAddressRange::GetByteSize() const {80LLDB_INSTRUMENT_VA(this);8182return ref().GetByteSize();83}8485bool SBAddressRange::GetDescription(SBStream &description,86const SBTarget target) {87LLDB_INSTRUMENT_VA(this, description, target);8889return ref().GetDescription(&description.ref(), target.GetSP().get());90}9192lldb_private::AddressRange &SBAddressRange::ref() const {93assert(m_opaque_up && "opaque pointer must always be valid");94return *m_opaque_up;95}969798