ROSE  0.9.9.109
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState Class Reference

Description

Byte-addressable memory.

This class represents an entire state of memory via MemoryMap, allocating new memory in units of pages (the size of a page is configurable.

Definition at line 164 of file ConcreteSemantics2.h.

#include <ConcreteSemantics2.h>

Inheritance diagram for Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState:
Collaboration graph
[legend]

Public Member Functions

virtual BaseSemantics::MemoryStatePtr create (const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) const ROSE_OVERRIDE
 Virtual constructor. More...
 
virtual BaseSemantics::MemoryStatePtr clone () const ROSE_OVERRIDE
 Virtual copy constructor. More...
 
virtual void clear () ROSE_OVERRIDE
 Clear memory. More...
 
virtual void print (std::ostream &, Formatter &) const ROSE_OVERRIDE
 Print a memory state to more than one line of output.
 
virtual BaseSemantics::SValuePtr readMemory (const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps) ROSE_OVERRIDE
 Read a value from memory. More...
 
virtual void writeMemory (const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &value, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps) ROSE_OVERRIDE
 Write a value to memory. More...
 
virtual bool merge (const BaseSemantics::MemoryStatePtr &other, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps) ROSE_OVERRIDE
 Merge memory states for data flow analysis. More...
 
const MemoryMap::Ptr memoryMap () const
 Returns the memory map. More...
 
void memoryMap (const MemoryMap::Ptr &, Sawyer::Optional< unsigned > padAccess=Sawyer::Nothing())
 Set memory map. More...
 
void allocatePage (rose_addr_t va)
 Allocate a page of memory. More...
 
rose_addr_t pageSize () const
 Size of each page of memory. More...
 
void pageSize (rose_addr_t nBytes)
 Size of each page of memory. More...
 
- Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState
SValuePtr get_addr_protoval () const
 Return the address protoval. More...
 
SValuePtr get_val_protoval () const
 Return the value protoval. More...
 
MergerPtr merger () const
 Property: Merger. More...
 
void merger (const MergerPtr &m)
 Property: Merger. More...
 
bool byteRestricted () const
 Indicates whether memory cell values are required to be eight bits wide. More...
 
void byteRestricted (bool b)
 Indicates whether memory cell values are required to be eight bits wide. More...
 
ByteOrder::Endianness get_byteOrder () const
 Memory byte order.
 
void set_byteOrder (ByteOrder::Endianness bo)
 Memory byte order.
 
void print (std::ostream &stream, const std::string prefix="") const
 Print a memory state to more than one line of output.
 
WithFormatter with_format (Formatter &fmt)
 Used for printing memory states with formatting. More...
 
WithFormatter operator+ (Formatter &fmt)
 Used for printing memory states with formatting. More...
 

Static Public Member Functions

static MemoryStatePtr instance (const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval)
 Instantiates a new memory state having specified prototypical value. More...
 
static MemoryStatePtr instance (const MemoryStatePtr &other)
 Instantiates a new deep copy of an existing state. More...
 
static MemoryStatePtr promote (const BaseSemantics::MemoryStatePtr &x)
 Recasts a base pointer to a concrete memory state. More...
 
- Static Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState
static MemoryStatePtr promote (const MemoryStatePtr &x)
 

Protected Member Functions

 MemoryState (const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval)
 
 MemoryState (const MemoryState &other)
 
- Protected Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState
 MemoryState (const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
 
 MemoryState (const MemoryStatePtr &other)
 

Additional Inherited Members

- Public Types inherited from Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState
typedef MemoryStatePtr Ptr
 Shared-ownership pointer for a MemoryState. More...
 

Member Function Documentation

static MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::instance ( const BaseSemantics::SValuePtr addrProtoval,
const BaseSemantics::SValuePtr valProtoval 
)
inlinestatic

Instantiates a new memory state having specified prototypical value.

The addrProtoval and valProtoval must both be of ConcreteSemantics::SValue type or derived classes.

Definition at line 191 of file ConcreteSemantics2.h.

Referenced by create(), and Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::RiscOperators::instance().

static MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::instance ( const MemoryStatePtr other)
inlinestatic

Instantiates a new deep copy of an existing state.

For efficiency purposes, the data buffers are not copied immediately but rather marked as copy-on-write. However, the newly constructed memory map will have its own segments, which hold the segment names, access permissions, etc.

Definition at line 199 of file ConcreteSemantics2.h.

virtual BaseSemantics::MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::create ( const BaseSemantics::SValuePtr addrProtoval,
const BaseSemantics::SValuePtr valProtoval 
) const
inlinevirtual

Virtual constructor.

Creates a memory state having specified prototypical value, which should be of type ConcreteSemantics::SValue or subclasses.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState.

Definition at line 210 of file ConcreteSemantics2.h.

References instance().

virtual BaseSemantics::MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::clone ( ) const
inlinevirtual

Virtual copy constructor.

Creates a new deep copy of this memory state. For efficiency purposes, the data buffers are not copied immediately but rather marked as copy-on-write. However, the newly constructed memory map will have its own segments, which hold the segment names, access permissions, etc.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState.

Definition at line 220 of file ConcreteSemantics2.h.

static MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::promote ( const BaseSemantics::MemoryStatePtr x)
inlinestatic

Recasts a base pointer to a concrete memory state.

This is a checked cast that will fail if the specified pointer does not have a run-time type that is a ConcreteSemantics::MemoryState or subclass thereof.

Definition at line 229 of file ConcreteSemantics2.h.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::clear ( )
inlinevirtual

Clear memory.

Removes all memory cells from this memory state.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState.

Definition at line 238 of file ConcreteSemantics2.h.

virtual BaseSemantics::SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::readMemory ( const BaseSemantics::SValuePtr address,
const BaseSemantics::SValuePtr dflt,
BaseSemantics::RiscOperators addrOps,
BaseSemantics::RiscOperators valOps 
)
virtual

Read a value from memory.

Consults the memory represented by this MemoryState object and returns a semantic value. Depending on the semantic domain, the value can be a value that is already stored in the memory state, a supplied default value, a new value constructed from some combination of existing values and/or the default value, or anything else. For instance, in a symbolic domain the address could alias multiple existing memory locations and the implementation may choose to return a McCarthy expression. Additional data (such as SMT solvers) may be passed via the RiscOperators argument.

The size of the value being read does not necessarily need to be equal to the size of values stored in the memory state, though it typically is(1). For instance, an implementation may allow reading a 32-bit little endian value from a memory state that stores only bytes. A RiscOperators object is provided for use in these situations.

In order to support cases where an address does not match any existing location, the dflt value can be used to initialize a new memory location. The manner in which the default is used depends on the implementation. In any case, the width of the dflt value determines how much to read.

Footnote 1: A MemoryState::readMemory() call is the last in a sequence of delegations starting with RiscOperators::readMemory(). The designers of the MemoryState, State, and RiscOperators subclasses will need to coordinate to decide which layer should handle concatenating values from individual memory locations.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::writeMemory ( const BaseSemantics::SValuePtr addr,
const BaseSemantics::SValuePtr value,
BaseSemantics::RiscOperators addrOps,
BaseSemantics::RiscOperators valOps 
)
virtual

Write a value to memory.

Consults the memory represented by this MemoryState object and possibly inserts the specified value. The details of how a value is inserted into a memory state depends entirely on the implementation in a subclass and will probably be different for each semantic domain.

A MemoryState::writeMemory() call is the last in a sequence of delegations starting with RiscOperators::writeMemory(). The designers of the MemoryState, State, and RiscOperators will need to coordinate to decide which layer (if any) should handle splitting a multi-byte value into multiple memory locations.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState.

virtual bool Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::merge ( const BaseSemantics::MemoryStatePtr other,
BaseSemantics::RiscOperators addrOps,
BaseSemantics::RiscOperators valOps 
)
virtual

Merge memory states for data flow analysis.

Merges the other state into this state, returning true if this state changed.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState.

const MemoryMap::Ptr Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::memoryMap ( ) const
inline

Returns the memory map.

Definition at line 258 of file ConcreteSemantics2.h.

void Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::memoryMap ( const MemoryMap::Ptr ,
Sawyer::Optional< unsigned >  padAccess = Sawyer::Nothing() 
)

Set memory map.

If the specified map's areas are not in units of pages then padding segments will be added to this memory state. The padding segments will either have the accessibility specified by padAccess, or will have the same accessibility as the memory region being padded. All padding segments will be named "padding".

rose_addr_t Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::pageSize ( ) const
inline

Size of each page of memory.

Memory is allocated in units of the page size and aligned on page-size boundaries. The page size cannot be changed once the map contains data.

Definition at line 273 of file ConcreteSemantics2.h.

void Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::pageSize ( rose_addr_t  nBytes)

Size of each page of memory.

Memory is allocated in units of the page size and aligned on page-size boundaries. The page size cannot be changed once the map contains data.

void Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState::allocatePage ( rose_addr_t  va)

Allocate a page of memory.

The specified address will be contained in the page, which is aligned on a page boundary. Do not call this if the page is already allocated unless: it will replace the allocated page with a new one containing all zeros.


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