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/lldb-private.h"
12 #include "lldb/Core/Stream.h"
13 #include "lldb/Core/VMRange.h"
17 using namespace lldb_private;
20 VMRange::ContainsValue(const VMRange::collection& coll, lldb::addr_t value)
22 ValueInRangeUnaryPredicate in_range_predicate(value);
23 VMRange::const_iterator pos;
24 VMRange::const_iterator end = coll.end();
25 pos = std::find_if( coll.begin(), end, in_range_predicate );
32 VMRange::ContainsRange(const VMRange::collection& coll, const VMRange& range)
34 RangeInRangeUnaryPredicate in_range_predicate(range);
35 VMRange::const_iterator pos;
36 VMRange::const_iterator end = coll.end();
37 pos = std::find_if( coll.begin(), end, in_range_predicate );
44 VMRange::FindRangeIndexThatContainsValue (const VMRange::collection& coll, lldb::addr_t value)
46 ValueInRangeUnaryPredicate in_range_predicate(value);
47 VMRange::const_iterator begin = coll.begin();
48 VMRange::const_iterator end = coll.end();
49 VMRange::const_iterator pos = std::find_if (begin, end, in_range_predicate);
51 return std::distance (begin, pos);
56 VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const
58 s->AddressRange(offset + GetBaseAddress(), offset + GetEndAddress(), addr_width);
62 lldb_private::operator== (const VMRange& lhs, const VMRange& rhs)
64 return lhs.GetBaseAddress() == rhs.GetBaseAddress() && lhs.GetEndAddress() == rhs.GetEndAddress();
68 lldb_private::operator!= (const VMRange& lhs, const VMRange& rhs)
70 return lhs.GetBaseAddress() != rhs.GetBaseAddress() || lhs.GetEndAddress() != rhs.GetEndAddress();
74 lldb_private::operator< (const VMRange& lhs, const VMRange& rhs)
76 if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
78 else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
80 return lhs.GetEndAddress() < rhs.GetEndAddress();
84 lldb_private::operator<= (const VMRange& lhs, const VMRange& rhs)
86 if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
88 else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
90 return lhs.GetEndAddress() <= rhs.GetEndAddress();
94 lldb_private::operator> (const VMRange& lhs, const VMRange& rhs)
96 if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
98 else if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
100 return lhs.GetEndAddress() > rhs.GetEndAddress();
104 lldb_private::operator>= (const VMRange& lhs, const VMRange& rhs)
106 if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
108 else if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
110 return lhs.GetEndAddress() >= rhs.GetEndAddress();