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 MEMORYOBJECT_H
11 #define MEMORYOBJECT_H
13 #include "llvm/System/DataTypes.h"
17 /// MemoryObject - Abstract base class for contiguous addressable memory.
18 /// Necessary for cases in which the memory is in another process, in a
19 /// file, or on a remote machine.
20 /// All size and offset parameters are uint64_ts, to allow 32-bit processes
21 /// access to 64-bit address spaces.
24 /// Destructor - Override as necessary.
25 virtual ~MemoryObject();
27 /// getBase - Returns the lowest valid address in the region.
29 /// @result - The lowest valid address.
30 virtual uint64_t getBase() const = 0;
32 /// getExtent - Returns the size of the region in bytes. (The region is
33 /// contiguous, so the highest valid address of the region
34 /// is getBase() + getExtent() - 1).
36 /// @result - The size of the region.
37 virtual uint64_t getExtent() const = 0;
39 /// readByte - Tries to read a single byte from the region.
41 /// @param address - The address of the byte, in the same space as getBase().
42 /// @param ptr - A pointer to a byte to be filled in. Must be non-NULL.
43 /// @result - 0 if successful; -1 if not. Failure may be due to a
44 /// bounds violation or an implementation-specific error.
45 virtual int readByte(uint64_t address, uint8_t* ptr) const = 0;
47 /// readBytes - Tries to read a contiguous range of bytes from the
48 /// region, up to the end of the region.
49 /// You should override this function if there is a quicker
50 /// way than going back and forth with individual bytes.
52 /// @param address - The address of the first byte, in the same space as
54 /// @param size - The maximum number of bytes to copy.
55 /// @param buf - A pointer to a buffer to be filled in. Must be non-NULL
56 /// and large enough to hold size bytes.
57 /// @param copied - A pointer to a nunber that is filled in with the number
58 /// of bytes actually read. May be NULL.
59 /// @result - 0 if successful; -1 if not. Failure may be due to a
60 /// bounds violation or an implementation-specific error.
61 virtual int readBytes(uint64_t address,
64 uint64_t* copied) const;