1 //===- MemoryObject.h - Abstract memory interface ---------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_SUPPORT_MEMORYOBJECT_H
11 #define LLVM_SUPPORT_MEMORYOBJECT_H
13 #include "llvm/Support/DataTypes.h"
17 /// Abstract base class for contiguous addressable memory. Necessary for cases
18 /// in which the memory is in another process, in a file, or on a remote
19 /// machine. All size and offset parameters are uint64_ts, to allow 32-bit
20 /// processes access to 64-bit address spaces.
23 virtual ~MemoryObject();
25 /// Returns the size of the region in bytes. (The region is contiguous, so
26 /// the highest valid address of the region is getExtent() - 1).
28 /// @result - The size of the region.
29 virtual uint64_t getExtent() const = 0;
31 /// Tries to read a contiguous range of bytes from the region, up to the end
32 /// of the region. You should override this function if there is a quicker way
33 /// than going back and forth with individual bytes.
35 /// @param address - The address of the first byte, in the same space as
37 /// @param size - The number of bytes to copy.
38 /// @param buf - A pointer to a buffer to be filled in. Must be non-NULL
39 /// and large enough to hold size bytes.
40 /// @result - 0 if successful; -1 if not. Failure may be due to a
41 /// bounds violation or an implementation-specific error.
42 virtual int readBytes(uint64_t address, uint64_t size,
43 uint8_t *buf) const = 0;