ROSE 0.11.145.147
|
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. | |
RegisterParts & | operator-= (const RegisterParts &other) |
Erase some register parts. | |
RegisterParts | operator- (const RegisterParts &other) const |
Compute difference. | |
RegisterParts & | operator|= (const RegisterParts &other) |
Add some register parts. | |
RegisterParts | operator| (const RegisterParts &other) const |
Compute the union. | |
RegisterParts & | operator&= (const RegisterParts &other) |
Erase some register parts. | |
RegisterParts | operator& (const RegisterParts &other) const |
Compute the intersection. | |
std::vector< RegisterDescriptor > | extract (const RegisterDictionaryPtr ®Dict, bool extractAll=false) |
Extract individual registers. | |
std::vector< RegisterDescriptor > | listAll (const RegisterDictionaryPtr &) const |
List registers present. | |
std::vector< RegisterDescriptor > | listNamed (const RegisterDictionaryPtr &) const |
List registers present. | |
|
inline |
Default construct an object with no register parts.
Definition at line 94 of file RegisterParts.h.
|
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().
|
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().
|
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().
|
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().
|
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().
void Rose::BinaryAnalysis::RegisterParts::erase | ( | RegisterDescriptor | reg | ) |
|
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().
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.