2009-09-09 23:46:42 +00:00
|
|
|
//===- MemoryObject.cpp - Abstract memory interface -----------------------===//
|
2009-09-09 22:49:13 +00: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-09 23:46:42 +00:00
|
|
|
using namespace llvm;
|
2009-09-09 22:49:13 +00:00
|
|
|
|
2009-09-09 23:46:42 +00:00
|
|
|
MemoryObject::~MemoryObject() {
|
|
|
|
}
|
|
|
|
|
|
|
|
int MemoryObject::readBytes(uint64_t address,
|
|
|
|
uint64_t size,
|
|
|
|
uint8_t* buf,
|
|
|
|
uint64_t* copied) const {
|
|
|
|
uint64_t current = address;
|
|
|
|
uint64_t limit = getBase() + getExtent();
|
2009-09-09 22:49:13 +00:00
|
|
|
|
2009-09-09 23:46:42 +00:00
|
|
|
while (current - address < size && current < limit) {
|
|
|
|
if (readByte(current, &buf[(current - address)]))
|
|
|
|
return -1;
|
2009-09-09 22:49:13 +00:00
|
|
|
|
2009-09-09 23:46:42 +00:00
|
|
|
current++;
|
2009-09-09 22:49:13 +00:00
|
|
|
}
|
2009-09-09 23:46:42 +00:00
|
|
|
|
|
|
|
if (copied)
|
|
|
|
*copied = current - address;
|
|
|
|
|
|
|
|
return 0;
|
2009-09-09 22:49:13 +00:00
|
|
|
}
|