ROSE  0.9.9.139
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState Class Referenceabstract

Description

Represents all memory in the state.

MemoryState objects are allocated on the heap and reference counted. The BaseSemantics::MemoryState is an abstract class that defines the interface. See the Rose::BinaryAnalysis::InstructionSemantics2 namespace for an overview of how the parts fit together.

Definition at line 1061 of file BaseSemantics2.h.

#include <BaseSemantics2.h>

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

Classes

class  WithFormatter
 MemoryState with formatter. More...
 

Public Types

typedef MemoryStatePtr Ptr
 Shared-ownership pointer for a MemoryState. More...
 

Public Member Functions

virtual MemoryStatePtr create (const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const =0
 Virtual allocating constructor. More...
 
virtual MemoryStatePtr clone () const =0
 Virtual allocating copy constructor. More...
 
SValuePtr get_addr_protoval () const
 Return the address protoval. More...
 
SValuePtr get_val_protoval () const
 Return the value protoval. More...
 
virtual void clear ()=0
 Clear memory. More...
 
virtual bool merge (const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps)=0
 Merge memory states for data flow analysis. More...
 
virtual SValuePtr readMemory (const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps)=0
 Read a value from memory. More...
 
virtual void writeMemory (const SValuePtr &addr, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps)=0
 Write a value to memory. 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.
 
virtual void print (std::ostream &, Formatter &) const =0
 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 promote (const MemoryStatePtr &x)
 

Protected Member Functions

 MemoryState (const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
 
 MemoryState (const MemoryStatePtr &other)
 

Member Typedef Documentation

Shared-ownership pointer for a MemoryState.

See Shared ownership.

Definition at line 1104 of file BaseSemantics2.h.

Member Function Documentation

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

Virtual allocating constructor.

Allocates and constructs a new MemoryState object having the same dynamic type as this object. A prototypical SValue must be supplied and will be used to construct any additional SValue objects needed during the operation of a MemoryState. Two prototypical values are supplied, one for addresses and another for values stored at those addresses, although they will almost always be the same.

Implemented in Rose::BinaryAnalysis::InstructionSemantics2::SymbolicSemantics::MemoryMapState, Rose::BinaryAnalysis::InstructionSemantics2::SymbolicSemantics::MemoryListState, Rose::BinaryAnalysis::InstructionSemantics2::IntervalSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics2::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryCellList, and Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SymbolicMemory.

virtual MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::clone ( ) const
pure virtual
MergerPtr Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::merger ( ) const
inline

Property: Merger.

This property is optional details about how to merge two states. It is passed down to the register and memory state merge operation and to the semantic value merge operation. Users can subclass this to hold whatever information is necessary for merging. Unless the user overrides merge functions to do something else, all merging will use the same merger object – the one set for this property.

Definition at line 1145 of file BaseSemantics2.h.

void Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::merger ( const MergerPtr m)
inline

Property: Merger.

This property is optional details about how to merge two states. It is passed down to the register and memory state merge operation and to the semantic value merge operation. Users can subclass this to hold whatever information is necessary for merging. Unless the user overrides merge functions to do something else, all merging will use the same merger object – the one set for this property.

Definition at line 1146 of file BaseSemantics2.h.

SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::get_addr_protoval ( ) const
inline

Return the address protoval.

The address protoval is used to construct other memory addresses via its virtual constructors.

Definition at line 1151 of file BaseSemantics2.h.

SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::get_val_protoval ( ) const
inline

Return the value protoval.

The value protoval is used to construct other stored values via its virtual constructors.

Definition at line 1155 of file BaseSemantics2.h.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::clear ( )
pure virtual
bool Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::byteRestricted ( ) const
inline

Indicates whether memory cell values are required to be eight bits wide.

The default is true since this simplifies the calculations for whether two memory cells are alias and how to combine the value from two or more aliasing cells. A memory that contains only eight-bit values requires that the caller concatenate/extract individual bytes when reading/writing multi-byte values.

Definition at line 1167 of file BaseSemantics2.h.

void Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::byteRestricted ( bool  b)
inline

Indicates whether memory cell values are required to be eight bits wide.

The default is true since this simplifies the calculations for whether two memory cells are alias and how to combine the value from two or more aliasing cells. A memory that contains only eight-bit values requires that the caller concatenate/extract individual bytes when reading/writing multi-byte values.

Definition at line 1168 of file BaseSemantics2.h.

virtual bool Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::merge ( const MemoryStatePtr other,
RiscOperators addrOps,
RiscOperators valOps 
)
pure virtual
virtual SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::readMemory ( const SValuePtr address,
const SValuePtr dflt,
RiscOperators addrOps,
RiscOperators valOps 
)
pure 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.

Implemented in Rose::BinaryAnalysis::InstructionSemantics2::SymbolicSemantics::MemoryListState, Rose::BinaryAnalysis::InstructionSemantics2::IntervalSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics2::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryCellMap, and Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SymbolicMemory.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::writeMemory ( const SValuePtr addr,
const SValuePtr value,
RiscOperators addrOps,
RiscOperators valOps 
)
pure 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.

Implemented in Rose::BinaryAnalysis::InstructionSemantics2::SymbolicSemantics::MemoryListState, Rose::BinaryAnalysis::InstructionSemantics2::IntervalSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics2::ConcreteSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics2::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryCellMap, and Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SymbolicMemory.

WithFormatter Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::with_format ( Formatter fmt)
inline

Used for printing memory states with formatting.

The usual way to use this is:

MemoryStatePtr obj = ...;
Formatter fmt = ...;
std::cout <<"The value is: " <<(*obj+fmt) <<"\n";

Definition at line 1242 of file BaseSemantics2.h.

WithFormatter Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::operator+ ( Formatter fmt)
inline

Used for printing memory states with formatting.

The usual way to use this is:

MemoryStatePtr obj = ...;
Formatter fmt = ...;
std::cout <<"The value is: " <<(*obj+fmt) <<"\n";

Definition at line 1243 of file BaseSemantics2.h.

References Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::with_format().


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