ROSE  0.9.9.109
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Rose::BinaryAnalysis::InstructionSemantics2::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::InstructionSemantics2 namespace for an overview of how the parts fit together.

Definition at line 758 of file BaseSemantics2.h.

#include <BaseSemantics2.h>

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

Classes

class  WithFormatter
 RegisterState with formatter. More...
 

Public Types

typedef RegisterStatePtr Ptr
 Shared-ownership pointer for a RegisterState object. More...
 

Public Member Functions

virtual RegisterStatePtr create (const SValuePtr &protoval, const RegisterDictionary *regdict) const =0
 Virtual constructor. More...
 
virtual RegisterStatePtr clone () const =0
 Make a copy of this register state. More...
 
SValuePtr protoval () const
 Return the protoval. More...
 
SValuePtr get_protoval () const ROSE_DEPRECATED("use protoval instead")
 
virtual void clear ()=0
 Removes stored values from the register state. More...
 
virtual void zero ()=0
 Set all registers to the zero. More...
 
virtual bool merge (const RegisterStatePtr &other, RiscOperators *ops)=0
 Merge register states for data flow analysis. More...
 
virtual SValuePtr readRegister (RegisterDescriptor reg, const SValuePtr &dflt, RiscOperators *ops)=0
 Read a value from a register. More...
 
virtual void writeRegister (RegisterDescriptor reg, const SValuePtr &value, RiscOperators *ops)=0
 Write a value to a register. More...
 
MergerPtr merger () const
 Property: Merger. More...
 
void merger (const MergerPtr &m)
 Property: Merger. More...
 
const RegisterDictionaryget_register_dictionary () const
 The register dictionary should be compatible with the register dictionary used for other parts of binary analysis. More...
 
void set_register_dictionary (const RegisterDictionary *rd)
 The register dictionary should be compatible with the register dictionary used for other parts of binary analysis. More...
 
void print (std::ostream &stream, const std::string prefix="") const
 Print the register contents. More...
 
virtual void print (std::ostream &, Formatter &) const =0
 Print the register contents. More...
 
WithFormatter with_format (Formatter &fmt)
 Used for printing register states with formatting. More...
 
WithFormatter operator+ (Formatter &fmt)
 Used for printing register states with formatting. More...
 

Static Public Member Functions

static RegisterStatePtr promote (const RegisterStatePtr &x)
 

Protected Member Functions

 RegisterState (const SValuePtr &protoval, const RegisterDictionary *regdict)
 

Protected Attributes

const RegisterDictionaryregdict
 Registers that are able to be stored by this state. More...
 

Member Typedef Documentation

Shared-ownership pointer for a RegisterState object.

See Shared ownership.

Definition at line 792 of file BaseSemantics2.h.

Member Function Documentation

virtual RegisterStatePtr Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::create ( const SValuePtr protoval,
const RegisterDictionary 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::InstructionSemantics2::BaseSemantics::RegisterStateX86, Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterStateGeneric, and Rose::BinaryAnalysis::InstructionSemantics2::NullSemantics::RegisterState.

virtual RegisterStatePtr Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::clone ( ) const
pure virtual
MergerPtr Rose::BinaryAnalysis::InstructionSemantics2::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 833 of file BaseSemantics2.h.

void Rose::BinaryAnalysis::InstructionSemantics2::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 834 of file BaseSemantics2.h.

SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::protoval ( ) const
inline
const RegisterDictionary* Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::get_register_dictionary ( ) const
inline

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.

Definition at line 848 of file BaseSemantics2.h.

References regdict.

void Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::set_register_dictionary ( const RegisterDictionary rd)
inline

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.

Definition at line 849 of file BaseSemantics2.h.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::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, RegisterStateX86, which stores register values using fixed length arrays assigns new undefined values to each element of those arrays, whereas 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 RegisterStateGeneric::initialize_nonoverlapping for one way to initialize that register state.

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

virtual void Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::zero ( )
pure virtual
virtual bool Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::merge ( const RegisterStatePtr other,
RiscOperators ops 
)
pure virtual
virtual SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::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 RiscOperators::readRegister for more details.

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

virtual void Rose::BinaryAnalysis::InstructionSemantics2::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 RiscOperators::readRegister for more details.

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

void Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::print ( std::ostream &  stream,
const std::string  prefix = "" 
) const
inline

Print the register contents.

This emits one line per register and contains the register name and its value.

Definition at line 898 of file BaseSemantics2.h.

References Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::Formatter::set_line_prefix().

virtual void Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::print ( std::ostream &  ,
Formatter  
) const
pure virtual
WithFormatter Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::with_format ( Formatter fmt)
inline

Used for printing register states with formatting.

The usual way to use this is:

RegisterStatePtr obj = ...;
Formatter fmt = ...;
std::cout <<"The value is: " <<(*obj+fmt) <<"\n";

Definition at line 922 of file BaseSemantics2.h.

Referenced by operator+(), Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::MemoryState::operator+(), Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::State::operator+(), and Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RiscOperators::operator+().

WithFormatter Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::operator+ ( Formatter fmt)
inline

Used for printing register states with formatting.

The usual way to use this is:

RegisterStatePtr obj = ...;
Formatter fmt = ...;
std::cout <<"The value is: " <<(*obj+fmt) <<"\n";

Definition at line 923 of file BaseSemantics2.h.

References with_format().

Member Data Documentation

const RegisterDictionary* Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::RegisterState::regdict
protected

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