decompiler
1.0.0
|
Container class for ParamTrial objects. More...
#include <fspec.hh>
Public Member Functions | |
ParamActive (bool recoversub) | |
Constructor an empty container. More... | |
void | clear (void) |
Reset to an empty container. | |
void | registerTrial (const Address &addr, int4 sz) |
Add a new trial to the container. More... | |
int4 | getNumTrials (void) const |
Get the number of trials in this container. | |
ParamTrial & | getTrial (int4 i) |
Get the i-th trial. | |
const ParamTrial & | getTrialForInputVarnode (int4 slot) const |
Get trial corresponding to the given input Varnode. More... | |
int4 | whichTrial (const Address &addr, int4 sz) const |
Get the trial overlapping with the given memory range. More... | |
bool | needsFinalCheck (void) const |
Is a final check required. | |
void | markNeedsFinalCheck (void) |
Mark that a final check is required. | |
bool | isRecoverSubcall (void) const |
Are these trials for a call to a sub-function. | |
bool | isFullyChecked (void) const |
Are all trials checked with no new trials expected. | |
void | markFullyChecked (void) |
Mark that all trials are checked. | |
void | setPlaceholderSlot (void) |
Establish a stack placedholder slot. | |
void | freePlaceholderSlot (void) |
Free the stack placeholder slot. More... | |
int4 | getNumPasses (void) const |
How many trial analysis passes were performed. | |
int4 | getMaxPass (void) const |
What is the maximum number of passes. | |
void | setMaxPass (int4 val) |
Set the maximum number of passes. | |
void | finishPass (void) |
Mark that an analysis pass has completed. | |
void | sortTrials (void) |
Sort the trials in formal parameter order. | |
void | deleteUnusedTrials (void) |
Remove trials that were found not to be parameters. More... | |
void | splitTrial (int4 i, int4 sz) |
Split the given trial in two. More... | |
void | joinTrial (int4 slot, const Address &addr, int4 sz) |
Join adjacent parameter trials. More... | |
int4 | getNumUsed (void) const |
Get number of trials marked as formal parameters. More... | |
bool | testShrink (int4 i, const Address &addr, int4 sz) const |
Test if the given trial can be shrunk to the given range. More... | |
void | shrink (int4 i, const Address &addr, int4 sz) |
Shrink the given trial to a new given range. More... | |
Private Attributes | |
vector< ParamTrial > | trial |
The list of parameter trials. | |
int4 | slotbase |
Slot where next parameter will go. | |
int4 | stackplaceholder |
Which call input slot holds the stack placeholder. | |
int4 | numpasses |
Number of attempts at evaluating parameters. | |
int4 | maxpass |
Number of passes before we assume we have seen all params. | |
bool | isfullychecked |
True if all trials are fully examined (and no new trials are expected) | |
bool | needsfinalcheck |
Should a final pass be made on trials (to take into account control-flow changes) | |
bool | recoversubcall |
True if this is being used to recover prototypes of a sub-function call. | |
Container class for ParamTrial objects.
The parameter analysis algorithms use this class to maintain the collection of parameter trials being actively considered for a given function. It holds the ParamTrial objects and other information about the current state of analysis.
Trials are maintained in two stages, before parameter decisions have been made and after. Before, trials are in input index order relative to the CALL or CALLIND op for a sub-function, or they are in address order for input Varnodes to the active function. After, the trials are put into formal parameter order, as dictated by the PrototypeModel.
ParamActive::ParamActive | ( | bool | recoversub | ) |
Constructor an empty container.
recoversub | selects whether a sub-function or the active function is being tested |
void ParamActive::deleteUnusedTrials | ( | void | ) |
Remove trials that were found not to be parameters.
Delete any trial for which isUsed() returns false. This is used in conjunction with setting the active Varnodes on a call, so the slot number is reordered too.
References ParamTrial::isUsed(), and ParamTrial::setSlot().
Referenced by FuncCallSpecs::buildInputFromTrials(), and FuncCallSpecs::buildOutputFromTrials().
void ParamActive::freePlaceholderSlot | ( | void | ) |
Free the stack placeholder slot.
Free up the stack placeholder slot, which may cause trial slots to get adjusted.
References ParamEntry::getSlot().
Referenced by FuncCallSpecs::clearStackPlaceholderSlot().
int4 ParamActive::getNumUsed | ( | void | ) | const |
Get number of trials marked as formal parameters.
This assumes the trials have been sorted. So used trials are first.
|
inline |
Get trial corresponding to the given input Varnode.
Return the trial associated with the input Varnode to the associated p-code CALL or CALLIND. We take into account the call address parameter (subtract 1) and if the index occurs after the index holding the stackpointer placeholder, we subtract an additional 1.
slot | is the input index of the input Varnode |
Referenced by Funcdata::checkCallDoubleUse(), FuncCallSpecs::checkInputJoin(), and FuncCallSpecs::doInputJoin().
void ParamActive::joinTrial | ( | int4 | slot, |
const Address & | addr, | ||
int4 | sz | ||
) |
Join adjacent parameter trials.
Join the trial at the given slot with the trial in the next slot
slot | is the given slot |
addr | is the address of the new joined memory range |
sz | is the size of the new memory range |
References ParamTrial::getSize(), and ParamTrial::getSlot().
Referenced by FuncCallSpecs::doInputJoin().
void ParamActive::registerTrial | ( | const Address & | addr, |
int4 | sz | ||
) |
Add a new trial to the container.
A ParamTrial object is created and a slot is assigned.
addr | is the starting address of the memory range |
sz | is the number of bytes in the range |
References Address::getSpace(), AddrSpace::getType(), and IPTR_SPACEBASE.
Referenced by ActionInputPrototype::apply(), ParamListStandard::buildTrialMap(), FuncCallSpecs::commitNewInputs(), FuncCallSpecs::commitNewOutputs(), ActionFuncLink::funcLinkInput(), Heritage::guardCallOverlappingInput(), Heritage::guardCalls(), and Heritage::guardReturns().
|
inline |
Shrink the given trial to a new given range.
i | is the index of the given trial |
addr | is the new range's starting address |
sz | is the new range's size in bytes |
void ParamActive::splitTrial | ( | int4 | i, |
int4 | sz | ||
) |
Split the given trial in two.
Split the trial into two trials, where the first piece has the given size.
i | is the index of the given trial |
sz | is the given size |
References ParamEntry::getSize().
Referenced by ActionParamDouble::apply().
|
inline |
Test if the given trial can be shrunk to the given range.
i | is the index of the given trial |
addr | is the new address |
sz | is the new size |
int4 ParamActive::whichTrial | ( | const Address & | addr, |
int4 | sz | ||
) | const |
Get the trial overlapping with the given memory range.
The (index of) the first overlapping trial is returned.
addr | is the starting address of the given range |
sz | is the number of bytes in the range |
References Address::overlap().
Referenced by FuncCallSpecs::collectOutputTrialVarnodes(), Heritage::guardCallOverlappingInput(), and Heritage::guardCalls().