mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 20:10:50 +08:00
Summary: Yet another step on the long road towards getting rid of lldb's Stream class. We probably should just make this some kind of member of Address/AddressRange, but it seems quite often we just push in random integers in there and this is just about getting rid of Stream and not improving arbitrary APIs. I had to rename another `DumpAddress` function in FormatEntity that is dumping the content of an address to make Clang happy. Reviewers: labath Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71052
71 lines
2.1 KiB
C++
71 lines
2.1 KiB
C++
//===-- VMRange.cpp ---------------------------------------------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Utility/VMRange.h"
|
|
|
|
#include "lldb/Utility/Stream.h"
|
|
#include "lldb/lldb-types.h"
|
|
|
|
#include <algorithm>
|
|
#include <iterator>
|
|
#include <vector>
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
bool VMRange::ContainsValue(const VMRange::collection &coll,
|
|
lldb::addr_t value) {
|
|
return llvm::find_if(coll, [&](const VMRange &r) {
|
|
return r.Contains(value);
|
|
}) != coll.end();
|
|
}
|
|
|
|
bool VMRange::ContainsRange(const VMRange::collection &coll,
|
|
const VMRange &range) {
|
|
return llvm::find_if(coll, [&](const VMRange &r) {
|
|
return r.Contains(range);
|
|
}) != coll.end();
|
|
}
|
|
|
|
void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const {
|
|
DumpAddressRange(s->AsRawOstream(), offset + GetBaseAddress(),
|
|
offset + GetEndAddress(), addr_width);
|
|
}
|
|
|
|
bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) {
|
|
return lhs.GetBaseAddress() == rhs.GetBaseAddress() &&
|
|
lhs.GetEndAddress() == rhs.GetEndAddress();
|
|
}
|
|
|
|
bool lldb_private::operator!=(const VMRange &lhs, const VMRange &rhs) {
|
|
return !(lhs == rhs);
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
bool lldb_private::operator<=(const VMRange &lhs, const VMRange &rhs) {
|
|
return !(lhs > rhs);
|
|
}
|
|
|
|
bool lldb_private::operator>(const VMRange &lhs, const VMRange &rhs) {
|
|
return rhs < lhs;
|
|
}
|
|
|
|
bool lldb_private::operator>=(const VMRange &lhs, const VMRange &rhs) {
|
|
return !(lhs < rhs);
|
|
}
|