ROSE  0.11.145.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState Class Reference

Description

Byte-addressable memory.

This class represents an entire state of memory via a map of memory cells. The cells are indexed in the map using the hash of their symbolic virtual address, therefore querying using an address that is equal but structurally different will fail to find the cell. This memory state does not resolve aliasing. For instance, storing a value at virtual address esp + 24 and then querying ebp + 8 will always assume that they are two non-aliasing addresses unless ROSE is able to simplify one of the expressions to exactly match the other.

Although this state has less precision than the list-based state (MemoryListState), it operatates in logorithmic time instead of linear time, and by using hashing it avoids a relatively expensive comparison of address expressions at each step.

This class should not be confused with MemoryMap. The former is used by instruction semantics to represent the state of memory such as during data-flow, while the latter is a model for mapping concrete values to concrete addresses similar to how operating systems map parts of files into an address space.

See also
MemoryListState

Definition at line 707 of file SymbolicSemantics.h.

#include <Rose/BinaryAnalysis/InstructionSemantics/SymbolicSemantics.h>

Inheritance diagram for Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState:
Collaboration graph
[legend]

Public Types

using Super = BaseSemantics::MemoryCellMap
 Base type. More...
 
using Ptr = MemoryMapStatePtr
 Shared-ownership pointer. More...
 
- Public Types inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap
using Super = MemoryCellState
 Base type. More...
 
using Ptr = MemoryCellMapPtr
 Shared-ownership pointer. More...
 
typedef uint64_t CellKey
 Key used to look up memory cells. More...
 
typedef Sawyer::Container::Map< CellKey, MemoryCellPtrCellMap
 Map of memory cells indexed by cell keys. More...
 
- Public Types inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellState
using Super = MemoryState
 Base type. More...
 
using Ptr = MemoryCellStatePtr
 Shared-ownership pointer. More...
 
- Public Types inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState
typedef MemoryStatePtr Ptr
 Shared-ownership pointer. More...
 

Public Member Functions

virtual BaseSemantics::MemoryStatePtr create (const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) const override
 Virtual constructor. More...
 
virtual BaseSemantics::MemoryStatePtr create (const BaseSemantics::MemoryCellPtr &protocell) const
 Virtual constructor. More...
 
virtual BaseSemantics::MemoryStatePtr clone () const override
 Virtual copy constructor. More...
 
virtual CellKey generateCellKey (const BaseSemantics::SValuePtr &addr_) const override
 Generate a cell lookup key. More...
 
- Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap
virtual MemoryCellPtr findCell (const SValuePtr &addr) const
 Look up memory cell for address. More...
 
virtual bool isAllPresent (const SValuePtr &address, size_t nBytes, RiscOperators *addrOps) const
 Predicate to determine whether all bytes are present. More...
 
virtual void hash (Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const override
 Calculate a hash for this memory state. More...
 
virtual void clear () override
 Clear memory. More...
 
virtual bool merge (const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps) override
 Merge memory states for data flow analysis. More...
 
virtual SValuePtr readMemory (const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
 Read a value from memory. More...
 
virtual SValuePtr peekMemory (const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
 Read a value from memory without side effects. More...
 
virtual void writeMemory (const SValuePtr &address, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps) override
 Write a value to memory. More...
 
virtual void print (std::ostream &, Formatter &) const override
 Print a memory state to more than one line of output.
 
virtual std::vector< MemoryCellPtrmatchingCells (MemoryCell::Predicate &) const override
 Find all matching cells. More...
 
virtual std::vector< MemoryCellPtrleadingCells (MemoryCell::Predicate &) const override
 Find leading matching cells. More...
 
virtual void eraseMatchingCells (MemoryCell::Predicate &) override
 Remove all matching cells. More...
 
virtual void eraseLeadingCells (MemoryCell::Predicate &) override
 Remove leading matching cells. More...
 
virtual void traverse (MemoryCell::Visitor &) override
 Traverse and modify cells. More...
 
virtual AddressSet getWritersUnion (const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) override
 Writers for an address. More...
 
virtual AddressSet getWritersIntersection (const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) override
 Writers for an address. More...
 
- Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellState
virtual void updateReadProperties (const CellList &)
 Adjust I/O properties after reading memory. More...
 
virtual void updateWriteProperties (const CellList &, InputOutputPropertySet)
 Adjust I/O properties after writing memory. More...
 
void eraseNonWritten ()
 Erase cells that have no writers. More...
 
std::vector< MemoryCellPtrallCells () const
 All cells. More...
 
virtual MemoryCellPtr latestWrittenCell () const
 Property: Cell most recently written.
 
virtual void latestWrittenCell (const MemoryCellPtr &cell)
 Property: Cell most recently written.
 
- Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::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 &)
 Property: Merger. More...
 
bool byteRestricted () const
 Indicates whether memory cell values are required to be eight bits wide. More...
 
void byteRestricted (bool)
 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)
 Memory byte order.
 
void print (std::ostream &, const std::string prefix="") const
 Print a memory state to more than one line of output.
 
WithFormatter with_format (Formatter &)
 Used for printing memory states with formatting. More...
 
WithFormatter operator+ (Formatter &)
 Used for printing memory states with formatting. More...
 
WithFormatter operator+ (const std::string &linePrefix)
 Used for printing memory states with formatting. More...
 

Static Public Member Functions

static MemoryMapStatePtr instance (const BaseSemantics::MemoryCellPtr &protocell)
 Instantiates a new memory state having specified prototypical cells and value. More...
 
static MemoryMapStatePtr instance (const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval)
 Instantiates a new memory state having specified prototypical value. More...
 
static MemoryMapStatePtr instance (const MemoryMapStatePtr &other)
 Instantiates a new deep copy of an existing state. More...
 
static MemoryMapStatePtr promote (const BaseSemantics::MemoryStatePtr &x)
 Recasts a base pointer to a symbolic memory state. More...
 
- Static Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap
static MemoryCellMapPtr promote (const MemoryStatePtr &x)
 Promote a base memory state pointer to a MemoryCellMap pointer. More...
 
- Static Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellState
static MemoryCellStatePtr promote (const BaseSemantics::MemoryStatePtr &m)
 Promote a base memory state pointer to a BaseSemantics::MemoryCellState pointer. More...
 
- Static Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState
static MemoryStatePtr promote (const MemoryStatePtr &)
 

Protected Member Functions

 MemoryMapState (const BaseSemantics::MemoryCellPtr &protocell)
 
 MemoryMapState (const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval)
 
- Protected Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap
 MemoryCellMap (const MemoryCellPtr &protocell)
 
 MemoryCellMap (const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
 
 MemoryCellMap (const MemoryCellMap &)
 
- Protected Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellState
 MemoryCellState (const MemoryCellPtr &protocell)
 
 MemoryCellState (const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
 
 MemoryCellState (const MemoryCellState &other)
 
- Protected Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState
 MemoryState (const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
 
 MemoryState (const MemoryStatePtr &other)
 

Additional Inherited Members

- Protected Attributes inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap
CellMap cells
 
- Protected Attributes inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellState
MemoryCellPtr protocell
 
MemoryCellPtr latestWrittenCell_
 

Member Typedef Documentation

Base type.

Definition at line 710 of file SymbolicSemantics.h.

Shared-ownership pointer.

Definition at line 713 of file SymbolicSemantics.h.

Member Function Documentation

static MemoryMapStatePtr Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState::instance ( const BaseSemantics::MemoryCellPtr protocell)
inlinestatic

Instantiates a new memory state having specified prototypical cells and value.

Definition at line 742 of file SymbolicSemantics.h.

static MemoryMapStatePtr Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState::instance ( const BaseSemantics::SValuePtr addrProtoval,
const BaseSemantics::SValuePtr valProtoval 
)
inlinestatic

Instantiates a new memory state having specified prototypical value.

This constructor uses BaseSemantics::MemoryCell as the cell type.

Definition at line 748 of file SymbolicSemantics.h.

static MemoryMapStatePtr Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState::instance ( const MemoryMapStatePtr other)
inlinestatic

Instantiates a new deep copy of an existing state.

Definition at line 754 of file SymbolicSemantics.h.

virtual BaseSemantics::MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState::create ( const BaseSemantics::SValuePtr addrProtoval,
const BaseSemantics::SValuePtr valProtoval 
) const
inlineoverridevirtual

Virtual constructor.

Creates a memory state having specified prototypical value. This constructor uses BaseSemantics::MemoryCell as the cell type.

Implements Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState.

Definition at line 763 of file SymbolicSemantics.h.

References Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryListState::instance().

virtual BaseSemantics::MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState::create ( const BaseSemantics::MemoryCellPtr protocell) const
inlinevirtual

Virtual constructor.

Creates a new memory state having specified prototypical cells and value.

Definition at line 769 of file SymbolicSemantics.h.

References Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryListState::instance().

virtual BaseSemantics::MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState::clone ( ) const
inlineoverridevirtual

Virtual copy constructor.

Creates a new deep copy of this memory state.

Implements Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState.

Definition at line 774 of file SymbolicSemantics.h.

static MemoryMapStatePtr Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState::promote ( const BaseSemantics::MemoryStatePtr x)
inlinestatic

Recasts a base pointer to a symbolic memory state.

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

Definition at line 783 of file SymbolicSemantics.h.

virtual CellKey Rose::BinaryAnalysis::InstructionSemantics::SymbolicSemantics::MemoryMapState::generateCellKey ( const BaseSemantics::SValuePtr address) const
overridevirtual

Generate a cell lookup key.

Generates a key from a virtual address. The key is used to look up the cell in a map-based container.

Implements Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCellMap.


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