ROSE 0.11.145.147
|
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>
Classes | |
class | WithFormatter |
MemoryState with formatter. More... | |
Public Types | |
typedef MemoryStatePtr | Ptr |
Shared-ownership pointer. | |
Public Member Functions | |
virtual MemoryStatePtr | create (const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const =0 |
Virtual allocating constructor. | |
virtual MemoryStatePtr | clone () const =0 |
Virtual allocating copy 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 bool | merge (const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps)=0 |
Merge memory states for data flow analysis. | |
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. | |
virtual void | hash (Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const =0 |
Calculate a hash for this memory state. | |
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. | |
void | print (std::ostream &, 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 &) |
Used for printing memory states with formatting. | |
WithFormatter | operator+ (Formatter &) |
Used for printing memory states with formatting. | |
WithFormatter | operator+ (const std::string &linePrefix) |
Used for printing memory states with formatting. | |
Static Public Member Functions | |
static MemoryStatePtr | promote (const MemoryStatePtr &) |
Protected Member Functions | |
MemoryState (const SValuePtr &addrProtoval, const SValuePtr &valProtoval) | |
MemoryState (const MemoryStatePtr &other) | |
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.
|
pure virtual |
Virtual allocating copy constructor.
Creates a new MemoryState object which is a copy of this object.
Implemented in Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::SymbolicMemory, 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, and Rose::BinaryAnalysis::Partitioner2::Semantics::MemoryState< Super >.
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.
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 |
Merge memory states for data flow analysis.
Merges the other
state into this state, returning true if this state changed.
Implemented in Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::ConcreteSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::SymbolicMemory.
|
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.
|
pure virtual |
Calculate a hash for this memory state.
This hashes the addresses and values stored in memory. The goal is to be able to identify when two memory states are the "same". An analysis might be able to take shortcuts if it encounters a state that it has seen before.
Implemented in Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::ConcreteSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::SymbolicMemory.
|
pure virtual |
Print a memory state to more than one line of output.
Implemented in Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::MemoryState, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellList, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap, Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::SymbolicMemory, Rose::BinaryAnalysis::InstructionSemantics::ConcreteSemantics::MemoryState, and Rose::BinaryAnalysis::Partitioner2::Semantics::MemoryState< Super >.
WithFormatter Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState::with_format | ( | Formatter & | ) |
Used for printing memory states with formatting.
The usual way to use this is:
Since specifying a line prefix string for indentation purposes is such a common use case, the indentation can be given instead of a format, as in the following code that indents the prefixes each line of the expression with four spaces.
WithFormatter Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState::operator+ | ( | Formatter & | ) |
Used for printing memory states with formatting.
The usual way to use this is:
Since specifying a line prefix string for indentation purposes is such a common use case, the indentation can be given instead of a format, as in the following code that indents the prefixes each line of the expression with four spaces.
WithFormatter Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState::operator+ | ( | const std::string & | linePrefix | ) |
Used for printing memory states with formatting.
The usual way to use this is:
Since specifying a line prefix string for indentation purposes is such a common use case, the indentation can be given instead of a format, as in the following code that indents the prefixes each line of the expression with four spaces.