ROSE  0.11.98.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Rose::BinaryAnalysis::ConcreteLocation Class Reference

Description

Concrete location of data.

A concrete location is a machine register, a concrete memory address, or a memory address calculated from a register's current value and a signed byte offset.

Concrete locations are immutable objects.

See also, AbstractLocation.

Definition at line 26 of file ConcreteLocation.h.

#include <Rose/BinaryAnalysis/ConcreteLocation.h>

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

Public Types

enum  Type {
  NO_LOCATION,
  REGISTER,
  RELATIVE,
  ABSOLUTE
}
 Type of location. More...
 

Public Member Functions

 ConcreteLocation ()
 Default constructor. More...
 
 ConcreteLocation (const ConcreteLocation &)
 Copy constructor. More...
 
ConcreteLocationoperator= (const ConcreteLocation &)
 
 ConcreteLocation (rose_addr_t)
 Address location. More...
 
 ConcreteLocation (RegisterDescriptor, int64_t offset)
 Register and offset location. 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
 
void print (std::ostream &, const RegisterDictionaryPtr &) const
 Print using the specified register dictionary. More...
 
int compare (const ConcreteLocation &) const
 Compare two concrete locations. More...
 
Type type () const
 Type of location. More...
 
RegisterDescriptor reg () const
 Register part of the location. More...
 
rose_addr_t address () const
 Address part of the location. More...
 
int64_t offset () const
 Offset part of the location. More...
 
 ConcreteLocation (RegisterDescriptor)
 Register location. More...
 
 ConcreteLocation (RegisterDescriptor, const RegisterDictionaryPtr &)
 Register location. More...
 
RegisterDictionaryPtr registerDictionary () const
 Property: Register dictionary. More...
 
void registerDictionary (const RegisterDictionaryPtr &)
 Property: Register dictionary. 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 ConcreteLocation parse (const std::string &)
 Parse a concrete location from a string. More...
 

Member Enumeration Documentation

Type of location.

Enumerator
NO_LOCATION 

Used by default-constructed locations.

REGISTER 

Parameter is in a register.

RELATIVE 

Parameter in memory relative to a register.

E.g., stack.

ABSOLUTE 

Parameter is at a fixed memory address.

Definition at line 29 of file ConcreteLocation.h.

Constructor & Destructor Documentation

Rose::BinaryAnalysis::ConcreteLocation::ConcreteLocation ( )

Default constructor.

Constructs a concrete location that does not refer to any location. The isEmpty method return true for such objects.

Rose::BinaryAnalysis::ConcreteLocation::ConcreteLocation ( const ConcreteLocation )

Copy constructor.

Rose::BinaryAnalysis::ConcreteLocation::ConcreteLocation ( RegisterDescriptor  )
explicit

Register location.

Construct a concrete location that refers to a register. The optional register dictionary can be associated with the location and is only used when printing the location.

FIXME[Robb Matzke 2022-07-15]: The second argument is temporary and unused. It's only purpose is to disambiguate the call to ConcreteLocation(RegisterDescriptor,int64_t) without the user having to add int64_t casts at all such calls when the offset is zero. Doing it this way will be easier to change in the future when register dictionaries are changed to use smart pointers since the compiler will be able to help us.

Rose::BinaryAnalysis::ConcreteLocation::ConcreteLocation ( RegisterDescriptor  ,
const RegisterDictionaryPtr  
)
explicit

Register location.

Construct a concrete location that refers to a register. The optional register dictionary can be associated with the location and is only used when printing the location.

FIXME[Robb Matzke 2022-07-15]: The second argument is temporary and unused. It's only purpose is to disambiguate the call to ConcreteLocation(RegisterDescriptor,int64_t) without the user having to add int64_t casts at all such calls when the offset is zero. Doing it this way will be easier to change in the future when register dictionaries are changed to use smart pointers since the compiler will be able to help us.

Rose::BinaryAnalysis::ConcreteLocation::ConcreteLocation ( rose_addr_t  )
explicit

Address location.

Construct a concrete location that refers to an address in memory.

Rose::BinaryAnalysis::ConcreteLocation::ConcreteLocation ( RegisterDescriptor  ,
int64_t  offset 
)

Register and offset location.

Construct a concrete location that refers to an address in memory calculated by adding a register's value and a signed byte offset.

Member Function Documentation

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

Parse a concrete location from a string.

virtual std::string Rose::BinaryAnalysis::ConcreteLocation::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::ConcreteLocation::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::ConcreteLocation::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::ConcreteLocation::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.

void Rose::BinaryAnalysis::ConcreteLocation::print ( std::ostream &  ,
const RegisterDictionaryPtr  
) const

Print using the specified register dictionary.

Concrete locations have an optional internal register dictionary pointer that's usually used for printing, but this method provides a way to use some other register dictionary.

int Rose::BinaryAnalysis::ConcreteLocation::compare ( const ConcreteLocation ) const

Compare two concrete locations.

Returns negative if this location is less than the other, positive if this location is greater than the other, or zero if this and the other location are equal.

Type Rose::BinaryAnalysis::ConcreteLocation::type ( ) const

Type of location.

RegisterDictionaryPtr Rose::BinaryAnalysis::ConcreteLocation::registerDictionary ( ) const

Property: Register dictionary.

This is the optional register dictionary associated with this location and used when printing the location.

void Rose::BinaryAnalysis::ConcreteLocation::registerDictionary ( const RegisterDictionaryPtr )

Property: Register dictionary.

This is the optional register dictionary associated with this location and used when printing the location.

RegisterDescriptor Rose::BinaryAnalysis::ConcreteLocation::reg ( ) const

Register part of the location.

Returns the register part of the location. This returns a valid register descriptor if the location is either a register or an indirect (register plus offset) memory address. Otherwise it returns the empty register descriptor.

rose_addr_t Rose::BinaryAnalysis::ConcreteLocation::address ( ) const

Address part of the location.

Returns the address of the location if the location is a simple memory address. Otherwise, if the address is formed from a base register and an offset, or if the location is a register, then zero is returned.

int64_t Rose::BinaryAnalysis::ConcreteLocation::offset ( ) const

Offset part of the location.

Returns the signed offset when the location is a memory address formed from a register base value and an offset. Otherwise it returns zero.


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