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 
9 #include "lldb/Utility/VMRange.h"
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 
21 using namespace lldb;
22 using namespace lldb_private;
23 
24 bool VMRange::ContainsValue(const VMRange::collection &coll,
25  lldb::addr_t value) {
26  return llvm::find_if(coll, [&](const VMRange &r) {
27  return r.Contains(value);
28  }) != coll.end();
29 }
30 
31 bool VMRange::ContainsRange(const VMRange::collection &coll,
32  const VMRange &range) {
33  return llvm::find_if(coll, [&](const VMRange &r) {
34  return r.Contains(range);
35  }) != coll.end();
36 }
37 
38 void VMRange::Dump(llvm::raw_ostream &s, lldb::addr_t offset,
39  uint32_t addr_width) const {
40  DumpAddressRange(s, offset + GetBaseAddress(), offset + GetEndAddress(),
41  addr_width);
42 }
43 
44 bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) {
45  return lhs.GetBaseAddress() == rhs.GetBaseAddress() &&
46  lhs.GetEndAddress() == rhs.GetEndAddress();
47 }
48 
49 bool lldb_private::operator!=(const VMRange &lhs, const VMRange &rhs) {
50  return !(lhs == rhs);
51 }
52 
53 bool lldb_private::operator<(const VMRange &lhs, const VMRange &rhs) {
54  if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
55  return true;
56  else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
57  return false;
58  return lhs.GetEndAddress() < rhs.GetEndAddress();
59 }
60 
61 bool lldb_private::operator<=(const VMRange &lhs, const VMRange &rhs) {
62  return !(lhs > rhs);
63 }
64 
65 bool lldb_private::operator>(const VMRange &lhs, const VMRange &rhs) {
66  return rhs < lhs;
67 }
68 
69 bool lldb_private::operator>=(const VMRange &lhs, const VMRange &rhs) {
70  return !(lhs < rhs);
71 }
lldb_private::VMRange::GetEndAddress
lldb::addr_t GetEndAddress() const
Definition: VMRange.h:65
lldb_private::DumpAddressRange
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:93
lldb_private::VMRange::collection
std::vector< VMRange > collection
Definition: VMRange.h:25
lldb_private::VMRange::GetBaseAddress
lldb::addr_t GetBaseAddress() const
Definition: VMRange.h:63
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::operator==
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:999
lldb_private::operator>
bool operator>(const Address &lhs, const Address &rhs)
Definition: Address.cpp:983
lldb_private::operator!=
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1005
lldb-types.h
uint32_t
VMRange.h
lldb_private::operator<
bool operator<(const Address &lhs, const Address &rhs)
Definition: Address.cpp:968
lldb_private::operator>=
bool operator>=(const Scalar &lhs, const Scalar &rhs)
Definition: Scalar.cpp:864
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
Stream.h
lldb
Definition: SBAddress.h:15
lldb_private::operator<=
bool operator<=(const Scalar &lhs, const Scalar &rhs)
Definition: Scalar.cpp:856
lldb_private::VMRange
Definition: VMRange.h:23
lldb_private::VMRange::Contains
bool Contains(lldb::addr_t addr) const
Definition: VMRange.h:69