LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MemoryObject.cpp
Go to the documentation of this file.
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 
11 using namespace llvm;
12 
14 }
15 
16 int 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 }
virtual int readByte(uint64_t address, uint8_t *ptr) const =0
virtual uint64_t getExtent() const =0
virtual int readBytes(uint64_t address, uint64_t size, uint8_t *buf) const
virtual uint64_t getBase() const =0
virtual ~MemoryObject()
Destructor - Override as necessary.