LLVM API Documentation

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

#include <StreamableMemoryObject.h>

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

Public Member Functions

 StreamingMemoryObject (DataStreamer *streamer)
 
virtual uint64_t getBase () const LLVM_OVERRIDE
 
virtual uint64_t getExtent () const LLVM_OVERRIDE
 
virtual int readByte (uint64_t address, uint8_t *ptr) const LLVM_OVERRIDE
 
virtual int readBytes (uint64_t address, uint64_t size, uint8_t *buf) const LLVM_OVERRIDE
 
virtual const uint8_t * getPointer (uint64_t address, uint64_t size) const LLVM_OVERRIDE
 
virtual bool isValidAddress (uint64_t address) const LLVM_OVERRIDE
 
virtual bool isObjectEnd (uint64_t address) const LLVM_OVERRIDE
 
bool dropLeadingBytes (size_t s)
 
void setKnownObjectSize (size_t size)
 
- Public Member Functions inherited from llvm::StreamableMemoryObject
virtual ~StreamableMemoryObject ()
 Destructor - Override as necessary. More...
 
- Public Member Functions inherited from llvm::MemoryObject
virtual ~MemoryObject ()
 Destructor - Override as necessary. More...
 

Detailed Description

StreamingMemoryObject - interface to data which is actually streamed from a DataStreamer. In addition to inherited members, it has the dropLeadingBytes and setKnownObjectSize methods which are not applicable to non-streamed objects.

Definition at line 105 of file StreamableMemoryObject.h.

Constructor & Destructor Documentation

llvm::StreamingMemoryObject::StreamingMemoryObject ( DataStreamer streamer)

Definition at line 136 of file StreamableMemoryObject.cpp.

References llvm::DataStreamer::GetBytes().

Member Function Documentation

bool llvm::StreamingMemoryObject::dropLeadingBytes ( size_t  s)

Drop s bytes from the front of the stream, pushing the positions of the remaining bytes down by s. This is used to skip past the bitcode header, since we don't know a priori if it's present, and we can't put bytes back into the stream once we've read them.

Definition at line 117 of file StreamableMemoryObject.cpp.

virtual uint64_t llvm::StreamingMemoryObject::getBase ( ) const
inlinevirtual

getBase - Returns the lowest valid address in the region.

Returns
- The lowest valid address.

Implements llvm::StreamableMemoryObject.

Definition at line 108 of file StreamableMemoryObject.h.

uint64_t llvm::StreamingMemoryObject::getExtent ( ) const
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::StreamableMemoryObject.

Definition at line 95 of file StreamableMemoryObject.cpp.

virtual const uint8_t* llvm::StreamingMemoryObject::getPointer ( uint64_t  address,
uint64_t  size 
) const
inlinevirtual

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

Implements llvm::StreamableMemoryObject.

Definition at line 114 of file StreamableMemoryObject.h.

bool llvm::StreamingMemoryObject::isObjectEnd ( uint64_t  address) const
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

Implements llvm::StreamableMemoryObject.

Definition at line 89 of file StreamableMemoryObject.cpp.

bool llvm::StreamingMemoryObject::isValidAddress ( uint64_t  address) const
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()

Implements llvm::StreamableMemoryObject.

Definition at line 84 of file StreamableMemoryObject.cpp.

int llvm::StreamingMemoryObject::readByte ( uint64_t  address,
uint8_t *  ptr 
) const
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::StreamableMemoryObject.

Definition at line 103 of file StreamableMemoryObject.cpp.

int llvm::StreamingMemoryObject::readBytes ( uint64_t  address,
uint64_t  size,
uint8_t *  buf 
) const
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.

Implements llvm::StreamableMemoryObject.

Definition at line 109 of file StreamableMemoryObject.cpp.

References llvm::Intrinsic::memcpy.

void llvm::StreamingMemoryObject::setKnownObjectSize ( size_t  size)

If the data object size is known in advance, many of the operations can be made more efficient, so this method should be called before reading starts (although it can be called anytime).

Definition at line 124 of file StreamableMemoryObject.cpp.


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