ROSE  0.9.9.168
Public Types | Public Member Functions | List of all members
Rose::BinaryAnalysis::AbstractLocation Class Reference

Description

Abstract location.

An abstract location represents either a register name or memory address. Registers are represented by RegisterDescriptor and addresses are represented by semantic values (subclasses of BaseSemantics::SValue).

For instance, to represent abstract locations where memory addresses have symbolic values, one uses:

using namespace Rose::BinaryAnalysis;
AbstractLocation aloc1(REG_EAX); // REG_EAX is a RegisterDescriptor
AbstractLocation aloc2(addr); // addr is an SValuePtr for the symbolic semantics domain

Abstract locations are immutable objects.

Definition at line 23 of file AbstractLocation.h.

#include <AbstractLocation.h>

Public Types

typedef InstructionSemantics2::BaseSemantics::SValuePtr Address
 Type of memory address. More...
 

Public Member Functions

 AbstractLocation ()
 Default constructor. More...
 
 AbstractLocation (const AbstractLocation &other)
 Copy constructor. More...
 
 AbstractLocation (RegisterDescriptor reg, const RegisterDictionary *regdict=NULL)
 Register referent. More...
 
 AbstractLocation (const Address &addr, size_t nBytes=0)
 Memory referent. More...
 
AbstractLocationoperator= (const AbstractLocation &other)
 Assignment operator. More...
 
bool isValid () const
 Validity checker. More...
 
bool isRegister () const
 Checks register reference. More...
 
bool isAddress () const
 Checks memory reference. More...
 
RegisterDescriptor getRegister () const
 Returns register. More...
 
const Address getAddress () const
 Returns memory address. More...
 
size_t nBytes () const
 Returns size of memory location in bytes. More...
 
bool mayAlias (const AbstractLocation &other, SmtSolver *solver=NULL) const
 True if two abstract locations could be aliases. More...
 
bool mustAlias (const AbstractLocation &other, SmtSolver *solver=NULL) const
 True if two abstract locations are certainly aliases. More...
 
void print (std::ostream &out, const RegisterDictionary *regdict=NULL) const
 Print an abstract location. More...
 
void print (std::ostream &out, InstructionSemantics2::BaseSemantics::Formatter &fmt) const
 Print an abstract location. More...
 
void print (std::ostream &out, const RegisterDictionary *regdict, InstructionSemantics2::BaseSemantics::Formatter &fmt) const
 Print an abstract location. More...
 

Member Typedef Documentation

Type of memory address.

Definition at line 25 of file AbstractLocation.h.

Constructor & Destructor Documentation

Rose::BinaryAnalysis::AbstractLocation::AbstractLocation ( )
inline

Default constructor.

Constructs an abstract location that does not refer to any location. The isValid method will return true for such objects.

Definition at line 38 of file AbstractLocation.h.

Rose::BinaryAnalysis::AbstractLocation::AbstractLocation ( const AbstractLocation other)
inline

Copy constructor.

Definition at line 41 of file AbstractLocation.h.

Rose::BinaryAnalysis::AbstractLocation::AbstractLocation ( RegisterDescriptor  reg,
const RegisterDictionary regdict = NULL 
)
inlineexplicit

Register referent.

Constructs an abstract location that refers to a register.

Definition at line 47 of file AbstractLocation.h.

Rose::BinaryAnalysis::AbstractLocation::AbstractLocation ( const Address addr,
size_t  nBytes = 0 
)
inlineexplicit

Memory referent.

Constructs an abstract location that refers to a memory location.

Definition at line 53 of file AbstractLocation.h.

Member Function Documentation

AbstractLocation& Rose::BinaryAnalysis::AbstractLocation::operator= ( const AbstractLocation other)
inline

Assignment operator.

Definition at line 56 of file AbstractLocation.h.

bool Rose::BinaryAnalysis::AbstractLocation::isValid ( ) const
inline

Validity checker.

Returns true if this abstract location refers to either a register or a memory location. Default constructed abstract locations refer to neither, as do locations that have both an invalid register descriptor and a null memory address.

Definition at line 68 of file AbstractLocation.h.

References isAddress(), and isRegister().

bool Rose::BinaryAnalysis::AbstractLocation::isRegister ( ) const
inline

Checks register reference.

Returns true if and only if this abstract location refers to a register. It is impossible for an abstract location to refer to both a register and memory.

Definition at line 74 of file AbstractLocation.h.

Referenced by isValid().

bool Rose::BinaryAnalysis::AbstractLocation::isAddress ( ) const
inline

Checks memory reference.

Returns true if and only if this abstract location refers to memory. It is impossible for an abstract location to refer to both a register and memory

Definition at line 80 of file AbstractLocation.h.

Referenced by isValid(), and nBytes().

RegisterDescriptor Rose::BinaryAnalysis::AbstractLocation::getRegister ( ) const
inline

Returns register.

Returns the register to which this abstract location refers. When called for an abstract location for which isRegister returns false, the return value is an invalid register descriptor (i.e., one for which RegisterDescriptor::is_valid returns false.

Definition at line 87 of file AbstractLocation.h.

const Address Rose::BinaryAnalysis::AbstractLocation::getAddress ( ) const
inline

Returns memory address.

Returns the memory address to which this abstract location refers. When called for an abstract location for which isAddress returns false, the return value is a null pointer.

Definition at line 93 of file AbstractLocation.h.

size_t Rose::BinaryAnalysis::AbstractLocation::nBytes ( ) const
inline

Returns size of memory location in bytes.

Returns the size of the memory location in bytes if known, otherwise zero. It is not valid to call this for an abstract location that points to a register since registers are not always a multiple of the byte size.

Definition at line 99 of file AbstractLocation.h.

References isAddress().

bool Rose::BinaryAnalysis::AbstractLocation::mayAlias ( const AbstractLocation other,
SmtSolver solver = NULL 
) const

True if two abstract locations could be aliases.

Two abstract locations are aliases if they refer to the exact same register or memory address. By this definition, the AX and EAX registers in x86 are not aliases because they do not refer to the exact same register (one is 16 bits and the other is 32 bits, although the low-order 16 bits are aliases). Likewise, memory addresses are assumed to refer to 8 bit values and two memory addresses are aliases only when they are equal.

Since memory addresses may be symbolic, this function uses an SMT solver to return true if and only if equality of two addresses is satisfiable.

bool Rose::BinaryAnalysis::AbstractLocation::mustAlias ( const AbstractLocation other,
SmtSolver solver = NULL 
) const

True if two abstract locations are certainly aliases.

Two abstract locations are aliases if they refer to the exact same register or memory address. By this definition, the AX and EAX registers in x86 are not aliases because they do not refer to the exact same register (one is 16 bits and the other is 32 bits, although the low-order 16 bits are aliases). Likewise, memory addresses are assumed to refer to 8 bit values and two memory addresses are aliases only when they are equal.

Since memory addresses may be symbolic, this function uses an SMT solver to return true if and only if the inequality of two addresses is unsatisfiable.

void Rose::BinaryAnalysis::AbstractLocation::print ( std::ostream &  out,
const RegisterDictionary regdict = NULL 
) const
inline

Print an abstract location.

The optional register dictionary is used for register names, the optional formatter is used for memory address expressions.

Definition at line 129 of file AbstractLocation.h.

Referenced by print().

void Rose::BinaryAnalysis::AbstractLocation::print ( std::ostream &  out,
InstructionSemantics2::BaseSemantics::Formatter fmt 
) const
inline

Print an abstract location.

The optional register dictionary is used for register names, the optional formatter is used for memory address expressions.

Definition at line 133 of file AbstractLocation.h.

References print().

void Rose::BinaryAnalysis::AbstractLocation::print ( std::ostream &  out,
const RegisterDictionary regdict,
InstructionSemantics2::BaseSemantics::Formatter fmt 
) const

Print an abstract location.

The optional register dictionary is used for register names, the optional formatter is used for memory address expressions.


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