1//===- MemoryObject.cpp - Abstract memory interface -----------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "llvm/Support/MemoryObject.h"
11using namespace llvm;
12
13MemoryObject::~MemoryObject() {
14}
15
16int MemoryObject::readBytes(uint64_t address,
17                            uint64_t size,
18                            uint8_t* buf) const {
19  uint64_t current = address;
20  uint64_t limit = getBase() + getExtent();
21
22  if (current + size > limit)
23    return -1;
24
25  while (current - address < size) {
26    if (readByte(current, &buf[(current - address)]))
27      return -1;
28
29    current++;
30  }
31
32  return 0;
33}
34