LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
llvm::StreamableMemoryObject Class Referenceabstract

#include <StreamableMemoryObject.h>

Inheritance diagram for llvm::StreamableMemoryObject:
Inheritance graph
[legend]
Collaboration diagram for llvm::StreamableMemoryObject:
Collaboration graph
[legend]

Public Member Functions

virtual ~StreamableMemoryObject ()
 Destructor - Override as necessary. More...
 
virtual uint64_t getBase () const LLVM_OVERRIDE=0
 
virtual uint64_t getExtent () const LLVM_OVERRIDE=0
 
virtual int readByte (uint64_t address, uint8_t *ptr) const LLVM_OVERRIDE=0
 
virtual int readBytes (uint64_t address, uint64_t size, uint8_t *buf) const LLVM_OVERRIDE=0
 
virtual const uint8_t * getPointer (uint64_t address, uint64_t size) const =0
 
virtual bool isValidAddress (uint64_t address) const =0
 
virtual bool isObjectEnd (uint64_t address) const =0
 
- Public Member Functions inherited from llvm::MemoryObject
virtual ~MemoryObject ()
 Destructor - Override as necessary. More...
 

Detailed Description

StreamableMemoryObject - Interface to data which might be streamed. Streamability has 2 important implications/restrictions. First, the data might not yet exist in memory when the request is made. This just means that readByte/readBytes might have to block or do some work to get it. More significantly, the exact size of the object might not be known until it has all been fetched. This means that to return the right result, getExtent must also wait for all the data to arrive; therefore it should not be called on objects which are actually streamed (this would defeat the purpose of streaming). Instead, isValidAddress and isObjectEnd can be used to test addresses without knowing the exact size of the stream. Finally, getPointer can be used instead of readBytes to avoid extra copying.

Definition at line 33 of file StreamableMemoryObject.h.

Constructor & Destructor Documentation

llvm::StreamableMemoryObject::~StreamableMemoryObject ( )
virtual

Destructor - Override as necessary.

Definition at line 134 of file StreamableMemoryObject.cpp.

Member Function Documentation

virtual uint64_t llvm::StreamableMemoryObject::getBase ( ) const
pure virtual

getBase - Returns the lowest valid address in the region.

Returns
- The lowest valid address.

Implements llvm::MemoryObject.

Implemented in llvm::StreamingMemoryObject.

virtual uint64_t llvm::StreamableMemoryObject::getExtent ( ) const
pure virtual

getExtent - Returns the size of the region in bytes. (The region is contiguous, so the highest valid address of the region is getBase() + getExtent() - 1). May block until all bytes in the stream have been read

Returns
- The size of the region.

Implements llvm::MemoryObject.

Implemented in llvm::StreamingMemoryObject.

Referenced by llvm::BitstreamCursor::readRecord(), and llvm::BitstreamCursor::skipRecord().

virtual const uint8_t* llvm::StreamableMemoryObject::getPointer ( uint64_t  address,
uint64_t  size 
) const
pure virtual

getPointer - Ensures that the requested data is in memory, and returns A pointer to it. More efficient than using readBytes if the data is already in memory. May block until (address - base + size) bytes have been read

Parameters
address- address of the byte, in the same space as getBase()
size- amount of data that must be available on return
Returns
- valid pointer to the requested data

Implemented in llvm::StreamingMemoryObject.

Referenced by llvm::BitstreamCursor::readRecord().

virtual bool llvm::StreamableMemoryObject::isObjectEnd ( uint64_t  address) const
pure virtual

isObjectEnd - Returns true if the address is one past the end of the object (i.e. if it is equal to base + extent) May block until (address - base) bytes have been read

Parameters
address- address of the byte, in the same space as getBase()
Returns
- true if the address is equal to base + extent

Implemented in llvm::StreamingMemoryObject.

Referenced by llvm::BitstreamCursor::isEndPos().

virtual bool llvm::StreamableMemoryObject::isValidAddress ( uint64_t  address) const
pure virtual

isValidAddress - Returns true if the address is within the object (i.e. between base and base + extent - 1 inclusive) May block until (address - base) bytes have been read

Parameters
address- address of the byte, in the same space as getBase()
Returns
- true if the address may be read with readByte()

Implemented in llvm::StreamingMemoryObject.

Referenced by llvm::BitstreamCursor::canSkipToPos().

virtual int llvm::StreamableMemoryObject::readByte ( uint64_t  address,
uint8_t *  ptr 
) const
pure virtual

readByte - Tries to read a single byte from the region. May block until (address - base) bytes have been read

Parameters
address- The address of the byte, in the same space as getBase().
ptr- A pointer to a byte to be filled in. Must be non-NULL.
Returns
- 0 if successful; -1 if not. Failure may be due to a bounds violation or an implementation-specific error.

Implements llvm::MemoryObject.

Implemented in llvm::StreamingMemoryObject.

virtual int llvm::StreamableMemoryObject::readBytes ( uint64_t  address,
uint64_t  size,
uint8_t *  buf 
) const
pure virtual

readBytes - Tries to read a contiguous range of bytes from the region, up to the end of the region. May block until (address - base + size) bytes have been read. Additionally, StreamableMemoryObjects will not do partial reads - if size bytes cannot be read, readBytes will fail.

Parameters
address- The address of the first byte, in the same space as getBase().
size- The number of bytes to copy.
buf- A pointer to a buffer to be filled in. Must be non-NULL and large enough to hold size bytes.
Returns
- 0 if successful; -1 if not. Failure may be due to a bounds violation or an implementation-specific error.

Reimplemented from llvm::MemoryObject.

Implemented in llvm::StreamingMemoryObject.

Referenced by llvm::BitstreamCursor::getWord(), and llvm::BitstreamCursor::Read().


The documentation for this class was generated from the following files: