LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MemoryObject.h
Go to the documentation of this file.
1 //===- MemoryObject.h - Abstract memory interface ---------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_SUPPORT_MEMORYOBJECT_H
11 #define LLVM_SUPPORT_MEMORYOBJECT_H
12 
13 #include "llvm/Support/DataTypes.h"
14 
15 namespace llvm {
16 
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.
22 class MemoryObject {
23 public:
24  /// Destructor - Override as necessary.
25  virtual ~MemoryObject();
26 
27  /// getBase - Returns the lowest valid address in the region.
28  ///
29  /// @result - The lowest valid address.
30  virtual uint64_t getBase() const = 0;
31 
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).
35  ///
36  /// @result - The size of the region.
37  virtual uint64_t getExtent() const = 0;
38 
39  /// readByte - Tries to read a single byte from the region.
40  ///
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;
46 
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.
51  ///
52  /// @param address - The address of the first byte, in the same space as
53  /// getBase().
54  /// @param size - The 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  /// @result - 0 if successful; -1 if not. Failure may be due to a
58  /// bounds violation or an implementation-specific error.
59  virtual int readBytes(uint64_t address, uint64_t size, uint8_t *buf) const;
60 };
61 
62 }
63 
64 #endif
virtual int readByte(uint64_t address, uint8_t *ptr) const =0
virtual uint64_t getExtent() const =0
virtual int readBytes(uint64_t address, uint64_t size, uint8_t *buf) const
virtual uint64_t getBase() const =0
virtual ~MemoryObject()
Destructor - Override as necessary.