mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-14 20:32:24 +00:00

Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary. So I defined a new "lldb::offset_t" which should be used for all file offsets. After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed. Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections. llvm-svn: 173463
113 lines
3.2 KiB
C++
113 lines
3.2 KiB
C++
//===-- VMRange.cpp ---------------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/lldb-private.h"
|
|
|
|
#include "lldb/Core/Stream.h"
|
|
#include "lldb/Core/VMRange.h"
|
|
#include <algorithm>
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
bool
|
|
VMRange::ContainsValue(const VMRange::collection& coll, lldb::addr_t value)
|
|
{
|
|
ValueInRangeUnaryPredicate in_range_predicate(value);
|
|
VMRange::const_iterator pos;
|
|
VMRange::const_iterator end = coll.end();
|
|
pos = std::find_if( coll.begin(), end, in_range_predicate );
|
|
if (pos != end)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
VMRange::ContainsRange(const VMRange::collection& coll, const VMRange& range)
|
|
{
|
|
RangeInRangeUnaryPredicate in_range_predicate(range);
|
|
VMRange::const_iterator pos;
|
|
VMRange::const_iterator end = coll.end();
|
|
pos = std::find_if( coll.begin(), end, in_range_predicate );
|
|
if (pos != end)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
size_t
|
|
VMRange::FindRangeIndexThatContainsValue (const VMRange::collection& coll, lldb::addr_t value)
|
|
{
|
|
ValueInRangeUnaryPredicate in_range_predicate(value);
|
|
VMRange::const_iterator begin = coll.begin();
|
|
VMRange::const_iterator end = coll.end();
|
|
VMRange::const_iterator pos = std::find_if (begin, end, in_range_predicate);
|
|
if (pos != end)
|
|
return std::distance (begin, pos);
|
|
return UINT32_MAX;
|
|
}
|
|
|
|
void
|
|
VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const
|
|
{
|
|
s->AddressRange(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.GetBaseAddress() != rhs.GetBaseAddress() || lhs.GetEndAddress() != rhs.GetEndAddress();
|
|
}
|
|
|
|
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)
|
|
{
|
|
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)
|
|
{
|
|
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)
|
|
{
|
|
if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
|
|
return true;
|
|
else if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
|
|
return false;
|
|
return lhs.GetEndAddress() >= rhs.GetEndAddress();
|
|
}
|
|
|