ROSE 0.11.145.147
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 30 of file RegisterParts.h.

#include <Rose/BinaryAnalysis/RegisterParts.h>

Public Member Functions

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

Constructor & Destructor Documentation

◆ RegisterParts() [1/2]

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

Default construct an object with no register parts.

Definition at line 94 of file RegisterParts.h.

◆ RegisterParts() [2/2]

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 99 of file RegisterParts.h.

References insert().

Member Function Documentation

◆ isEmpty()

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 106 of file RegisterParts.h.

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

◆ existsAny()

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 114 of file RegisterParts.h.

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

◆ existsAll()

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 122 of file RegisterParts.h.

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

◆ insert()

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 130 of file RegisterParts.h.

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

Referenced by RegisterParts().

◆ erase()

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.

◆ clear()

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 143 of file RegisterParts.h.

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

◆ operator-=()

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

Erase some register parts.

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

◆ operator-()

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.

◆ operator|=()

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

Add some register parts.

Inserts parts stored in other into this container.

◆ operator|()

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.

◆ operator&=()

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.

◆ operator&()

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.

◆ extract()

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.

◆ listAll()

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.

◆ listNamed()

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: