LLDB mainline
SBAddressRangeList.cpp
Go to the documentation of this file.
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//===----------------------------------------------------------------------===//
8
10#include "Utils.h"
12#include "lldb/API/SBStream.h"
13#include "lldb/API/SBTarget.h"
16#include "lldb/Utility/Stream.h"
17
18#include <memory>
19
20using namespace lldb;
21using namespace lldb_private;
22
24 : m_opaque_up(std::make_unique<AddressRangeListImpl>()) {
26}
27
29 : m_opaque_up(std::make_unique<AddressRangeListImpl>(*rhs.m_opaque_up)) {
30 LLDB_INSTRUMENT_VA(this, rhs);
31}
32
34
37 LLDB_INSTRUMENT_VA(this, rhs);
38
39 if (this != &rhs)
40 ref() = rhs.ref();
41 return *this;
42}
43
46
47 return ref().GetSize();
48}
49
51 LLDB_INSTRUMENT_VA(this, idx);
52
53 SBAddressRange sb_addr_range;
54 (*sb_addr_range.m_opaque_up) = ref().GetAddressRangeAtIndex(idx);
55 return sb_addr_range;
56}
57
60
61 ref().Clear();
62}
63
64void SBAddressRangeList::Append(const SBAddressRange &sb_addr_range) {
65 LLDB_INSTRUMENT_VA(this, sb_addr_range);
66
67 ref().Append(*sb_addr_range.m_opaque_up);
68}
69
70void SBAddressRangeList::Append(const SBAddressRangeList &sb_addr_range_list) {
71 LLDB_INSTRUMENT_VA(this, sb_addr_range_list);
72
73 ref().Append(*sb_addr_range_list.m_opaque_up);
74}
75
77 const SBTarget &target) {
78 LLDB_INSTRUMENT_VA(this, description, target);
79
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(", ");
89 }
90 GetAddressRangeAtIndex(i).GetDescription(description, target);
91 }
92 stream << "]";
93 return true;
94}
95
97 assert(m_opaque_up && "opaque pointer must always be valid");
98 return *m_opaque_up;
99}
#define LLDB_INSTRUMENT_VA(...)
const lldb::SBAddressRangeList & operator=(const lldb::SBAddressRangeList &rhs)
void Append(const lldb::SBAddressRange &addr_range)
std::unique_ptr< lldb_private::AddressRangeListImpl > m_opaque_up
SBAddressRange GetAddressRangeAtIndex(uint64_t idx)
lldb_private::AddressRangeListImpl & ref() const
bool GetDescription(lldb::SBStream &description, const SBTarget &target)
AddressRangeUP m_opaque_up
bool GetDescription(lldb::SBStream &description, const SBTarget target)
lldb_private::Stream & ref()
Definition: SBStream.cpp:177
lldb_private::AddressRange GetAddressRangeAtIndex(size_t index)
void Append(const AddressRange &sb_region)
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
A class that represents a running process on the host machine.
Definition: SBAddress.h:15