decompiler  1.0.0
Public Member Functions | Private Attributes | List of all members
ParamActive Class Reference

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.
 
ParamTrialgetTrial (int4 i)
 Get the i-th trial.
 
const ParamTrialgetTrialForInputVarnode (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< ParamTrialtrial
 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

ParamActive::ParamActive ( bool  recoversub)

Constructor an empty container.

Parameters
recoversubselects whether a sub-function or the active function is being tested

Member Function Documentation

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.

Returns
the number of formally used trials
const ParamTrial & ParamActive::getTrialForInputVarnode ( int4  slot) const
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.

Parameters
slotis the input index of the input Varnode
Returns
the corresponding parameter trial

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

Parameters
slotis the given slot
addris the address of the new joined memory range
szis 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.

Parameters
addris the starting address of the memory range
szis 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().

void ParamActive::shrink ( int4  i,
const Address addr,
int4  sz 
)
inline

Shrink the given trial to a new given range.

Parameters
iis the index of the given trial
addris the new range's starting address
szis 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.

Parameters
iis the index of the given trial
szis the given size

References ParamEntry::getSize().

Referenced by ActionParamDouble::apply().

bool ParamActive::testShrink ( int4  i,
const Address addr,
int4  sz 
) const
inline

Test if the given trial can be shrunk to the given range.

Parameters
iis the index of the given trial
addris the new address
szis the new size
Returns
true if the trial can be shrunk to the new range
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.

Parameters
addris the starting address of the given range
szis the number of bytes in the range
Returns
the index of the overlapping trial, or -1 if no trial overlaps

References Address::overlap().

Referenced by FuncCallSpecs::collectOutputTrialVarnodes(), Heritage::guardCallOverlappingInput(), and Heritage::guardCalls().


The documentation for this class was generated from the following files: