10 #ifndef LLVM_SUPPORT_STREAMINGMEMORYOBJECT_H
11 #define LLVM_SUPPORT_STREAMINGMEMORYOBJECT_H
29 uint64_t
readBytes(uint8_t *Buf, uint64_t Size,
30 uint64_t
Address)
const override;
54 const static uint32_t kChunkSize = 4096 * 4;
55 mutable std::vector<unsigned char> Bytes;
56 std::unique_ptr<DataStreamer> Streamer;
57 mutable size_t BytesRead;
59 mutable size_t ObjectSize;
60 mutable bool EOFReached;
68 bool fetchToPos(
size_t Pos)
const {
69 while (Pos >= BytesRead) {
72 Bytes.resize(BytesRead + BytesSkipped + kChunkSize);
73 size_t bytes = Streamer->GetBytes(&Bytes[BytesRead + BytesSkipped],
78 ObjectSize = BytesRead;
82 return !ObjectSize || Pos < ObjectSize;
90 const unsigned char *Start,
const unsigned char *End);
93 #endif // STREAMINGMEMORYOBJECT_H_
bool isValidAddress(uint64_t address) const override
Returns true if the address is within the object (i.e.
uint64_t getExtent() const override
Returns the size of the region in bytes.
Interface to data which might be streamed.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
uint64_t readBytes(uint8_t *Buf, uint64_t Size, uint64_t Address) const override
Tries to read a contiguous range of bytes from the region, up to the end of the region.
void setKnownObjectSize(size_t size)
If the data object size is known in advance, many of the operations can be made more efficient...
Interface to data which is actually streamed from a DataStreamer.
const uint8_t * getPointer(uint64_t address, uint64_t size) const override
Ensures that the requested data is in memory, and returns a pointer to it.
StreamingMemoryObject(std::unique_ptr< DataStreamer > Streamer)
bool dropLeadingBytes(size_t s)
Drop s bytes from the front of the stream, pushing the positions of the remaining bytes down by s...
MemoryObject * getNonStreamedMemoryObject(const unsigned char *Start, const unsigned char *End)