MemoryObject.h revision 263508
1176434Skaiw//===- MemoryObject.h - Abstract memory interface ---------------*- C++ -*-===// 2176434Skaiw// 3176434Skaiw// The LLVM Compiler Infrastructure 4176434Skaiw// 5176434Skaiw// This file is distributed under the University of Illinois Open Source 6176434Skaiw// License. See LICENSE.TXT for details. 7176434Skaiw// 8176434Skaiw//===----------------------------------------------------------------------===// 9176434Skaiw 10176434Skaiw#ifndef LLVM_SUPPORT_MEMORYOBJECT_H 11176434Skaiw#define LLVM_SUPPORT_MEMORYOBJECT_H 12176434Skaiw 13176434Skaiw#include "llvm/Support/DataTypes.h" 14176434Skaiw 15176434Skaiwnamespace llvm { 16176434Skaiw 17176434Skaiw/// MemoryObject - Abstract base class for contiguous addressable memory. 18176434Skaiw/// Necessary for cases in which the memory is in another process, in a 19176434Skaiw/// file, or on a remote machine. 20176434Skaiw/// All size and offset parameters are uint64_ts, to allow 32-bit processes 21176434Skaiw/// access to 64-bit address spaces. 22176434Skaiwclass MemoryObject { 23176434Skaiwpublic: 24176434Skaiw /// Destructor - Override as necessary. 25176434Skaiw virtual ~MemoryObject(); 26176434Skaiw 27176434Skaiw /// getBase - Returns the lowest valid address in the region. 28176434Skaiw /// 29176434Skaiw /// @result - The lowest valid address. 30176434Skaiw virtual uint64_t getBase() const = 0; 31176434Skaiw 32176434Skaiw /// getExtent - Returns the size of the region in bytes. (The region is 33176434Skaiw /// contiguous, so the highest valid address of the region 34176434Skaiw /// is getBase() + getExtent() - 1). 35176434Skaiw /// 36176434Skaiw /// @result - The size of the region. 37176434Skaiw virtual uint64_t getExtent() const = 0; 38176434Skaiw 39176434Skaiw /// readByte - Tries to read a single byte from the region. 40176434Skaiw /// 41176434Skaiw /// @param address - The address of the byte, in the same space as getBase(). 42176434Skaiw /// @param ptr - A pointer to a byte to be filled in. Must be non-NULL. 43176434Skaiw /// @result - 0 if successful; -1 if not. Failure may be due to a 44176434Skaiw /// bounds violation or an implementation-specific error. 45176434Skaiw virtual int readByte(uint64_t address, uint8_t *ptr) const = 0; 46176434Skaiw 47176434Skaiw /// readBytes - Tries to read a contiguous range of bytes from the 48176434Skaiw /// region, up to the end of the region. 49176434Skaiw /// You should override this function if there is a quicker 50176434Skaiw /// way than going back and forth with individual bytes. 51176434Skaiw /// 52176434Skaiw /// @param address - The address of the first byte, in the same space as 53176434Skaiw /// getBase(). 54176434Skaiw /// @param size - The number of bytes to copy. 55176434Skaiw /// @param buf - A pointer to a buffer to be filled in. Must be non-NULL 56176434Skaiw /// and large enough to hold size bytes. 57176434Skaiw /// @result - 0 if successful; -1 if not. Failure may be due to a 58176434Skaiw /// bounds violation or an implementation-specific error. 59176434Skaiw virtual int readBytes(uint64_t address, uint64_t size, uint8_t *buf) const; 60176434Skaiw}; 61176434Skaiw 62176434Skaiw} 63183218Skaiw 64183218Skaiw#endif 65176434Skaiw