2009-09-10 01:46:42 +02:00
|
|
|
//===- MemoryObject.cpp - Abstract memory interface -----------------------===//
|
2009-09-10 00:49:13 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Support/MemoryObject.h"
|
2009-09-10 01:46:42 +02:00
|
|
|
using namespace llvm;
|
2009-09-10 00:49:13 +02:00
|
|
|
|
2009-09-10 01:46:42 +02:00
|
|
|
MemoryObject::~MemoryObject() {
|
|
|
|
}
|
|
|
|
|
|
|
|
int MemoryObject::readBytes(uint64_t address,
|
|
|
|
uint64_t size,
|
2013-05-24 12:54:58 +02:00
|
|
|
uint8_t* buf) const {
|
2009-09-10 01:46:42 +02:00
|
|
|
uint64_t current = address;
|
|
|
|
uint64_t limit = getBase() + getExtent();
|
2011-08-27 09:45:46 +02:00
|
|
|
|
|
|
|
if (current + size > limit)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
while (current - address < size) {
|
2009-09-10 01:46:42 +02:00
|
|
|
if (readByte(current, &buf[(current - address)]))
|
|
|
|
return -1;
|
2009-09-10 00:49:13 +02:00
|
|
|
|
2009-09-10 01:46:42 +02:00
|
|
|
current++;
|
2009-09-10 00:49:13 +02:00
|
|
|
}
|
2009-09-10 01:46:42 +02:00
|
|
|
|
|
|
|
return 0;
|
2009-09-10 00:49:13 +02:00
|
|
|
}
|