1 //===-- SBAddressRangeList.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/SBAddressRangeList.h"
11 #include "lldb/API/SBAddressRange.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/API/SBTarget.h"
14 #include "lldb/Core/AddressRangeListImpl.h"
15 #include "lldb/Utility/Instrumentation.h"
16 #include "lldb/Utility/Stream.h"
21 using namespace lldb_private
;
23 SBAddressRangeList::SBAddressRangeList()
24 : m_opaque_up(std::make_unique
<AddressRangeListImpl
>()) {
25 LLDB_INSTRUMENT_VA(this);
28 SBAddressRangeList::SBAddressRangeList(const SBAddressRangeList
&rhs
)
29 : m_opaque_up(std::make_unique
<AddressRangeListImpl
>(*rhs
.m_opaque_up
)) {
30 LLDB_INSTRUMENT_VA(this, rhs
);
33 SBAddressRangeList::~SBAddressRangeList() = default;
35 const SBAddressRangeList
&
36 SBAddressRangeList::operator=(const SBAddressRangeList
&rhs
) {
37 LLDB_INSTRUMENT_VA(this, rhs
);
44 uint32_t SBAddressRangeList::GetSize() const {
45 LLDB_INSTRUMENT_VA(this);
47 return ref().GetSize();
50 SBAddressRange
SBAddressRangeList::GetAddressRangeAtIndex(uint64_t idx
) {
51 LLDB_INSTRUMENT_VA(this, idx
);
53 SBAddressRange sb_addr_range
;
54 (*sb_addr_range
.m_opaque_up
) = ref().GetAddressRangeAtIndex(idx
);
58 void SBAddressRangeList::Clear() {
59 LLDB_INSTRUMENT_VA(this);
64 void SBAddressRangeList::Append(const SBAddressRange
&sb_addr_range
) {
65 LLDB_INSTRUMENT_VA(this, sb_addr_range
);
67 ref().Append(*sb_addr_range
.m_opaque_up
);
70 void SBAddressRangeList::Append(const SBAddressRangeList
&sb_addr_range_list
) {
71 LLDB_INSTRUMENT_VA(this, sb_addr_range_list
);
73 ref().Append(*sb_addr_range_list
.m_opaque_up
);
76 bool SBAddressRangeList::GetDescription(SBStream
&description
,
77 const SBTarget
&target
) {
78 LLDB_INSTRUMENT_VA(this, description
, target
);
80 const uint32_t num_ranges
= GetSize();
82 Stream
&stream
= description
.ref();
84 for (uint32_t i
= 0; i
< num_ranges
; ++i
) {
90 GetAddressRangeAtIndex(i
).GetDescription(description
, target
);
96 lldb_private::AddressRangeListImpl
&SBAddressRangeList::ref() const {
97 assert(m_opaque_up
&& "opaque pointer must always be valid");