decompiler
1.0.0
|
A high-level variable modeled as a list of low-level variables, each written once. More...
#include <variable.hh>
Public Types | |
enum | { flagsdirty = 1, typedirty = 2, coverdirty = 4 } |
Dirtiness flags for a HighVariable. More... | |
Public Member Functions | |
HighVariable (Varnode *vn) | |
Construct a HighVariable with a single member Varnode. More... | |
Datatype * | getType (void) const |
Get the data-type. | |
void | setSymbol (Symbol *sym, int4 off) const |
Set the Symbol associated with this HighVariable. More... | |
Symbol * | getSymbol (void) const |
Get the Symbol associated with this. | |
int4 | getSymbolOffset (void) const |
Get the Symbol offset associated with this. | |
int4 | numInstances (void) const |
Get the number of member Varnodes this has. | |
Varnode * | getInstance (int4 i) const |
Get the i-th member Varnode. | |
void | flagsDirty (void) const |
Mark the boolean properties as dirty. | |
void | coverDirty (void) const |
Mark the cover as dirty. | |
void | typeDirty (void) const |
Mark the data-type as dirty. | |
void | remove (Varnode *vn) |
Remove a member Varnode from this. More... | |
void | printCover (ostream &s) const |
Print details of the cover for this (for debug purposes) More... | |
void | printInfo (ostream &s) const |
Print information about this HighVariable to stream. More... | |
bool | hasName (void) const |
Check if this HighVariable can be named. More... | |
Varnode * | getTiedVarnode (void) const |
Find the first address tied member Varnode. More... | |
Varnode * | getInputVarnode (void) const |
Find (the) input member Varnode. More... | |
Varnode * | getTypeRepresentative (void) const |
Get a member Varnode with the strongest data-type. More... | |
Varnode * | getNameRepresentative (void) const |
Get a member Varnode that dictates the naming of this HighVariable. More... | |
void | merge (HighVariable *tv2, bool isspeculative) |
Merge another HighVariable into this. More... | |
bool | isMapped (void) const |
Return true if this is mapped. | |
bool | isPersist (void) const |
Return true if this is a global variable. | |
bool | isAddrTied (void) const |
Return true if this is address ties. | |
bool | isInput (void) const |
Return true if this is an input variable. | |
bool | isImplied (void) const |
Return true if this is an implied variable. | |
bool | isSpacebase (void) const |
Return true if this is a spacebase. | |
bool | isConstant (void) const |
Return true if this is a constant. | |
bool | isUnaffected (void) const |
Return true if this is an unaffected register. | |
bool | isExtraOut (void) const |
Return true if this is an extra output. | |
void | setMark (void) const |
Set the mark on this variable. | |
void | clearMark (void) const |
Clear the mark on this variable. | |
bool | isMark (void) const |
Return true if this is marked. | |
bool | hasCover (void) const |
Determine if this HighVariable has an associated cover. More... | |
bool | isUnattached (void) const |
Return true if this has no member Varnode. | |
bool | isTypeLock (void) const |
Return true if this is typelocked. | |
bool | isNameLock (void) const |
Return true if this is namelocked. | |
Static Public Member Functions | |
static bool | compareName (Varnode *vn1, Varnode *vn2) |
Determine which given Varnode is most nameable. More... | |
static bool | compareJustLoc (const Varnode *a, const Varnode *b) |
Compare based on storage location. More... | |
Private Member Functions | |
int4 | instanceIndex (const Varnode *vn) const |
Find the index of a specific Varnode member. More... | |
void | updateFlags (void) const |
(Re)derive boolean properties of this from the member Varnodes More... | |
void | updateCover (void) const |
(Re)derive the cover of this from the member Varnodes More... | |
void | updateType (void) const |
(Re)derive the data-type for this from the member Varnodes More... | |
Private Attributes | |
vector< Varnode * > | inst |
The member Varnode objects making up this HighVariable. | |
int4 | numMergeClasses |
Number of different speculative merge classes in this. | |
uint4 | highflags |
Dirtiness flags. | |
uint4 | flags |
Boolean properties inherited from Varnode members. | |
Datatype * | type |
The data-type for this. | |
Cover | wholecover |
The ranges of code addresses covered by this HighVariable. | |
Symbol * | symbol |
The Symbol this HighVariable is tied to. | |
int4 | symboloffset |
-1=perfect symbol match >=0, offset | |
Friends | |
class | Merge |
A high-level variable modeled as a list of low-level variables, each written once.
In the Static Single Assignment (SSA) representation of a function's data-flow, the Varnode object represents a variable node. This is a low-level variable: it is written to at most once, and there is 1 or more reads. A high-level variable, in the source language may be written to multiple times. We model this idea as a list of Varnode objects, where a different Varnode holds the value of the variable for different parts of the code. The range(s) of code for which a single Varnode holds the high-level variable's value is the cover or range of that Varnode and is modeled by the class Cover. Within a high-level variable, HighVariable, the covers of member Varnode objects should not intersect, as that represents the variable holding two or more different values at the same place in the code. The HighVariable inherits a cover which is the union of the covers of its Varnodes.
anonymous enum |
Dirtiness flags for a HighVariable.
The HighVariable inherits its Cover, its data-type, and other boolean properties from its Varnodes. The object holds these explicitly, but the values may become stale as the data-flow transforms. So we keep track of when these inherited values are dirty
Enumerator | |
---|---|
flagsdirty | Boolean properties for the HighVariable are dirty. |
typedirty | The data-type for the HighVariable is dirty. |
coverdirty | The cover for the HighVariable is dirty. |
HighVariable::HighVariable | ( | Varnode * | vn | ) |
Construct a HighVariable with a single member Varnode.
The new instance starts off with no associate Symbol and all properties marked as dirty.
vn | is the single Varnode member |
References coverdirty, flags, flagsdirty, highflags, inst, numMergeClasses, Varnode::setHigh(), symbol, symboloffset, type, and typedirty.
Compare based on storage location.
Compare two Varnode objects based just on their storage address
References Varnode::getAddr().
Determine which given Varnode is most nameable.
Given two Varnode (members), sort them based on naming properties:
References Varnode::getDef(), Varnode::getSpace(), PcodeOp::getTime(), AddrSpace::getType(), IPTR_INTERNAL, Varnode::isAddrTied(), Varnode::isInput(), Varnode::isNameLock(), Varnode::isPersist(), Varnode::isUnaffected(), and Varnode::isWritten().
Referenced by getNameRepresentative().
Varnode * HighVariable::getInputVarnode | ( | void | ) | const |
Varnode * HighVariable::getNameRepresentative | ( | void | ) | const |
Get a member Varnode that dictates the naming of this HighVariable.
Members are scored based the properties that are most dominating in choosing a name.
References compareName(), and inst.
Referenced by ActionNameVars::apply(), PrintLanguage::pushVnExplicit(), PrintLanguage::pushVnLHS(), and Funcdata::saveXmlHigh().
Varnode * HighVariable::getTiedVarnode | ( | void | ) | const |
Find the first address tied member Varnode.
This should only be called if isAddrTied() returns true. If there is no address tied member, this will throw an exception.
References inst, and isAddrTied().
Referenced by ActionCopyMarker::apply(), and Merge::mergeTestRequired().
Varnode * HighVariable::getTypeRepresentative | ( | void | ) | const |
Get a member Varnode with the strongest data-type.
Using Datatype::typeOrder, find the member Varnode with the most specific data-type.
References Varnode::getType(), inst, Varnode::isTypeLock(), and Datatype::typeOrder().
Referenced by updateType().
|
inline |
Determine if this HighVariable has an associated cover.
Constant and annotation variables do not have a cover
References Varnode::annotation, Varnode::constant, flags, Varnode::insert, and updateFlags().
Referenced by Merge::mergeTest(), and updateCover().
bool HighVariable::hasName | ( | void | ) | const |
Check if this HighVariable can be named.
All Varnode objects are assigned a HighVariable, including those that don't get names like indirect variables, constants, and annotations. Determine if this, as inherited from its member Varnodes, can have a name.
References getInputVarnode(), Varnode::hasCover(), inst, Varnode::isIllegalInput(), Varnode::isImplied(), Varnode::isIndirectOnly(), isInput(), Varnode::isSpacebase(), and isUnaffected().
Referenced by ActionNameVars::apply().
|
private |
Find the index of a specific Varnode member.
Find the index, for use with getInstance(), that will retrieve the given Varnode member
vn | is the given Varnode member |
References inst.
void HighVariable::merge | ( | HighVariable * | tv2, |
bool | isspeculative | ||
) |
Merge another HighVariable into this.
The lists of members are merged and the other HighVariable is deleted.
tv2 | is the other HighVariable to merge into this |
isspeculative | is true to keep the new members in separate merge classes |
References compareJustLoc(), coverdirty, flagsdirty, Varnode::getMergeGroup(), highflags, inst, Cover::merge(), numMergeClasses, Varnode::setHigh(), typedirty, and wholecover.
Referenced by Merge::merge().
|
inline |
Print details of the cover for this (for debug purposes)
s | is the output stream |
References coverdirty, highflags, Cover::print(), and wholecover.
void HighVariable::printInfo | ( | ostream & | s | ) | const |
Print information about this HighVariable to stream.
This is generally used for debug purposes.
s | is the output stream |
References Varnode::getMergeGroup(), Symbol::getName(), inst, Varnode::printInfo(), Datatype::printRaw(), symbol, symboloffset, type, and updateType().
void HighVariable::remove | ( | Varnode * | vn | ) |
Remove a member Varnode from this.
Search for the given Varnode and cut it out of the list, marking all properties as dirty.
vn | is the given Varnode member to remove |
References compareJustLoc(), coverdirty, flagsdirty, highflags, inst, and typedirty.
Referenced by Varnode::~Varnode().
|
inline |
Set the Symbol associated with this HighVariable.
This HighVariable does not need to be associated with the whole symbol. It can be associated with a part, like a sub-field, if the size of the member Varnodes and the Symbol don't match. In this case a non-zero offset may be passed in with the Symbol to indicate what part is represented by the this.
sym | is the Symbol to associate with this |
off | is the offset in bytes, relative to the Symbol, where this HighVariable starts |
References symbol, and symboloffset.
Referenced by ActionDynamicSymbols::apply(), Funcdata::buildDynamicSymbol(), and Funcdata::linkSymbol().
|
private |
(Re)derive the cover of this from the member Varnodes
Only update if the cover is marked as dirty. Merge the covers of all Varnode instances. This is only called by the Merge class which knows when to call it properly.
References Cover::clear(), coverdirty, hasCover(), highflags, inst, Cover::merge(), and wholecover.
Referenced by Merge::merge(), and Merge::updateHigh().
|
private |
(Re)derive boolean properties of this from the member Varnodes
Only update if flags are marked as dirty. Generally if any member Varnode possesses the property, this HighVariable should inherit it. The Varnode::typelock field is not set here, but in updateType().
References Varnode::directwrite, flags, flagsdirty, highflags, inst, Varnode::mark, and Varnode::typelock.
Referenced by hasCover(), isAddrTied(), isConstant(), isExtraOut(), isImplied(), isInput(), isMapped(), isNameLock(), isPersist(), isSpacebase(), and isUnaffected().
|
private |
(Re)derive the data-type for this from the member Varnodes
Only update if the data-type is marked as dirty. Get the most locked, most specific data-type from member Varnode objects.
References flags, Varnode::getType(), getTypeRepresentative(), highflags, Varnode::isTypeLock(), type, typedirty, and Varnode::typelock.
Referenced by getType(), isTypeLock(), and printInfo().