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" 14 15 #include <algorithm> 16 #include <iterator> 17 #include <vector> 18 19 #include <stddef.h> 20 #include <stdint.h> 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 return llvm::find_if(coll, [&](const VMRange &r) { 28 return r.Contains(value); 29 }) != coll.end(); 30 } 31 32 bool VMRange::ContainsRange(const VMRange::collection &coll, 33 const VMRange &range) { 34 return llvm::find_if(coll, [&](const VMRange &r) { 35 return r.Contains(range); 36 }) != coll.end(); 37 } 38 39 void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const { 40 s->AddressRange(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 } 72