aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/API/SBAddressRange.cpp
blob: 5834ebe5e63c00fed0bdb8717690b7b2aa4fcdb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//===-- SBAddressRange.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "lldb/API/SBAddressRange.h"
#include "Utils.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTarget.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Section.h"
#include "lldb/Utility/Instrumentation.h"
#include "lldb/Utility/Stream.h"
#include <cstddef>
#include <memory>

using namespace lldb;
using namespace lldb_private;

SBAddressRange::SBAddressRange()
    : m_opaque_up(std::make_unique<AddressRange>()) {
  LLDB_INSTRUMENT_VA(this);
}

SBAddressRange::SBAddressRange(const SBAddressRange &rhs) {
  LLDB_INSTRUMENT_VA(this, rhs);

  m_opaque_up = clone(rhs.m_opaque_up);
}

SBAddressRange::SBAddressRange(lldb::SBAddress addr, lldb::addr_t byte_size)
    : m_opaque_up(std::make_unique<AddressRange>(addr.ref(), byte_size)) {
  LLDB_INSTRUMENT_VA(this, addr, byte_size);
}

SBAddressRange::~SBAddressRange() = default;

const SBAddressRange &SBAddressRange::operator=(const SBAddressRange &rhs) {
  LLDB_INSTRUMENT_VA(this, rhs);

  if (this != &rhs)
    m_opaque_up = clone(rhs.m_opaque_up);
  return *this;
}

bool SBAddressRange::operator==(const SBAddressRange &rhs) {
  LLDB_INSTRUMENT_VA(this, rhs);

  return ref().operator==(rhs.ref());
}

bool SBAddressRange::operator!=(const SBAddressRange &rhs) {
  LLDB_INSTRUMENT_VA(this, rhs);

  return !(*this == rhs);
}

void SBAddressRange::Clear() {
  LLDB_INSTRUMENT_VA(this);

  ref().Clear();
}

bool SBAddressRange::IsValid() const {
  LLDB_INSTRUMENT_VA(this);

  return ref().IsValid();
}

lldb::SBAddress SBAddressRange::GetBaseAddress() const {
  LLDB_INSTRUMENT_VA(this);

  return lldb::SBAddress(ref().GetBaseAddress());
}

lldb::addr_t SBAddressRange::GetByteSize() const {
  LLDB_INSTRUMENT_VA(this);

  return ref().GetByteSize();
}

bool SBAddressRange::GetDescription(SBStream &description,
                                    const SBTarget target) {
  LLDB_INSTRUMENT_VA(this, description, target);

  return ref().GetDescription(&description.ref(), target.GetSP().get());
}

lldb_private::AddressRange &SBAddressRange::ref() const {
  assert(m_opaque_up && "opaque pointer must always be valid");
  return *m_opaque_up;
}