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

All paths from a (putative) switch variable to the CPUI_BRANCHIND. More...

#include <jumptable.hh>

Classes

struct  RootedOp
 A PcodeOp in the path set associated with the last Varnode in the intersection. More...
 

Public Member Functions

void set (const PathMeld &op2)
 Copy paths from another container. More...
 
void set (const vector< PcodeOpNode > &path)
 Initialize this to be a single path. More...
 
void set (PcodeOp *op, Varnode *vn)
 Initialize this container to a single node "path". More...
 
void append (const PathMeld &op2)
 Append a new set of paths to this set of paths. More...
 
void clear (void)
 Clear this to be an empty container.
 
void meld (vector< PcodeOpNode > &path)
 Meld a new path into this container. More...
 
void markPaths (bool val, int4 startVarnode)
 Mark PcodeOps paths from the given start. More...
 
int4 numCommonVarnode (void) const
 Return the number of Varnodes common to all paths.
 
int4 numOps (void) const
 Return the number of PcodeOps across all paths.
 
VarnodegetVarnode (int4 i) const
 Get the i-th common Varnode.
 
VarnodegetOpParent (int4 i) const
 Get the split-point for the i-th PcodeOp.
 
PcodeOpgetOp (int4 i) const
 Get the i-th PcodeOp.
 
PcodeOpgetEarliestOp (int4 pos) const
 Find earliest PcodeOp that has a specific common Varnode as input. More...
 
bool empty (void) const
 Return true if this container holds no paths.
 

Private Member Functions

void internalIntersect (vector< int4 > &parentMap)
 Calculate intersection of a new Varnode path with the old path. More...
 
int4 meldOps (const vector< PcodeOpNode > &path, int4 cutOff, const vector< int4 > &parentMap)
 Meld in PcodeOps from a new path into this container. More...
 
void truncatePaths (int4 cutPoint)
 Truncate all paths at the given new Varnode. More...
 

Private Attributes

vector< Varnode * > commonVn
 Varnodes in common with all paths.
 
vector< RootedOpopMeld
 All the ops for the melded paths.
 

Detailed Description

All paths from a (putative) switch variable to the CPUI_BRANCHIND.

This is a container for intersecting paths during the construction of a JumpModel. It contains every PcodeOp from some starting Varnode through all paths to a specific BRANCHIND. The paths can split and rejoin. This also keeps track of Varnodes that are present on all paths, as these are the potential switch variables for the model.

Member Function Documentation

◆ append()

void ghidra::PathMeld::append ( const PathMeld op2)

Append a new set of paths to this set of paths.

The new paths must all start at the common end-point of the paths in this container. The new set of melded paths start at the original common start point for this container, flow through this old common end-point, and end at the new common end-point.

Parameters
op2is the set of paths to be appended

References commonVn, and opMeld.

◆ getEarliestOp()

PcodeOp * ghidra::PathMeld::getEarliestOp ( int4  pos) const

Find earliest PcodeOp that has a specific common Varnode as input.

The Varnode is specified by an index into sequence of Varnodes common to all paths in this PathMeld. We find the earliest (as in executed first) PcodeOp, within this PathMeld that uses the Varnode as input.

Parameters
posis the index of the Varnode
Returns
the earliest PcodeOp using the Varnode

◆ internalIntersect()

void ghidra::PathMeld::internalIntersect ( vector< int4 > &  parentMap)
private

Calculate intersection of a new Varnode path with the old path.

The new path of Varnodes must all be marked. The old path, commonVn, is replaced with the intersection. A map is created from the index of each Varnode in the old path with its index in the new path. If the Varnode is not in the intersection, its index is mapped to -1.

Parameters
parentMapwill hold the new index map

References ghidra::Varnode::clearMark(), and ghidra::Varnode::isMark().

◆ markPaths()

void ghidra::PathMeld::markPaths ( bool  val,
int4  startVarnode 
)

Mark PcodeOps paths from the given start.

The starting Varnode, common to all paths, is provided as an index. All PcodeOps up to the final BRANCHIND are (un)marked.

Parameters
valis true for marking, false for unmarking
startVarnodeis the index of the starting PcodeOp

◆ meld()

void ghidra::PathMeld::meld ( vector< PcodeOpNode > &  path)

Meld a new path into this container.

Add the new path, recalculating the set of Varnodes common to all paths. Paths are trimmed to ensure that any path that splits from the common intersection must eventually rejoin.

Parameters
pathis the new path of PcodeOpNode edges to meld, in reverse execution order

References ghidra::Varnode::clearMark(), ghidra::PcodeOp::getIn(), ghidra::Varnode::isMark(), ghidra::PcodeOpNode::op, ghidra::Varnode::setMark(), and ghidra::PcodeOpNode::slot.

◆ meldOps()

int4 ghidra::PathMeld::meldOps ( const vector< PcodeOpNode > &  path,
int4  cutOff,
const vector< int4 > &  parentMap 
)
private

Meld in PcodeOps from a new path into this container.

Execution order of the PcodeOps in the container is maintained. Each PcodeOp, old or new, has its split point from the common path recalculated. PcodeOps that split (use a vn not in intersection) and do not rejoin (have a predecessor Varnode in the intersection) get removed. If splitting PcodeOps can't be ordered with the existing meld, we get a new cut point.

Parameters
pathis the new path of PcodeOps in sequence
cutOffis the number of PcodeOps with an input in the common path
parentMapis the map from old common Varnodes to the new common Varnodes
Returns
the index of the last (earliest) Varnode in the common path or -1

References ghidra::SeqNum::getOrder(), ghidra::PcodeOp::getParent(), and ghidra::PcodeOp::getSeqNum().

◆ set() [1/3]

void ghidra::PathMeld::set ( const PathMeld op2)

Copy paths from another container.

Parameters
op2is the path container to copy from

References commonVn, and opMeld.

◆ set() [2/3]

void ghidra::PathMeld::set ( const vector< PcodeOpNode > &  path)

Initialize this to be a single path.

This container is initialized to hold a single data-flow path.

Parameters
pathis the list of PcodeOpNode edges in the path (in reverse execution order)

References ghidra::PcodeOp::getIn(), ghidra::PcodeOpNode::op, and ghidra::PcodeOpNode::slot.

◆ set() [3/3]

void ghidra::PathMeld::set ( PcodeOp op,
Varnode vn 
)

Initialize this container to a single node "path".

Parameters
opis the one PcodeOp in the path
vnis the one Varnode (input to the PcodeOp) in the path

◆ truncatePaths()

void ghidra::PathMeld::truncatePaths ( int4  cutPoint)
private

Truncate all paths at the given new Varnode.

The given Varnode is provided as an index into the current common Varnode list. All Varnodes and PcodeOps involved in execution before this new cut point are removed.

Parameters
cutPointis the given new Varnode

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