ROSE 2.1.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState Class Reference

Description

Purely symbolic memory state.

This memory state stores Jvm operands and local variables. Jvm Frames, see section 2.6.

A frame is used to store data and partial results, as well as to perform dynamic linking, return values for methods, and dispatch exceptions.

A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes, whether that completion is normal or abrupt (it throws an uncaught exception). Frames are allocated from the Java Virtual Machine stack (§2.5.2) of the thread creating the frame. Each frame has its own array of local variables (§2.6.1), its own operand stack (§2.6.2), and a reference to the run-time constant pool (§2.5.5) of the class of the current method.

A frame may be extended with additional implementation-specific information, such as debugging information.

The sizes of the local variable array and the operand stack are determined at compile-time and are supplied along with the code for the method associated with the frame (§4.7.3). Thus the size of the frame data structure depends only on the implementation of the Java Virtual Machine, and the memory for these structures can be allocated simultaneously on method invocation.

Only one frame, the frame for the executing method, is active at any point in a given thread of control. This frame is referred to as the current frame, and its method is known as the current method. The class in which the current method is defined is the current class. Operations on local variables and the operand stack are typically with reference to the current frame.

A frame ceases to be current if its method invokes another method or if its method completes. When a method is invoked, a new frame is created and becomes current when control transfers to the new method. On method return, the current frame passes back the result of its method invocation, if any, to the previous frame. The current frame is then discarded as the previous frame becomes the current one.

Note that a frame created by a thread is local to that thread and cannot be referenced by any other thread. The set of all frames and their values. FrameState objects are allocated on the heap and reference counted. The BaseSemantics::FrameState 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 60 of file FrameState.h.

#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/FrameState.h>

Inheritance diagram for Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState:
Collaboration graph
[legend]

Public Types

using Super = MemoryState
 Base type.
 
using Ptr = FrameStatePtr
 Shared-ownership pointer.
 
- Public Types inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState
typedef MemoryStatePtr Ptr
 Shared-ownership pointer.
 
- Public Types inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::AddressSpace
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 override
 Virtual allocating constructor.
 
virtual AddressSpacePtr clone () const override
 Deep-copy of this address space.
 
virtual bool merge (const AddressSpacePtr &other, RiscOperators *addrOps, RiscOperators *valOps) override
 Merge address spaces for data flow analysis.
 
virtual void clear () override
 Clear memory.
 
virtual SValuePtr readMemory (const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
 Read a value from memory.
 
virtual void writeMemory (const SValuePtr &address, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps) override
 Write a value to memory.
 
virtual SValuePtr peekMemory (const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
 Read a value from memory without side effects.
 
SValuePtr readLocal (uint8_t index) override
 
void writeLocal (uint8_t index, const SValuePtr &value) override
 
SValuePtr popOperand () override
 Pop an operand value from a frame.
 
void pushOperand (const SValuePtr &value) override
 Push an operand value to a frame.
 
virtual void hash (Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const override
 Hash this address space.
 
virtual void print (std::ostream &, Formatter &) const override
 Print an address space.
 
- Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState
SValuePtr get_addr_protoval () const
 Return the address protoval.
 
SValuePtr get_val_protoval () const
 Return the value protoval.
 
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.
 
- Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::AddressSpace
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.
 
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.
 
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 FrameStatePtr instance (const SValuePtr &valProtoval)
 Instantiate a new empty frame state on the heap.
 
static FrameStatePtr promote (const AddressSpacePtr &)
 Convert pointer to a FrameState pointer.
 
- Static Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState
static MemoryStatePtr promote (const AddressSpacePtr &)
 

Protected Member Functions

 FrameState (const SValuePtr &valProtoval)
 
- Protected Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState
 MemoryState (Purpose, const std::string &name, const SValuePtr &valProtoval)
 
 MemoryState (const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
 
 MemoryState (const MemoryStatePtr &other)
 
- Protected Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::AddressSpace
 AddressSpace (Purpose, const std::string &name)
 
 AddressSpace (const AddressSpace &)
 
AddressSpaceoperator= (const AddressSpace &)=delete
 

Member Typedef Documentation

◆ Super

Base type.

Definition at line 63 of file FrameState.h.

◆ Ptr

Shared-ownership pointer.

Definition at line 66 of file FrameState.h.

Member Function Documentation

◆ create()

virtual MemoryStatePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::create ( const SValuePtr addrProtoval,
const SValuePtr valProtoval 
) const
overridevirtual

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.

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

◆ clone()

virtual AddressSpacePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::clone ( ) const
overridevirtual

◆ promote()

static FrameStatePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::promote ( const AddressSpacePtr )
static

Convert pointer to a FrameState pointer.

Converts x to a FrameStatePtr and asserts that it is non-null.

◆ merge()

virtual bool Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::merge ( const AddressSpacePtr other,
RiscOperators addrOps,
RiscOperators valOps 
)
overridevirtual

Merge address spaces for data flow analysis.

Merges the other address space into this address space, returning true if this space changed.

Implements Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::AddressSpace.

◆ clear()

virtual void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::clear ( )
overridevirtual

Clear memory.

Removes all memory cells from this memory state.

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

◆ readMemory()

virtual SValuePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::readMemory ( const SValuePtr address,
const SValuePtr dflt,
RiscOperators addrOps,
RiscOperators valOps 
)
overridevirtual

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::InstructionSemantics::BaseSemantics::MemoryState.

◆ writeMemory()

virtual void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::writeMemory ( const SValuePtr addr,
const SValuePtr value,
RiscOperators addrOps,
RiscOperators valOps 
)
overridevirtual

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::InstructionSemantics::BaseSemantics::MemoryState.

◆ peekMemory()

virtual SValuePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::peekMemory ( const SValuePtr address,
const SValuePtr dflt,
RiscOperators addrOps,
RiscOperators valOps 
)
overridevirtual

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.

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

◆ readLocal()

SValuePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::readLocal ( uint8_t  index)
overridevirtual

◆ writeLocal()

void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::writeLocal ( uint8_t  index,
const SValuePtr value 
)
overridevirtual

◆ popOperand()

SValuePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::popOperand ( )
overridevirtual

Pop an operand value from a frame.

Reimplemented from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState.

◆ pushOperand()

void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::pushOperand ( const SValuePtr value)
overridevirtual

Push an operand value to a frame.

Reimplemented from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryState.

◆ hash()

virtual void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::hash ( Combinatorics::Hasher ,
RiscOperators addrOps,
RiscOperators valOps 
) const
overridevirtual

Hash this address space.

Hashes this address space by appending its data to the specified hasher. The goal is to identify when two address spaces are the "same" and allow certain kinds of analyses to take shortcuts. The address space purpose and name are not included in the hash. Separate RISC operators are passed for the addresses and values of this address space and are used if the hashing requires any operations on the addresses or values.

Implements Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::AddressSpace.

◆ print()

virtual void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::FrameState::print ( std::ostream &  ,
Formatter  
) const
overridevirtual

Print an address space.

The output most likely occupies more than one line and each emitted line will be terminated with a line feed.

Implements Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::AddressSpace.


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