ROSE  0.11.145.0
Classes | Public Member Functions | List of all members
Rose::BinaryAnalysis::RegisterParts Class Reference

Description

Holds a set of registers without regard for register boundaries.

This class is a container to which registers can be inserted and erased in such a way that the boundaries of registers are irrelevant. For instance, if one constructs an empty container, then inserts the 16-bit x86 AX register, then removes the 8-bit AH register (the high order eight bits of AX) all that's left is AL (the low-order 8 bits).

Sometimes this container contains parts of registers that don't correpond to actual named registers for the machine. For instance, if we insert the x86 EFLAGS register and then erase the ZF bit flag we're left with two parts of EFLAGS that don't actually have names in the x86 documentation. However, we can query whether another bit flag, say NF, is still present (which it is in this example).

One way to figure out names for the parts contained here is to get a list of all registers from a register dictionary, then query whether each is fully present in this container, report its name if present, and then remove its part from this container. If the container is non-empty at the end then all that can be done is to report which parts are still present.

Definition at line 28 of file RegisterParts.h.

#include <Rose/BinaryAnalysis/RegisterParts.h>

Public Member Functions

 RegisterParts ()
 Default construct an object with no register parts. More...
 
 RegisterParts (RegisterDescriptor reg)
 Constructor to insert a register. More...
 
bool isEmpty () const
 Predicate checking whether this container is empty. More...
 
bool existsAny (RegisterDescriptor reg) const
 Predicate checking if part of a register is present. More...
 
bool existsAll (RegisterDescriptor reg) const
 Predicate checking if all of a register is present. More...
 
void insert (RegisterDescriptor reg)
 Insert register into container. More...
 
void erase (RegisterDescriptor reg)
 Erase register from container. More...
 
void clear ()
 Erase everything. More...
 
RegisterPartsoperator-= (const RegisterParts &other)
 Erase some register parts. More...
 
RegisterParts operator- (const RegisterParts &other) const
 Compute difference. More...
 
RegisterPartsoperator|= (const RegisterParts &other)
 Add some register parts. More...
 
RegisterParts operator| (const RegisterParts &other) const
 Compute the union. More...
 
RegisterPartsoperator&= (const RegisterParts &other)
 Erase some register parts. More...
 
RegisterParts operator& (const RegisterParts &other) const
 Compute the intersection. More...
 
std::vector< RegisterDescriptorextract (const RegisterDictionaryPtr &regDict, bool extractAll=false)
 Extract individual registers. More...
 
std::vector< RegisterDescriptorlistAll (const RegisterDictionaryPtr &) const
 List registers present. More...
 
std::vector< RegisterDescriptorlistNamed (const RegisterDictionaryPtr &) const
 List registers present. More...
 

Constructor & Destructor Documentation

Rose::BinaryAnalysis::RegisterParts::RegisterParts ( )
inline

Default construct an object with no register parts.

Definition at line 92 of file RegisterParts.h.

Rose::BinaryAnalysis::RegisterParts::RegisterParts ( RegisterDescriptor  reg)
inlineexplicit

Constructor to insert a register.

This is the same as default-constructing an instance and inserting the specified register.

Definition at line 97 of file RegisterParts.h.

References insert().

Member Function Documentation

bool Rose::BinaryAnalysis::RegisterParts::isEmpty ( ) const
inline

Predicate checking whether this container is empty.

Returns true if this container holds no part of any register.

Definition at line 104 of file RegisterParts.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::isEmpty().

bool Rose::BinaryAnalysis::RegisterParts::existsAny ( RegisterDescriptor  reg) const
inline

Predicate checking if part of a register is present.

Returns true if any part of reg is present in this container. The reg need not be entirely present. See also existsAll.

Definition at line 112 of file RegisterParts.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::exists().

bool Rose::BinaryAnalysis::RegisterParts::existsAll ( RegisterDescriptor  reg) const
inline

Predicate checking if all of a register is present.

Returns true if all of reg is present in this container. It is not sufficient for just part of reg to be present. See also existsAny.

Definition at line 120 of file RegisterParts.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::exists().

void Rose::BinaryAnalysis::RegisterParts::insert ( RegisterDescriptor  reg)
inline

Insert register into container.

Inserts reg into this container. After inserting, existsAll and existsAny will both return true for reg. Nothing happens if reg is already fully present in this container.

Definition at line 128 of file RegisterParts.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMaybeDefault().

Referenced by RegisterParts().

void Rose::BinaryAnalysis::RegisterParts::erase ( RegisterDescriptor  reg)

Erase register from container.

Removes all of reg from this container. After erasing, existsAll and existsAny will both return false for reg. Nothing happens if reg is already fully absent from this container.

void Rose::BinaryAnalysis::RegisterParts::clear ( )
inline

Erase everything.

All registers are removed from this container, which becomes empty as if it were freshly constructed.

Definition at line 141 of file RegisterParts.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::clear().

RegisterParts& Rose::BinaryAnalysis::RegisterParts::operator-= ( const RegisterParts other)

Erase some register parts.

Erases from this container all register parts stored in the other container.

RegisterParts Rose::BinaryAnalysis::RegisterParts::operator- ( const RegisterParts other) const

Compute difference.

Returns a new container that contains those register parts that are in this container but not in other.

RegisterParts& Rose::BinaryAnalysis::RegisterParts::operator|= ( const RegisterParts other)

Add some register parts.

Inserts parts stored in other into this container.

RegisterParts Rose::BinaryAnalysis::RegisterParts::operator| ( const RegisterParts other) const

Compute the union.

Returns a new container that is the union of this container and other.

RegisterParts& Rose::BinaryAnalysis::RegisterParts::operator&= ( const RegisterParts other)

Erase some register parts.

Erases from this container all register parts that are not in the other container.

RegisterParts Rose::BinaryAnalysis::RegisterParts::operator& ( const RegisterParts other) const

Compute the intersection.

Returns a new container containing only those parts that are in both this and other.

std::vector<RegisterDescriptor> Rose::BinaryAnalysis::RegisterParts::extract ( const RegisterDictionaryPtr regDict,
bool  extractAll = false 
)

Extract individual registers.

Uses an optional register dictionary to extract individual register descriptors from this container, returning all of those that were found. The dictionary is quered to obtain its register descriptors in decreasing size, and each register which is fully present in this container is added to the end of the return value and removed from this container.

If extractAll is true (or no register dictionary is specified) then all leftover parts from the prior step are appended to the return value and this container is cleared.

std::vector<RegisterDescriptor> Rose::BinaryAnalysis::RegisterParts::listAll ( const RegisterDictionaryPtr ) const

List registers present.

This is similar to extract except it doesn't modify this container. The listAll version returns a list of all possible registers regardless of whether they have entries in the supplied dictionary, while the listNamed version returns only those that are present in the dictionary.

The register dictionary may be null for listAll, in which case no attempt is made to divide consecutive bits into smaller parts that would have had names.

std::vector<RegisterDescriptor> Rose::BinaryAnalysis::RegisterParts::listNamed ( const RegisterDictionaryPtr ) const

List registers present.

This is similar to extract except it doesn't modify this container. The listAll version returns a list of all possible registers regardless of whether they have entries in the supplied dictionary, while the listNamed version returns only those that are present in the dictionary.

The register dictionary may be null for listAll, in which case no attempt is made to divide consecutive bits into smaller parts that would have had names.


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