ROSE 0.11.145.267
|
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::InstructionSemantics namespace for an overview of how the parts fit together.
Definition at line 27 of file MemoryState.h.
#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryState.h>
Public Types | |
typedef MemoryStatePtr | Ptr |
Shared-ownership pointer. | |
![]() | |
using | Ptr = AddressSpacePtr |
Shared-ownership pointer. | |
using | Purpose = AddressSpacePurpose |
Purpose for the address space. | |
Public Member Functions | |
virtual MemoryStatePtr | create (const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const =0 |
Virtual allocating constructor. | |
SValuePtr | get_addr_protoval () const |
Return the address protoval. | |
SValuePtr | get_val_protoval () const |
Return the value protoval. | |
virtual void | clear ()=0 |
Clear memory. | |
virtual SValuePtr | readMemory (const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps)=0 |
Read a value from memory. | |
virtual SValuePtr | peekMemory (const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps)=0 |
Read a value from memory without side effects. | |
virtual void | writeMemory (const SValuePtr &addr, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps)=0 |
Write a value to memory. | |
MergerPtr | merger () const |
Property: Merger. | |
void | merger (const MergerPtr &) |
Property: Merger. | |
bool | byteRestricted () const |
Indicates whether memory cell values are required to be eight bits wide. | |
void | byteRestricted (bool) |
Indicates whether memory cell values are required to be eight bits wide. | |
ByteOrder::Endianness | get_byteOrder () const |
Memory byte order. | |
void | set_byteOrder (ByteOrder::Endianness) |
Memory byte order. | |
![]() | |
virtual Ptr | clone () const =0 |
Deep-copy of this address space. | |
virtual SValuePtr | read (const AddressSpaceAddress &, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps) |
Read a value from the address space. | |
virtual SValuePtr | peek (const AddressSpaceAddress &, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps) |
Read without causing side effects. | |
virtual void | write (const AddressSpaceAddress &, const SValuePtr &value, RiscOperators &addrOps, RiscOperators &valOps) |
Write a value to an address space. | |
virtual void | hash (Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const =0 |
Hash this address space. | |
virtual bool | merge (const AddressSpacePtr &other, RiscOperators *addrOps, RiscOperators *valOps)=0 |
Merge address spaces for data flow analysis. | |
std::string | printableName () const |
Printable name for this address space. | |
Purpose | purpose () const |
Property: Purpose of this address space. | |
void | purpose (Purpose) |
Property: Purpose of this address space. | |
const std::string & | name () const |
Property: Name for this address space. | |
void | name (const std::string &) |
Property: Name for this address space. | |
void | print (std::ostream &, const std::string &prefix="") const |
Print an address space. | |
virtual void | print (std::ostream &, Formatter &) const =0 |
Print an address space. | |
WithFormatter | with_format (Formatter &) |
Used for printing address spaces with formatting. | |
WithFormatter | operator+ (Formatter &) |
Used for printing address spaces with formatting. | |
WithFormatter | operator+ (const std::string &linePrefix) |
Used for printing address spaces with formatting. | |
Static Public Member Functions | |
static MemoryStatePtr | promote (const AddressSpacePtr &) |
Protected Member Functions | |
MemoryState (const SValuePtr &addrProtoval, const SValuePtr &valProtoval) | |
MemoryState (const MemoryStatePtr &other) | |
![]() | |
AddressSpace (Purpose, const std::string &name) | |
AddressSpace (const AddressSpace &) | |
AddressSpace & | operator= (const AddressSpace &)=delete |
Shared-ownership pointer.
Definition at line 30 of file MemoryState.h.
|
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::InstructionSemantics::ConcreteSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::IntervalSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryListState, Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState, Rose::BinaryAnalysis::Partitioner2::Semantics::MemoryState< Super >, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellList, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::SymbolicMemory.
MergerPtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState::merger | ( | ) | const |
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.
void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState::merger | ( | const MergerPtr & | ) |
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.
SValuePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState::get_addr_protoval | ( | ) | const |
Return the address protoval.
The address protoval is used to construct other memory addresses via its virtual constructors.
SValuePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState::get_val_protoval | ( | ) | const |
Return the value protoval.
The value protoval is used to construct other stored values via its virtual constructors.
|
pure virtual |
Clear memory.
Removes all memory cells from this memory state.
Implements Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::AddressSpace.
Implemented in Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellState, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::SymbolicMemory, Rose::BinaryAnalysis::InstructionSemantics::ConcreteSemantics::MemoryState, and Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::MemoryState.
bool Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState::byteRestricted | ( | ) | const |
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.
void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState::byteRestricted | ( | bool | ) |
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.
|
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::InstructionSemantics::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::ConcreteSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::IntervalSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryListState, Rose::BinaryAnalysis::Partitioner2::Semantics::MemoryState< Super >, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::SymbolicMemory.
|
pure virtual |
Read a value from memory without side effects.
This is similar to readMemory except there are no side effects. The memory state is not modified by this function.
Implemented in Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::ConcreteSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::IntervalSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryListState, Rose::BinaryAnalysis::Partitioner2::Semantics::MemoryState< Super >, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::SymbolicMemory.
|
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::InstructionSemantics::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::ConcreteSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::IntervalSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryListState, Rose::BinaryAnalysis::Partitioner2::Semantics::MemoryState< Super >, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::SymbolicMemory.