LLDB mainline
VMRange.cpp
Go to the documentation of this file.
1//===-- VMRange.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
11#include "lldb/Utility/Stream.h"
12#include "lldb/lldb-types.h"
13
14#include <algorithm>
15#include <iterator>
16#include <vector>
17
18#include <cstddef>
19#include <cstdint>
20
21using namespace lldb;
22using namespace lldb_private;
23
25 lldb::addr_t value) {
26 return llvm::any_of(coll,
27 [&](const VMRange &r) { return r.Contains(value); });
28}
29
31 const VMRange &range) {
32 return llvm::any_of(coll,
33 [&](const VMRange &r) { return r.Contains(range); });
34}
35
36void VMRange::Dump(llvm::raw_ostream &s, lldb::addr_t offset,
37 uint32_t addr_width) const {
38 DumpAddressRange(s, offset + GetBaseAddress(), offset + GetEndAddress(),
39 addr_width);
40}
41
42bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) {
43 return lhs.GetBaseAddress() == rhs.GetBaseAddress() &&
44 lhs.GetEndAddress() == rhs.GetEndAddress();
45}
46
47bool lldb_private::operator!=(const VMRange &lhs, const VMRange &rhs) {
48 return !(lhs == rhs);
49}
50
51bool lldb_private::operator<(const VMRange &lhs, const VMRange &rhs) {
52 if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
53 return true;
54 else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
55 return false;
56 return lhs.GetEndAddress() < rhs.GetEndAddress();
57}
58
59bool lldb_private::operator<=(const VMRange &lhs, const VMRange &rhs) {
60 return !(lhs > rhs);
61}
62
63bool lldb_private::operator>(const VMRange &lhs, const VMRange &rhs) {
64 return rhs < lhs;
65}
66
67bool lldb_private::operator>=(const VMRange &lhs, const VMRange &rhs) {
68 return !(lhs < rhs);
69}
static bool ContainsRange(const VMRange::collection &coll, const VMRange &range)
Definition: VMRange.cpp:30
static bool ContainsValue(const VMRange::collection &coll, lldb::addr_t value)
Definition: VMRange.cpp:24
lldb::addr_t GetEndAddress() const
Definition: VMRange.h:65
lldb::addr_t GetBaseAddress() const
Definition: VMRange.h:63
bool Contains(lldb::addr_t addr) const
Definition: VMRange.h:69
std::vector< VMRange > collection
Definition: VMRange.h:25
void Dump(llvm::raw_ostream &s, lldb::addr_t base_addr=0, uint32_t addr_width=8) const
Definition: VMRange.cpp:36
A class that represents a running process on the host machine.
void DumpAddressRange(llvm::raw_ostream &s, uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix=nullptr, const char *suffix=nullptr)
Output an address range to this stream.
Definition: Stream.cpp:120
bool operator<=(const Scalar &lhs, const Scalar &rhs)
Definition: Scalar.cpp:897
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1029
bool operator>(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1007
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1023
bool operator<(const Address &lhs, const Address &rhs)
Definition: Address.cpp:992
bool operator>=(const Scalar &lhs, const Scalar &rhs)
Definition: Scalar.cpp:905
Definition: SBAddress.h:15
uint64_t addr_t
Definition: lldb-types.h:80