ROSE  0.11.101.0
Public Types | Public Member Functions | Static 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.

See also, ConcreteLocation.

Definition at line 33 of file AbstractLocation.h.

#include <Rose/BinaryAnalysis/AbstractLocation.h>

Inheritance diagram for Rose::BinaryAnalysis::AbstractLocation:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::AbstractLocation:
Collaboration graph
[legend]

Public Types

using Address = InstructionSemantics::BaseSemantics::SValuePtr
 Type of memory address. More...
 

Public Member Functions

 AbstractLocation ()
 Default constructor. More...
 
 AbstractLocation (const AbstractLocation &)
 Copy constructor. More...
 
AbstractLocationoperator= (const AbstractLocation &)
 Assignment operator. More...
 
 AbstractLocation (const Address &, size_t nBytes=0)
 Memory referent. More...
 
virtual bool isValid () const override
 Test whether this object is valid.
 
virtual std::string toString () const override
 Convert location to string. More...
 
virtual void print (std::ostream &) const override
 Output location to a stream. More...
 
virtual std::string printableName () const override
 Convert location to escaped, parsable string. More...
 
virtual bool isEqual (const Location &) const override
 Equality and inequality. More...
 
virtual bool operator< (const Location &) const override
 
virtual bool operator<= (const Location &) const override
 
virtual bool operator> (const Location &) const override
 
virtual bool operator>= (const Location &) const override
 
int compare (const AbstractLocation &other) const
 Compare two abstract locations. 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, const SmtSolverPtr &solver=SmtSolverPtr()) const
 True if two abstract locations could be aliases. More...
 
bool mustAlias (const AbstractLocation &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
 True if two abstract locations are certainly aliases. More...
 
 AbstractLocation (RegisterDescriptor)
 Register referent. More...
 
 AbstractLocation (RegisterDescriptor, const RegisterDictionaryPtr &regdict)
 Register referent. More...
 
void print (std::ostream &out, const RegisterDictionaryPtr &regdict) const
 Print an abstract location. More...
 
void print (std::ostream &out, InstructionSemantics::BaseSemantics::Formatter &fmt) const
 Print an abstract location. More...
 
void print (std::ostream &out, const RegisterDictionaryPtr &regdict, InstructionSemantics::BaseSemantics::Formatter &fmt) const
 Print an abstract location. More...
 
- Public Member Functions inherited from Rose::Location
virtual bool operator== (const Location &other) const final
 Equality and inequality. More...
 
virtual bool operator!= (const Location &other) const final
 Equality and inequality. More...
 
virtual operator bool () const final
 Test whether this object is valid.
 
virtual bool operator! () const final
 Test whether this object is empty. More...
 
virtual bool isEmpty () const final
 Test whether this object is empty. More...
 

Static Public Member Functions

static AbstractLocation parse (const std::string &)
 Parse an abstract location from a string. More...
 

Member Typedef Documentation

Type of memory address.

Definition at line 35 of file AbstractLocation.h.

Constructor & Destructor Documentation

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

Default constructor.

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

Rose::BinaryAnalysis::AbstractLocation::AbstractLocation ( const AbstractLocation )

Copy constructor.

Rose::BinaryAnalysis::AbstractLocation::AbstractLocation ( RegisterDescriptor  )
explicit

Register referent.

Constructs an abstract location that refers to a register.

Rose::BinaryAnalysis::AbstractLocation::AbstractLocation ( RegisterDescriptor  ,
const RegisterDictionaryPtr regdict 
)
explicit

Register referent.

Constructs an abstract location that refers to a register.

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

Memory referent.

Constructs an abstract location that refers to a memory location.

Member Function Documentation

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

Assignment operator.

static AbstractLocation Rose::BinaryAnalysis::AbstractLocation::parse ( const std::string &  )
static

Parse an abstract location from a string.

virtual std::string Rose::BinaryAnalysis::AbstractLocation::toString ( ) const
overridevirtual

Convert location to string.

Returns a string representation of the location. This representation is not necessarily parsable.

See also, print.

Implements Rose::Location.

virtual void Rose::BinaryAnalysis::AbstractLocation::print ( std::ostream &  ) const
overridevirtual

Output location to a stream.

The format is the same as the toString method and is not necessarily parsable.

See also, toString.

Implements Rose::Location.

virtual std::string Rose::BinaryAnalysis::AbstractLocation::printableName ( ) const
overridevirtual

Convert location to escaped, parsable string.

Returns a string that can be safely emitted to a terminal. The format should also be parsable so the parse method can create an equal object from the string.

See also, parse.

Implements Rose::Location.

virtual bool Rose::BinaryAnalysis::AbstractLocation::isEqual ( const Location other) const
overridevirtual

Equality and inequality.

Objects are equal if they are the same type and they point to the same location. Otherwise they are unequal.

The operator== is implemented in the base class only. For the expression a == b it calls both a.isEqual(b) and b.isEqual(a), returning true only if both tests return true. Subclasses should implement x.isEqual(y) by dynamic casting y to the type of x and returning true if and only if the cast succeeds and x and y point to the same location.

The operator!= is implemented in the base class as the complement of operator==.

Implements Rose::Location.

int Rose::BinaryAnalysis::AbstractLocation::compare ( const AbstractLocation other) const

Compare two abstract locations.

Returns -1 if this location is less than other, 1 if this location is greater than other, or zero if this location is equal to other.

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

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.

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

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

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

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.

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

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.

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

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.

bool Rose::BinaryAnalysis::AbstractLocation::mayAlias ( const AbstractLocation other,
const SmtSolverPtr &  solver = SmtSolverPtr() 
) 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,
const SmtSolverPtr &  solver = SmtSolverPtr() 
) 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 RegisterDictionaryPtr regdict 
) const

Print an abstract location.

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

void Rose::BinaryAnalysis::AbstractLocation::print ( std::ostream &  out,
InstructionSemantics::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.

void Rose::BinaryAnalysis::AbstractLocation::print ( std::ostream &  out,
const RegisterDictionaryPtr regdict,
InstructionSemantics::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: