1 //===-- VMRange.cpp ---------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Utility/VMRange.h" 11 12 #include "lldb/Utility/Stream.h" 13 #include "lldb/lldb-types.h" // for addr_t 14 15 #include <algorithm> 16 #include <iterator> // for distance 17 #include <vector> // for const_iterator 18 19 #include <stddef.h> // for size_t 20 #include <stdint.h> // for UINT32_MAX, uint32_t 21 22 using namespace lldb; 23 using namespace lldb_private; 24 25 bool VMRange::ContainsValue(const VMRange::collection &coll, 26 lldb::addr_t value) { 27 ValueInRangeUnaryPredicate in_range_predicate(value); 28 return llvm::find_if(coll, in_range_predicate) != coll.end(); 29 } 30 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(); 35 } 36 37 void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const { 38 s->AddressRange(offset + GetBaseAddress(), offset + GetEndAddress(), 39 addr_width); 40 } 41 42 bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) { 43 return lhs.GetBaseAddress() == rhs.GetBaseAddress() && 44 lhs.GetEndAddress() == rhs.GetEndAddress(); 45 } 46 47 bool lldb_private::operator!=(const VMRange &lhs, const VMRange &rhs) { 48 return !(lhs == rhs); 49 } 50 51 bool 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 59 bool lldb_private::operator<=(const VMRange &lhs, const VMRange &rhs) { 60 return !(lhs > rhs); 61 } 62 63 bool lldb_private::operator>(const VMRange &lhs, const VMRange &rhs) { 64 return rhs < lhs; 65 } 66 67 bool lldb_private::operator>=(const VMRange &lhs, const VMRange &rhs) { 68 return !(lhs < rhs); 69 } 70