ROSE 0.11.145.192
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
Binary analysis.

Abstract locations are immutable objects.

See also, ConcreteLocation.

Definition at line 32 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.
 

Public Member Functions

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

Static Public Member Functions

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

Member Typedef Documentation

◆ Address

Type of memory address.

Definition at line 34 of file AbstractLocation.h.

Constructor & Destructor Documentation

◆ AbstractLocation() [1/4]

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.

◆ AbstractLocation() [2/4]

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

Register referent.

Constructs an abstract location that refers to a register.

◆ AbstractLocation() [3/4]

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

Register referent.

Constructs an abstract location that refers to a register.

◆ AbstractLocation() [4/4]

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

◆ isValid()

virtual bool Rose::BinaryAnalysis::AbstractLocation::isValid ( ) const
overridevirtual

Test whether this object is valid.

Implements Rose::Location.

◆ toString()

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.

◆ print() [1/4]

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.

◆ printableName()

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 static parse method in subclasses can create an equal object from the string.

Implements Rose::Location.

◆ isEqual()

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.

◆ operator<()

virtual bool Rose::BinaryAnalysis::AbstractLocation::operator< ( const Location ) const
overridevirtual

Implements Rose::Location.

◆ operator<=()

virtual bool Rose::BinaryAnalysis::AbstractLocation::operator<= ( const Location ) const
overridevirtual

Implements Rose::Location.

◆ operator>()

virtual bool Rose::BinaryAnalysis::AbstractLocation::operator> ( const Location ) const
overridevirtual

Implements Rose::Location.

◆ operator>=()

virtual bool Rose::BinaryAnalysis::AbstractLocation::operator>= ( const Location ) const
overridevirtual

Implements Rose::Location.

◆ compare()

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.

◆ isRegister()

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.

◆ isAddress()

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

◆ getRegister()

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.

◆ getAddress()

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.

◆ nBytes()

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.

◆ mayAlias()

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.

◆ mustAlias()

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.

◆ print() [2/4]

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.

◆ print() [3/4]

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.

◆ print() [4/4]

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: