My Project
|
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... | |
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.
void ParamActive::freePlaceholderSlot | ( | void | ) |
Free the stack placeholder slot.
Free up the stack placeholder slot, which may cause trial slots to get adjusted.
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 |
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 |
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 |
|
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 |
|
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 |