ROSE 0.11.145.192
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState Class Referenceabstract

Description

The set of all registers and their values.

RegisterState objects are allocated on the heap and reference counted. The BaseSemantics::RegisterState 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 30 of file RegisterState.h.

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

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

Public Types

using Ptr = RegisterStatePtr
 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 RegisterStatePtr create (const SValuePtr &protoval, const RegisterDictionaryPtr &regdict) const =0
 Virtual constructor.
 
SValuePtr protoval () const
 Return the protoval.
 
virtual void clear ()=0
 Removes stored values from the register state.
 
virtual void zero ()=0
 Set all registers to the zero.
 
virtual SValuePtr readRegister (RegisterDescriptor reg, const SValuePtr &dflt, RiscOperators *ops)=0
 Read a value from a register.
 
virtual SValuePtr peekRegister (RegisterDescriptor reg, const SValuePtr &dflt, RiscOperators *ops)=0
 Read a register without side effects.
 
virtual void updateReadProperties (RegisterDescriptor)=0
 Update register properties after reading a register.
 
virtual void writeRegister (RegisterDescriptor reg, const SValuePtr &value, RiscOperators *ops)=0
 Write a value to a register.
 
virtual void updateWriteProperties (RegisterDescriptor, InputOutputProperty)=0
 Update register properties after writing to a register.
 
MergerPtr merger () const
 Property: Merger.
 
void merger (const MergerPtr &m)
 Property: Merger.
 
RegisterDictionaryPtr registerDictionary () const
 Property: Register dictionary.
 
void registerDictionary (const RegisterDictionaryPtr &)
 Property: Register dictionary.
 
- Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::AddressSpace
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 RegisterStatePtr promote (const AddressSpacePtr &)
 

Protected Member Functions

 RegisterState (const SValuePtr &protoval, const RegisterDictionaryPtr &regdict)
 
- Protected Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::AddressSpace
 AddressSpace (Purpose, const std::string &name)
 
 AddressSpace (const AddressSpace &)
 
AddressSpaceoperator= (const AddressSpace &)=delete
 

Protected Attributes

RegisterDictionaryPtr regdict
 Registers that are able to be stored by this state.
 

Member Typedef Documentation

◆ Ptr

Shared-ownership pointer.

Definition at line 33 of file RegisterState.h.

Member Function Documentation

◆ create()

virtual RegisterStatePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::create ( const SValuePtr protoval,
const RegisterDictionaryPtr regdict 
) const
pure virtual

Virtual constructor.

The protoval argument must be a non-null pointer to a semantic value which will be used only to create additional instances of the value via its virtual constructors. The prototypical value is normally of the same type for all parts of a semantic analysis. The register state must be compatible with the rest of the binary analysis objects in use.

Implemented in Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::RegisterState, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterStateGeneric.

◆ merger() [1/2]

MergerPtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::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 99 of file RegisterState.h.

◆ merger() [2/2]

void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::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 100 of file RegisterState.h.

◆ protoval()

SValuePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::protoval ( ) const
inline

Return the protoval.

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

Definition at line 104 of file RegisterState.h.

◆ registerDictionary() [1/2]

RegisterDictionaryPtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::registerDictionary ( ) const

Property: Register dictionary.

The register dictionary should be compatible with the register dictionary used for other parts of binary analysis. At this time (May 2013) the dictionary is only used when printing.

◆ registerDictionary() [2/2]

void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::registerDictionary ( const RegisterDictionaryPtr )

Property: Register dictionary.

The register dictionary should be compatible with the register dictionary used for other parts of binary analysis. At this time (May 2013) the dictionary is only used when printing.

◆ clear()

virtual void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::clear ( )
pure virtual

Removes stored values from the register state.

Depending on the register state implementation, this could either store new, distinct undefined values in each register, or it could simply erase all information about stored values leaving the register state truly empty. For instance RegisterStateGeneric, which uses variable length arrays to store information about a dynamically changing set of registers, clears its arrays to zero length.

Register states can also be initialized by clearing them or by explicitly writing new values into each desired register (or both). See BaseSemantics::RegisterStateGeneric::initialize_nonoverlapping for one way to initialize that register state.

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

Implemented in Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterStateGeneric, and Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::RegisterState.

◆ zero()

virtual void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::zero ( )
pure virtual

◆ readRegister()

virtual SValuePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::readRegister ( RegisterDescriptor  reg,
const SValuePtr dflt,
RiscOperators ops 
)
pure virtual

Read a value from a register.

The register descriptor, reg, not only describes which register, but also which bits of that register (e.g., "al", "ah", "ax", "eax", and "rax" are all the same hardware register on an amd64, but refer to different parts of that register). The RISC operations are provided so that they can be used to extract the correct bits from a wider hardware register if necessary.

The dflt value is written into the register state if the register was not defined in the state. By doing this, a subsequent read of the same register will return the same value. Some register states cannot distinguish between a register that was never accessed and a register that was only read, in which case dflt is not used since all registers are already initialized.

See BaseSemantics::RiscOperators::readRegister for more details.

Implemented in Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::RegisterState, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterStateGeneric.

◆ peekRegister()

virtual SValuePtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::peekRegister ( RegisterDescriptor  reg,
const SValuePtr dflt,
RiscOperators ops 
)
pure virtual

Read a register without side effects.

This is similar to readRegister except it doesn't modify the register state in any way.

Implemented in Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::RegisterState, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterStateGeneric.

◆ updateReadProperties()

virtual void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::updateReadProperties ( RegisterDescriptor  )
pure virtual

Update register properties after reading a register.

This should be called by all implementations of BaseSemantics::RiscOperators::readRegister. Depending on the semantic domain, it usually adds the READ property to all bits of the register, and conditionally adds READ_BEFORE_WRITE and/or READ_UNINITIALIZED properties to parts of the register.

Implemented in Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterStateGeneric, and Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::RegisterState.

◆ writeRegister()

virtual void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::writeRegister ( RegisterDescriptor  reg,
const SValuePtr value,
RiscOperators ops 
)
pure virtual

Write a value to a register.

The register descriptor, reg, not only describes which register, but also which bits of that register (e.g., "al", "ah", "ax", "eax", and "rax" are all the same hardware register on an amd64, but refer to different parts of that register). The RISC operations are provided so that they can be used to insert the value bits into a wider the hardware register if necessary. See BaseSemantics::RiscOperators::readRegister for more details.

Implemented in Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::RegisterState, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterStateGeneric.

◆ updateWriteProperties()

virtual void Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::updateWriteProperties ( RegisterDescriptor  ,
InputOutputProperty   
)
pure virtual

Update register properties after writing to a register.

This should be called by all implementations of BaseSemantics::RiscOperators::writeRegister. Depending on the domain, it usually adds the WRITE or INIT property to the bits of the rgister.

Implemented in Rose::BinaryAnalysis::InstructionSemantics::NullSemantics::RegisterState, and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterStateGeneric.

Member Data Documentation

◆ regdict

RegisterDictionaryPtr Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RegisterState::regdict
protected

Registers that are able to be stored by this state.

Definition at line 40 of file RegisterState.h.


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