LLVM API Documentation
00001 //===- MemoryObject.h - Abstract memory interface ---------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #ifndef LLVM_SUPPORT_MEMORYOBJECT_H 00011 #define LLVM_SUPPORT_MEMORYOBJECT_H 00012 00013 #include "llvm/Support/DataTypes.h" 00014 00015 namespace llvm { 00016 00017 /// MemoryObject - Abstract base class for contiguous addressable memory. 00018 /// Necessary for cases in which the memory is in another process, in a 00019 /// file, or on a remote machine. 00020 /// All size and offset parameters are uint64_ts, to allow 32-bit processes 00021 /// access to 64-bit address spaces. 00022 class MemoryObject { 00023 public: 00024 /// Destructor - Override as necessary. 00025 virtual ~MemoryObject(); 00026 00027 /// getBase - Returns the lowest valid address in the region. 00028 /// 00029 /// @result - The lowest valid address. 00030 virtual uint64_t getBase() const = 0; 00031 00032 /// getExtent - Returns the size of the region in bytes. (The region is 00033 /// contiguous, so the highest valid address of the region 00034 /// is getBase() + getExtent() - 1). 00035 /// 00036 /// @result - The size of the region. 00037 virtual uint64_t getExtent() const = 0; 00038 00039 /// readByte - Tries to read a single byte from the region. 00040 /// 00041 /// @param address - The address of the byte, in the same space as getBase(). 00042 /// @param ptr - A pointer to a byte to be filled in. Must be non-NULL. 00043 /// @result - 0 if successful; -1 if not. Failure may be due to a 00044 /// bounds violation or an implementation-specific error. 00045 virtual int readByte(uint64_t address, uint8_t *ptr) const = 0; 00046 00047 /// readBytes - Tries to read a contiguous range of bytes from the 00048 /// region, up to the end of the region. 00049 /// You should override this function if there is a quicker 00050 /// way than going back and forth with individual bytes. 00051 /// 00052 /// @param address - The address of the first byte, in the same space as 00053 /// getBase(). 00054 /// @param size - The number of bytes to copy. 00055 /// @param buf - A pointer to a buffer to be filled in. Must be non-NULL 00056 /// and large enough to hold size bytes. 00057 /// @result - 0 if successful; -1 if not. Failure may be due to a 00058 /// bounds violation or an implementation-specific error. 00059 virtual int readBytes(uint64_t address, uint64_t size, uint8_t *buf) const; 00060 }; 00061 00062 } 00063 00064 #endif