[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFT...
[llvm-project.git] / lldb / source / API / SBAddressRangeList.cpp
blob957155d5125ef94313905ecebade2ec520712223
1 //===-- SBAddressRangeList.cpp --------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBAddressRangeList.h"
10 #include "Utils.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"
18 #include <memory>
20 using namespace lldb;
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);
39 if (this != &rhs)
40 ref() = rhs.ref();
41 return *this;
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);
55 return sb_addr_range;
58 void SBAddressRangeList::Clear() {
59 LLDB_INSTRUMENT_VA(this);
61 ref().Clear();
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();
81 bool is_first = true;
82 Stream &stream = description.ref();
83 stream << "[";
84 for (uint32_t i = 0; i < num_ranges; ++i) {
85 if (is_first) {
86 is_first = false;
87 } else {
88 stream.Printf(", ");
90 GetAddressRangeAtIndex(i).GetDescription(description, target);
92 stream << "]";
93 return true;
96 lldb_private::AddressRangeListImpl &SBAddressRangeList::ref() const {
97 assert(m_opaque_up && "opaque pointer must always be valid");
98 return *m_opaque_up;