2010-06-09 00:52:24 +08:00
|
|
|
//===-- VMRange.cpp ---------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-04-07 02:12:24 +08:00
|
|
|
#include "lldb/Utility/VMRange.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2017-04-07 02:12:24 +08:00
|
|
|
#include "lldb/lldb-types.h" // for addr_t
|
|
|
|
|
2010-06-09 16:50:27 +08:00
|
|
|
#include <algorithm>
|
2017-04-07 02:12:24 +08:00
|
|
|
#include <iterator> // for distance
|
|
|
|
#include <vector> // for const_iterator
|
|
|
|
|
|
|
|
#include <stddef.h> // for size_t
|
|
|
|
#include <stdint.h> // for UINT32_MAX, uint32_t
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool VMRange::ContainsValue(const VMRange::collection &coll,
|
|
|
|
lldb::addr_t value) {
|
2018-08-04 10:15:26 +08:00
|
|
|
return llvm::find_if(coll, [&](const VMRange &r) {
|
|
|
|
return r.Contains(value);
|
|
|
|
}) != coll.end();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool VMRange::ContainsRange(const VMRange::collection &coll,
|
|
|
|
const VMRange &range) {
|
2018-08-04 10:15:26 +08:00
|
|
|
return llvm::find_if(coll, [&](const VMRange &r) {
|
|
|
|
return r.Contains(range);
|
|
|
|
}) != coll.end();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const {
|
|
|
|
s->AddressRange(offset + GetBaseAddress(), offset + GetEndAddress(),
|
|
|
|
addr_width);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) {
|
|
|
|
return lhs.GetBaseAddress() == rhs.GetBaseAddress() &&
|
|
|
|
lhs.GetEndAddress() == rhs.GetEndAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator!=(const VMRange &lhs, const VMRange &rhs) {
|
2017-06-10 04:49:11 +08:00
|
|
|
return !(lhs == rhs);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator<(const VMRange &lhs, const VMRange &rhs) {
|
|
|
|
if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
|
|
|
|
return true;
|
|
|
|
else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
|
|
|
|
return false;
|
|
|
|
return lhs.GetEndAddress() < rhs.GetEndAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator<=(const VMRange &lhs, const VMRange &rhs) {
|
2017-06-10 04:49:11 +08:00
|
|
|
return !(lhs > rhs);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator>(const VMRange &lhs, const VMRange &rhs) {
|
2017-06-10 04:49:11 +08:00
|
|
|
return rhs < lhs;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator>=(const VMRange &lhs, const VMRange &rhs) {
|
2017-06-10 04:49:11 +08:00
|
|
|
return !(lhs < rhs);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|