ROSE 0.11.145.192
|
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:
Abstract locations are immutable objects.
See also, ConcreteLocation.
Definition at line 32 of file AbstractLocation.h.
#include <Rose/BinaryAnalysis/AbstractLocation.h>
Public Types | |
using | Address = InstructionSemantics::BaseSemantics::SValuePtr |
Type of memory address. | |
Public Member Functions | |
AbstractLocation () | |
Default constructor. | |
AbstractLocation (const AbstractLocation &) | |
Copy constructor. | |
AbstractLocation & | operator= (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 ®dict) | |
Register referent. | |
void | print (std::ostream &out, const RegisterDictionaryPtr ®dict) 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 ®dict, 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. | |
using Rose::BinaryAnalysis::AbstractLocation::Address = InstructionSemantics::BaseSemantics::SValuePtr |
Type of memory address.
Definition at line 34 of file AbstractLocation.h.
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.
|
explicit |
Register referent.
Constructs an abstract location that refers to a register.
|
explicit |
Register referent.
Constructs an abstract location that refers to a register.
|
explicit |
Memory referent.
Constructs an abstract location that refers to a memory location.
|
overridevirtual |
Test whether this object is valid.
Implements Rose::Location.
|
overridevirtual |
Convert location to string.
Returns a string representation of the location. This representation is not necessarily parsable.
See also, print.
Implements Rose::Location.
|
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.
|
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.
|
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.
|
overridevirtual |
Implements Rose::Location.
|
overridevirtual |
Implements Rose::Location.
|
overridevirtual |
Implements Rose::Location.
|
overridevirtual |
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.