2010-06-09 00:52:24 +08:00
|
|
|
//===-- VMRange.cpp ---------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
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"
|
2018-11-12 07:16:43 +08:00
|
|
|
#include "lldb/lldb-types.h"
|
2017-04-07 02:12:24 +08:00
|
|
|
|
2010-06-09 16:50:27 +08:00
|
|
|
#include <algorithm>
|
2018-11-12 07:16:43 +08:00
|
|
|
#include <iterator>
|
|
|
|
#include <vector>
|
2017-04-07 02:12:24 +08:00
|
|
|
|
2018-11-12 07:16:43 +08:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
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
|
|
|
}
|