ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MemoryMap::ExternBuffer Class Reference

Buffer of data owned by someone else. More...

#include <MemoryMap.h>

Inheritance diagram for MemoryMap::ExternBuffer:
Collaboration diagram for MemoryMap::ExternBuffer:

Public Member Functions

virtual BufferPtr clone () const
 Create a new buffer from an existing buffer. More...
 
virtual void resize (size_t n)
 Size of buffer in bytes. More...
 
virtual const void * get_data_ptr () const
 Return pointer to low-level data. More...
 
virtual size_t read (void *, size_t offset, size_t nbytes) const
 Reads data from a buffer. More...
 
virtual size_t write (const void *, size_t offset, size_t nbytes)
 Writes data into a buffer. More...
 
- Public Member Functions inherited from MemoryMap::Buffer
virtual ~Buffer ()
 
virtual void save (const std::string &filename) const
 Saves data to a file. More...
 
virtual bool is_zero () const
 Returns true if the buffer's data is all zero. More...
 
virtual bool is_read_only () const
 Property indicating whether buffer is read-only. More...
 
virtual void set_read_only (bool b=true)
 Property indicating whether buffer is read-only. More...
 
void clear_read_only ()
 Property indicating whether buffer is read-only. More...
 
virtual std::string get_name () const
 Debug name for buffer. More...
 
virtual void set_name (const std::string &s)
 Debug name for buffer. More...
 
virtual size_t size () const
 Size of buffer in bytes. More...
 

Static Public Member Functions

static BufferPtr create (void *data, size_t size)
 Construct from caller-supplied data. More...
 
static BufferPtr create (const void *data, size_t size)
 Construct from caller-supplied data. More...
 

Protected Member Functions

 ExternBuffer (const uint8_t *data, size_t size)
 
 ExternBuffer (uint8_t *data, size_t size)
 
- Protected Member Functions inherited from MemoryMap::Buffer
 Buffer (size_t size)
 
std::string new_name ()
 

Protected Attributes

uint8_t * p_data
 
- Protected Attributes inherited from MemoryMap::Buffer
bool read_only
 If true, buffer data cannot be modified. More...
 
std::string name
 Name for debugging. More...
 
size_t p_size
 Size of buffer in bytes. More...
 

Detailed Description

Buffer of data owned by someone else.

The data is not deleted when the buffer is deleted. This class is mostly for backward compatibility with older versions of ROSE where memory maps never owned the data to which they pointed.

Definition at line 200 of file MemoryMap.h.

Constructor & Destructor Documentation

MemoryMap::ExternBuffer::ExternBuffer ( const uint8_t *  data,
size_t  size 
)
inlineprotected

Definition at line 217 of file MemoryMap.h.

References MemoryMap::Buffer::set_read_only().

MemoryMap::ExternBuffer::ExternBuffer ( uint8_t *  data,
size_t  size 
)
inlineprotected

Definition at line 219 of file MemoryMap.h.

Member Function Documentation

MemoryMap::BufferPtr MemoryMap::ExternBuffer::create ( void *  data,
size_t  size 
)
static

Construct from caller-supplied data.

The caller supplies a pointer to data and the size of that data. The new buffer object does not take ownership of the data or copy it, thus the caller-supplied data must continue to exist for as long as the Buffer exists. This is mostly for backward compatibility with older versions of ROSE.

Definition at line 157 of file MemoryMap.C.

Referenced by Disassembler::disassembleBlock(), Disassembler::disassembleBuffer(), Disassembler::disassembleOne(), Disassembler::disassembleSection(), and Partitioner::mark_ipd_configuration().

MemoryMap::BufferPtr MemoryMap::ExternBuffer::create ( const void *  data,
size_t  size 
)
static

Construct from caller-supplied data.

The caller supplies a pointer to data and the size of that data. The new buffer object does not take ownership of the data or copy it, thus the caller-supplied data must continue to exist for as long as the Buffer exists. This is mostly for backward compatibility with older versions of ROSE.

Definition at line 163 of file MemoryMap.C.

MemoryMap::BufferPtr MemoryMap::ExternBuffer::clone ( ) const
virtual

Create a new buffer from an existing buffer.

The new buffer will point to a different copy of the data so that writing data into one buffer will not cause it to appear when reading from the other buffer. The type of the new buffer might not be the same as this buffer because not all buffers are able to copy their data. For instance, cloning an ExternBuffer or a MmapBuffer will create a ByteBuffer.

Implements MemoryMap::Buffer.

Reimplemented in MemoryMap::AnonymousBuffer.

Definition at line 169 of file MemoryMap.C.

References MemoryMap::ByteBuffer::create(), and MemoryMap::size().

Referenced by MemoryMap::AnonymousBuffer::clone().

void MemoryMap::ExternBuffer::resize ( size_t  n)
virtual

Size of buffer in bytes.

Reimplemented from MemoryMap::Buffer.

Reimplemented in MemoryMap::MmapBuffer.

Definition at line 179 of file MemoryMap.C.

virtual const void* MemoryMap::ExternBuffer::get_data_ptr ( ) const
inlinevirtual

Return pointer to low-level data.

This probably shouldn't be used to access the data because it makes assumptions about the implementation (use read() and write() methods instead). But it is sometimes useful when trying to determine if a buffer was initialized with data known to the caller.

Implements MemoryMap::Buffer.

Reimplemented in MemoryMap::AnonymousBuffer.

Definition at line 212 of file MemoryMap.h.

References p_data.

Referenced by MemoryMap::AnonymousBuffer::get_data_ptr().

size_t MemoryMap::ExternBuffer::read ( void *  buf,
size_t  offset,
size_t  nbytes 
) const
virtual

Reads data from a buffer.

Reads up to nbytes of data from this buffer and copies it to the caller-supplied address, the buf argument. Reading starts at the specified byte offset from the beginning of this buffer. Returns the number of bytes copied. The output buffer is not zero-padded for short reads.

If buf is the null pointer, then no data is copied and the return value is the number of bytes that would have been copied if buf had not been null.

Implements MemoryMap::Buffer.

Reimplemented in MemoryMap::AnonymousBuffer.

Definition at line 186 of file MemoryMap.C.

References MemoryMap::size().

size_t MemoryMap::ExternBuffer::write ( const void *  buf,
size_t  offset,
size_t  nbytes 
)
virtual

Writes data into a buffer.

Writes up to nbytes of data from buf into this buffer starting at the specified byte offset within this buffer. Returns the number of bytes written. The return value will be less than nbytes if an error occurs.

Implements MemoryMap::Buffer.

Reimplemented in MemoryMap::AnonymousBuffer.

Definition at line 197 of file MemoryMap.C.

References MemoryMap::size().

Member Data Documentation

uint8_t* MemoryMap::ExternBuffer::p_data
mutableprotected

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