blob: 2f5d8ecf9abbb01f769a25f1139bdec6c0b605bc [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- 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/lldb-private.h"
11
12#include "lldb/Core/Stream.h"
13#include "lldb/Core/VMRange.h"
14
15using namespace lldb;
16using namespace lldb_private;
17
18bool
19VMRange::ContainsValue(const VMRange::collection& coll, lldb::addr_t value)
20{
21 ValueInRangeUnaryPredicate in_range_predicate(value);
22 VMRange::const_iterator pos;
23 VMRange::const_iterator end = coll.end();
24 pos = std::find_if( coll.begin(), end, in_range_predicate );
25 if (pos != end)
26 return true;
27 return false;
28}
29
30bool
31VMRange::ContainsRange(const VMRange::collection& coll, const VMRange& range)
32{
33 RangeInRangeUnaryPredicate in_range_predicate(range);
34 VMRange::const_iterator pos;
35 VMRange::const_iterator end = coll.end();
36 pos = std::find_if( coll.begin(), end, in_range_predicate );
37 if (pos != end)
38 return true;
39 return false;
40}
41
42
43void
44VMRange::Dump(Stream *s, lldb::addr_t offset) const
45{
46 s->AddressRange(offset + GetBaseAddress(), offset + GetEndAddress(), sizeof (addr_t));
47}
48
49bool
50lldb_private::operator== (const VMRange& lhs, const VMRange& rhs)
51{
52 return lhs.GetBaseAddress() == rhs.GetBaseAddress() && lhs.GetEndAddress() == rhs.GetEndAddress();
53}
54
55bool
56lldb_private::operator!= (const VMRange& lhs, const VMRange& rhs)
57{
58 return lhs.GetBaseAddress() != rhs.GetBaseAddress() || lhs.GetEndAddress() != rhs.GetEndAddress();
59}
60
61bool
62lldb_private::operator< (const VMRange& lhs, const VMRange& rhs)
63{
64 if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
65 return true;
66 else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
67 return false;
68 return lhs.GetEndAddress() < rhs.GetEndAddress();
69}
70
71bool
72lldb_private::operator<= (const VMRange& lhs, const VMRange& rhs)
73{
74 if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
75 return true;
76 else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
77 return false;
78 return lhs.GetEndAddress() <= rhs.GetEndAddress();
79}
80
81bool
82lldb_private::operator> (const VMRange& lhs, const VMRange& rhs)
83{
84 if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
85 return true;
86 else if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
87 return false;
88 return lhs.GetEndAddress() > rhs.GetEndAddress();
89}
90
91bool
92lldb_private::operator>= (const VMRange& lhs, const VMRange& rhs)
93{
94 if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
95 return true;
96 else if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
97 return false;
98 return lhs.GetEndAddress() >= rhs.GetEndAddress();
99}
100