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

A cache of Cover intersection tests for HighVariables. More...

#include <variable.hh>

Public Member Functions

void moveIntersectTests (HighVariable *high1, HighVariable *high2)
 Translate any intersection tests for high2 into tests for high1. More...
 
bool updateHigh (HighVariable *a)
 Make sure given HighVariable's Cover is up-to-date. More...
 
bool intersection (HighVariable *a, HighVariable *b)
 Test the intersection of two HighVariables and cache the result. More...
 
void clear (void)
 

Private Member Functions

bool blockIntersection (HighVariable *a, HighVariable *b, int4 blk)
 Test if two HighVariables intersect on a given BlockBasic. More...
 
void purgeHigh (HighVariable *high)
 Remove cached intersection tests for a given HighVariable. More...
 

Static Private Member Functions

static void gatherBlockVarnodes (HighVariable *a, int4 blk, const Cover &cover, vector< Varnode *> &res)
 Gather Varnode instances of the given HighVariable that intersect a cover on a specific block. More...
 
static bool testBlockIntersection (HighVariable *a, int4 blk, const Cover &cover, int4 relOff, const vector< Varnode *> &blist)
 Test instances of a the given HighVariable for intersection on a specific block with a cover. More...
 

Private Attributes

map< HighEdge, bool > highedgemap
 A cache of intersection tests, sorted by HighVariable pair.
 

Detailed Description

A cache of Cover intersection tests for HighVariables.

An test is performed by calling the intersect() method, which returns the result of a full Cover intersection test, taking into account, overlapping pieces, shadow Varnodes etc. The results of the test are cached in this object, so repeated calls do not need to perform the full calculation. The cache examines HighVariable dirtiness flags to determine if its Cover and cached tests are stale. The Cover can be externally updated, without performing a test, and still keeping the cached tests accurate, by calling the updateHigh() method. If two HighVariables to be merged, the cached tests can be updated by calling moveIntersectTest() before merging.

Member Function Documentation

◆ blockIntersection()

bool ghidra::HighIntersectTest::blockIntersection ( HighVariable a,
HighVariable b,
int4  blk 
)
private

Test if two HighVariables intersect on a given BlockBasic.

Intersections are checked only on the specified block.

Parameters
ais the first HighVariable
bis the second HighVariable
blkis the index of the BlockBasic on which to test intersection
Returns
true if an intersection occurs in the specified block

References ghidra::HighVariable::getCover(), ghidra::VariablePiece::getHigh(), ghidra::VariablePiece::getIntersection(), ghidra::VariablePiece::getOffset(), ghidra::VariablePiece::getSize(), ghidra::VariablePiece::numIntersection(), and ghidra::HighVariable::piece.

◆ gatherBlockVarnodes()

void ghidra::HighIntersectTest::gatherBlockVarnodes ( HighVariable a,
int4  blk,
const Cover cover,
vector< Varnode *> &  res 
)
staticprivate

Gather Varnode instances of the given HighVariable that intersect a cover on a specific block.

Parameters
ais the given HighVariable
blkis the specific block number
coveris the Cover to test for intersection
reswill hold the resulting intersecting Varnodes

References ghidra::Varnode::getCover(), ghidra::HighVariable::getInstance(), ghidra::Cover::intersectByBlock(), and ghidra::HighVariable::numInstances().

◆ intersection()

bool ghidra::HighIntersectTest::intersection ( HighVariable a,
HighVariable b 
)

Test the intersection of two HighVariables and cache the result.

If the Covers of the two variables intersect, this routine returns true. To avoid expensive computation on the Cover objects themselves, the test result associated with the pair of HighVariables is cached.

Parameters
ais the first HighVariable
bis the second HighVariable
Returns
true if the variables intersect

References ghidra::HighVariable::getCover(), and ghidra::Cover::intersectList().

◆ moveIntersectTests()

void ghidra::HighIntersectTest::moveIntersectTests ( HighVariable high1,
HighVariable high2 
)

Translate any intersection tests for high2 into tests for high1.

The two variables will be merged and high2, as an object, will be freed. We update the cached intersection tests for high2 so that they will now apply to new merged high1

Parameters
high1is the variable object being kept
high2is the variable object being eliminated

References ghidra::HighVariable::setMark().

Referenced by ghidra::HighVariable::merge().

◆ purgeHigh()

void ghidra::HighIntersectTest::purgeHigh ( HighVariable high)
private

Remove cached intersection tests for a given HighVariable.

All tests for pairs where either the first or second HighVariable matches the given one are removed.

Parameters
highis the given HighVariable to purge

◆ testBlockIntersection()

bool ghidra::HighIntersectTest::testBlockIntersection ( HighVariable a,
int4  blk,
const Cover cover,
int4  relOff,
const vector< Varnode *> &  blist 
)
staticprivate

Test instances of a the given HighVariable for intersection on a specific block with a cover.

A list of Varnodes has already been determined to intersect on the block. For an instance that does as well, a final test of copy shadowing is performed with the Varnode list. If there is no shadowing, a merging intersection has been found and true is returned.

Parameters
ais the given HighVariable
blkis the specific block number
coveris the Cover to test for intersection
relOffis the relative byte offset of the HighVariable to the Varnodes
blistis the list of Varnodes for copy shadow testing
Returns
true if there is an intersection preventing merging

References ghidra::Varnode::copyShadow(), ghidra::Varnode::getCover(), ghidra::HighVariable::getInstance(), ghidra::Varnode::getSize(), ghidra::Cover::intersectByBlock(), ghidra::HighVariable::numInstances(), and ghidra::Varnode::partialCopyShadow().

◆ updateHigh()

bool ghidra::HighIntersectTest::updateHigh ( HighVariable a)

Make sure given HighVariable's Cover is up-to-date.

As manipulations are made, Cover information gets out of date. A dirty flag is used to indicate a particular HighVariable Cover is out-of-date. This routine checks the dirty flag and updates the Cover information if it is set.

Parameters
ais the HighVariable to update
Returns
true if the HighVariable was not originally dirty

References ghidra::HighVariable::isCoverDirty(), and ghidra::HighVariable::updateCover().


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