1 //===-- SBAddressRange.cpp ------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBAddressRange.h"
11 #include "lldb/API/SBAddress.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/API/SBTarget.h"
14 #include "lldb/Core/AddressRange.h"
15 #include "lldb/Core/Section.h"
16 #include "lldb/Utility/Instrumentation.h"
17 #include "lldb/Utility/Stream.h"
22 using namespace lldb_private
;
24 SBAddressRange::SBAddressRange()
25 : m_opaque_up(std::make_unique
<AddressRange
>()) {
26 LLDB_INSTRUMENT_VA(this);
29 SBAddressRange::SBAddressRange(const SBAddressRange
&rhs
) {
30 LLDB_INSTRUMENT_VA(this, rhs
);
32 m_opaque_up
= clone(rhs
.m_opaque_up
);
35 SBAddressRange::SBAddressRange(lldb::SBAddress addr
, lldb::addr_t byte_size
)
36 : m_opaque_up(std::make_unique
<AddressRange
>(addr
.ref(), byte_size
)) {
37 LLDB_INSTRUMENT_VA(this, addr
, byte_size
);
40 SBAddressRange::~SBAddressRange() = default;
42 const SBAddressRange
&SBAddressRange::operator=(const SBAddressRange
&rhs
) {
43 LLDB_INSTRUMENT_VA(this, rhs
);
46 m_opaque_up
= clone(rhs
.m_opaque_up
);
50 bool SBAddressRange::operator==(const SBAddressRange
&rhs
) {
51 LLDB_INSTRUMENT_VA(this, rhs
);
53 return ref().operator==(rhs
.ref());
56 bool SBAddressRange::operator!=(const SBAddressRange
&rhs
) {
57 LLDB_INSTRUMENT_VA(this, rhs
);
59 return !(*this == rhs
);
62 void SBAddressRange::Clear() {
63 LLDB_INSTRUMENT_VA(this);
68 bool SBAddressRange::IsValid() const {
69 LLDB_INSTRUMENT_VA(this);
71 return ref().IsValid();
74 lldb::SBAddress
SBAddressRange::GetBaseAddress() const {
75 LLDB_INSTRUMENT_VA(this);
77 return lldb::SBAddress(ref().GetBaseAddress());
80 lldb::addr_t
SBAddressRange::GetByteSize() const {
81 LLDB_INSTRUMENT_VA(this);
83 return ref().GetByteSize();
86 bool SBAddressRange::GetDescription(SBStream
&description
,
87 const SBTarget target
) {
88 LLDB_INSTRUMENT_VA(this, description
, target
);
90 return ref().GetDescription(&description
.ref(), target
.GetSP().get());
93 lldb_private::AddressRange
&SBAddressRange::ref() const {
94 assert(m_opaque_up
&& "opaque pointer must always be valid");