1 //===-- VMRange.cpp ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Utility/VMRange.h"
12 #include "lldb/Utility/Stream.h"
13 #include "lldb/lldb-types.h" // for addr_t
16 #include <iterator> // for distance
17 #include <vector> // for const_iterator
19 #include <stddef.h> // for size_t
20 #include <stdint.h> // for UINT32_MAX, uint32_t
23 using namespace lldb_private;
25 bool VMRange::ContainsValue(const VMRange::collection &coll,
27 ValueInRangeUnaryPredicate in_range_predicate(value);
28 return llvm::find_if(coll, in_range_predicate) != coll.end();
31 bool VMRange::ContainsRange(const VMRange::collection &coll,
32 const VMRange &range) {
33 RangeInRangeUnaryPredicate in_range_predicate(range);
34 return llvm::find_if(coll, in_range_predicate) != coll.end();
37 void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const {
38 s->AddressRange(offset + GetBaseAddress(), offset + GetEndAddress(),
42 bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) {
43 return lhs.GetBaseAddress() == rhs.GetBaseAddress() &&
44 lhs.GetEndAddress() == rhs.GetEndAddress();
47 bool lldb_private::operator!=(const VMRange &lhs, const VMRange &rhs) {
51 bool lldb_private::operator<(const VMRange &lhs, const VMRange &rhs) {
52 if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
54 else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
56 return lhs.GetEndAddress() < rhs.GetEndAddress();
59 bool lldb_private::operator<=(const VMRange &lhs, const VMRange &rhs) {
63 bool lldb_private::operator>(const VMRange &lhs, const VMRange &rhs) {
67 bool lldb_private::operator>=(const VMRange &lhs, const VMRange &rhs) {