MemoryObject.h revision 263508
117680Spst//===- MemoryObject.h - Abstract memory interface ---------------*- C++ -*-===// 217680Spst// 317680Spst// The LLVM Compiler Infrastructure 417680Spst// 517680Spst// This file is distributed under the University of Illinois Open Source 617680Spst// License. See LICENSE.TXT for details. 717680Spst// 817680Spst//===----------------------------------------------------------------------===// 917680Spst 1017680Spst#ifndef LLVM_SUPPORT_MEMORYOBJECT_H 1117680Spst#define LLVM_SUPPORT_MEMORYOBJECT_H 1217680Spst 1317680Spst#include "llvm/Support/DataTypes.h" 1417680Spst 1517680Spstnamespace llvm { 1617680Spst 1717680Spst/// MemoryObject - Abstract base class for contiguous addressable memory. 1817680Spst/// Necessary for cases in which the memory is in another process, in a 1917680Spst/// file, or on a remote machine. 2057278Sfenner/// All size and offset parameters are uint64_ts, to allow 32-bit processes 2157278Sfenner/// access to 64-bit address spaces. 2217680Spstclass MemoryObject { 2317680Spstpublic: 2417680Spst /// Destructor - Override as necessary. 2526180Sfenner virtual ~MemoryObject(); 2656893Sfenner 2717680Spst /// getBase - Returns the lowest valid address in the region. 2817680Spst /// 2956893Sfenner /// @result - The lowest valid address. 3056893Sfenner virtual uint64_t getBase() const = 0; 3156893Sfenner 3256893Sfenner /// getExtent - Returns the size of the region in bytes. (The region is 3317680Spst /// contiguous, so the highest valid address of the region 3417680Spst /// is getBase() + getExtent() - 1). 3517680Spst /// 3617680Spst /// @result - The size of the region. 3717680Spst virtual uint64_t getExtent() const = 0; 3817680Spst 3917680Spst /// readByte - Tries to read a single byte from the region. 4017680Spst /// 4156893Sfenner /// @param address - The address of the byte, in the same space as getBase(). 4256893Sfenner /// @param ptr - A pointer to a byte to be filled in. Must be non-NULL. 4356893Sfenner /// @result - 0 if successful; -1 if not. Failure may be due to a 4456893Sfenner /// bounds violation or an implementation-specific error. 4556893Sfenner virtual int readByte(uint64_t address, uint8_t *ptr) const = 0; 4656893Sfenner 4756893Sfenner /// readBytes - Tries to read a contiguous range of bytes from the 4857278Sfenner /// region, up to the end of the region. 4957278Sfenner /// You should override this function if there is a quicker 5056893Sfenner /// way than going back and forth with individual bytes. 5156893Sfenner /// 5256893Sfenner /// @param address - The address of the first byte, in the same space as 5356893Sfenner /// getBase(). 5457278Sfenner /// @param size - The number of bytes to copy. 5557278Sfenner /// @param buf - A pointer to a buffer to be filled in. Must be non-NULL 5656893Sfenner /// and large enough to hold size bytes. 5756893Sfenner /// @result - 0 if successful; -1 if not. Failure may be due to a 5856893Sfenner /// bounds violation or an implementation-specific error. 5956893Sfenner virtual int readBytes(uint64_t address, uint64_t size, uint8_t *buf) const; 6056893Sfenner}; 6117680Spst 6217680Spst} 6317680Spst 6417680Spst#endif 6517680Spst