Ghidra Decompiler Analysis Engine
Public Member Functions | 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...
 
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...
 
void freePlaceholderSlot (void)
 Free the stack placeholder slot. More...
 
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...
 

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::ParamActive ( bool  recoversub)

Constructor an empty container.

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

Member Function Documentation

◆ deleteUnusedTrials()

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.

◆ freePlaceholderSlot()

void ParamActive::freePlaceholderSlot ( void  )

Free the stack placeholder slot.

Free up the stack placeholder slot, which may cause trial slots to get adjusted.

◆ getNumUsed()

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

◆ getTrialForInputVarnode()

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

◆ joinTrial()

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

◆ registerTrial()

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

◆ shrink()

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

◆ splitTrial()

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

◆ testShrink()

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

◆ whichTrial()

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

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