decompiler  1.0.0
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ghidra::ParamTrial Class Reference

A register or memory register that may be used to pass a parameter or return value. More...

#include <fspec.hh>

Public Types

enum  {
  checked = 1, used = 2, defnouse = 4, active = 8,
  unref = 0x10, killedbycall = 0x20, rem_formed = 0x40, indcreate_formed = 0x80,
  condexe_effect = 0x100, ancestor_realistic = 0x200, ancestor_solid = 0x400
}
 

Public Member Functions

 ParamTrial (const Address &ad, int4 sz, int4 sl)
 Construct from components.
 
const AddressgetAddress (void) const
 Get the starting address of this trial.
 
int4 getSize (void) const
 Get the number of bytes in this trial.
 
int4 getSlot (void) const
 Get the slot associated with this trial.
 
void setSlot (int4 val)
 Set the slot associated with this trial.
 
const ParamEntrygetEntry (void) const
 Get the model entry associated with this trial.
 
int4 getOffset (void) const
 Get the offset associated with this trial.
 
void setEntry (const ParamEntry *ent, int4 off)
 Set the model entry for this trial.
 
void markUsed (void)
 Mark the trial as a formal parameter.
 
void markActive (void)
 Mark that trial is actively used (in data-flow)
 
void markInactive (void)
 Mark that trial is not actively used.
 
void markNoUse (void)
 Mark trial as definitely not a parameter.
 
void markUnref (void)
 Mark that this trial has no Varnode representative.
 
void markKilledByCall (void)
 Mark that this storage is killed-by-call.
 
bool isChecked (void) const
 Has this trial been checked.
 
bool isActive (void) const
 Is this trial actively used in data-flow.
 
bool isDefinitelyNotUsed (void) const
 Is this trial as definitely not a parameter.
 
bool isUsed (void) const
 Is this trial as a formal parameter.
 
bool isUnref (void) const
 Does this trial not have a Varnode representative.
 
bool isKilledByCall (void) const
 Is this storage killed-by-call.
 
void setRemFormed (void)
 Mark that this is formed by a INT_REM operation.
 
bool isRemFormed (void) const
 Is this formed by a INT_REM operation.
 
void setIndCreateFormed (void)
 Mark this trial as formed by indirect creation.
 
bool isIndCreateFormed (void) const
 Is this trial formed by indirect creation.
 
void setCondExeEffect (void)
 Mark this trial as possibly affected by conditional execution.
 
bool hasCondExeEffect (void) const
 Is this trial possibly affected by conditional execution.
 
void setAncestorRealistic (void)
 Mark this as having a realistic ancestor.
 
bool hasAncestorRealistic (void) const
 Does this have a realistic ancestor.
 
void setAncestorSolid (void)
 Mark this as showing solid movement into Varnode.
 
bool hasAncestorSolid (void) const
 Does this show solid movement into Varnode.
 
int4 slotGroup (void) const
 Get position of this within its parameter group.
 
void setAddress (const Address &ad, int4 sz)
 Reset the memory range of this trial.
 
ParamTrial splitHi (int4 sz) const
 Create a trial representing the first part of this. More...
 
ParamTrial splitLo (int4 sz) const
 Create a trial representing the last part of this. More...
 
bool testShrink (const Address &newaddr, int4 sz) const
 Test if this trial can be made smaller. More...
 
bool operator< (const ParamTrial &b) const
 Sort trials in formal parameter order. More...
 
void setFixedPosition (int4 pos)
 Set fixed position.
 

Static Public Member Functions

static bool fixedPositionCompare (const ParamTrial &a, const ParamTrial &b)
 Sort by fixed position; stable for fixedPosition = -1. More...
 

Private Attributes

uint4 flags
 Boolean properties of the trial.
 
Address addr
 Starting address of the memory range.
 
int4 size
 Number of bytes in the memory range.
 
int4 slot
 Slot assigned to this trial.
 
const ParamEntryentry
 PrototypeModel entry matching this trial.
 
int4 offset
 "justified" offset into entry
 
int4 fixedPosition
 argument position if a fixed arg of a varargs function, else -1
 

Detailed Description

A register or memory register that may be used to pass a parameter or return value.

The parameter recovery utilities (see ParamActive) use this to denote a putative parameter passing storage location. It is made up of the address and size of the memory range, a set of properties about the use of the range (as a parameter) in context, and a link to the matching part of the PrototypeModel.

Data-flow for the putative parameter is held directly by a Varnode. To quickly map to the Varnode (which may or may not exist at points during the ParamTrial lifetime), the concept of slot is used. ParamTrials are assigned a slot, starting at 1. For sub-function parameters, this represents the actual input index of the Varnode in the corresponding CALL or CALLIND op. For parameters, this gives the position within the list of possible input Varnodes in address order. The slot ordering varies over the course of analysis and is unlikely to match the final parameter ordering. The ParamTrial comparator sorts the trials in final parameter ordering.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
checked 

Trial has been checked.

used 

Trial is definitely used (final verdict)

defnouse 

Trial is definitely not used.

active 

Trial looks active (hint that it is used)

unref 

There is no direct reference to this parameter trial.

killedbycall 

Data in this location is unlikely to flow thru a func and still be a param.

rem_formed 

The trial is built out of a remainder operation.

indcreate_formed 

The trial is built out of an indirect creation.

condexe_effect 

This trial may be affected by conditional execution.

ancestor_realistic 

Trial has a realistic ancestor.

ancestor_solid 

Solid movement into the Varnode.

Member Function Documentation

◆ fixedPositionCompare()

bool ghidra::ParamTrial::fixedPositionCompare ( const ParamTrial a,
const ParamTrial b 
)
static

Sort by fixed position; stable for fixedPosition = -1.

Sort by fixed position then by ParamTrial::operator<

Parameters
atrial
btrial
Returns
true if a should be ordered before b

References fixedPosition.

Referenced by ghidra::ParamActive::sortFixedPosition().

◆ operator<()

bool ghidra::ParamTrial::operator< ( const ParamTrial b) const

Sort trials in formal parameter order.

Trials are sorted primarily by the group index assigned by the PrototypeModel. Trials within the same group are sorted in address order (or its reverse)

Parameters
bis the other trial to compare with this
Returns
true if this should be ordered before the other trial

References addr, entry, ghidra::ParamEntry::getGroup(), offset, ghidra::ParamEntry::size, and size.

◆ splitHi()

ParamTrial ghidra::ParamTrial::splitHi ( int4  sz) const

Create a trial representing the first part of this.

Create a new ParamTrial based on the first bytes of the memory range.

Parameters
szis the number of bytes to include in the new trial
Returns
the new trial

References ghidra::ParamEntry::flags, and flags.

◆ splitLo()

ParamTrial ghidra::ParamTrial::splitLo ( int4  sz) const

Create a trial representing the last part of this.

Create a new ParamTrial based on the last bytes of the memory range.

Parameters
szis the number of bytes to include in the new trial
Returns
the new trial

References ghidra::ParamEntry::flags, and ghidra::ParamEntry::size.

◆ testShrink()

bool ghidra::ParamTrial::testShrink ( const Address newaddr,
int4  sz 
) const

Test if this trial can be made smaller.

A new address and size for the memory range is given, which must respect the endianness of the putative parameter and any existing match with the PrototypeModel

Parameters
newaddris the new address
szis the new size
Returns
true if the trial can be shrunk to the new range

References ghidra::ParamEntry::size.


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