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

Container class for PcodeOps associated with a single function. More...

#include <op.hh>

Public Member Functions

void clear (void)
 Clear all PcodeOps from this container.
 
 PcodeOpBank (void)
 Constructor.
 
 ~PcodeOpBank (void)
 Destructor.
 
void setUniqId (uintm val)
 Set the unique id counter.
 
uintm getUniqId (void) const
 Get the next unique id.
 
PcodeOpcreate (int4 inputs, const Address &pc)
 Create a PcodeOp with at a given Address. More...
 
PcodeOpcreate (int4 inputs, const SeqNum &sq)
 Create a PcodeOp with a given sequence number. More...
 
void destroy (PcodeOp *op)
 Destroy/retire the given PcodeOp. More...
 
void destroyDead (void)
 Destroy/retire all PcodeOps in the dead list.
 
void changeOpcode (PcodeOp *op, TypeOp *newopc)
 Change the op-code for the given PcodeOp. More...
 
void markAlive (PcodeOp *op)
 Mark the given PcodeOp as alive. More...
 
void markDead (PcodeOp *op)
 Mark the given PcodeOp as dead. More...
 
void insertAfterDead (PcodeOp *op, PcodeOp *prev)
 Insert the given PcodeOp after a point in the dead list. More...
 
void moveSequenceDead (PcodeOp *firstop, PcodeOp *lastop, PcodeOp *prev)
 Move a sequence of PcodeOps to a point in the dead list. More...
 
void markIncidentalCopy (PcodeOp *firstop, PcodeOp *lastop)
 Mark any COPY ops in the given range as incidental. More...
 
bool empty (void) const
 Return true if there are no PcodeOps in this container.
 
PcodeOptarget (const Address &addr) const
 Find the first executing PcodeOp for a target address. More...
 
PcodeOpfindOp (const SeqNum &num) const
 Find a PcodeOp by sequence number. More...
 
PcodeOpfallthru (const PcodeOp *op) const
 Find the PcodeOp considered a fallthru of the given PcodeOp. More...
 
PcodeOpTree::const_iterator beginAll (void) const
 Start of all PcodeOps in sequence number order.
 
PcodeOpTree::const_iterator endAll (void) const
 End of all PcodeOps in sequence number order.
 
PcodeOpTree::const_iterator begin (const Address &addr) const
 Start of all PcodeOps at one Address.
 
PcodeOpTree::const_iterator end (const Address &addr) const
 End of all PcodeOps at one Address.
 
list< PcodeOp * >::const_iterator beginAlive (void) const
 Start of all PcodeOps marked as alive.
 
list< PcodeOp * >::const_iterator endAlive (void) const
 End of all PcodeOps marked as alive.
 
list< PcodeOp * >::const_iterator beginDead (void) const
 Start of all PcodeOps marked as dead.
 
list< PcodeOp * >::const_iterator endDead (void) const
 End of all PcodeOps marked as dead.
 
list< PcodeOp * >::const_iterator begin (OpCode opc) const
 Start of all PcodeOps sharing the given op-code.
 
list< PcodeOp * >::const_iterator end (OpCode opc) const
 End of all PcodeOps sharing the given op-code.
 

Private Member Functions

void addToCodeList (PcodeOp *op)
 Add given PcodeOp to specific op-code list. More...
 
void removeFromCodeList (PcodeOp *op)
 Remove given PcodeOp from specific op-code list. More...
 
void clearCodeLists (void)
 Clear all op-code specific lists.
 

Private Attributes

PcodeOpTree optree
 The main sequence number sort.
 
list< PcodeOp * > deadlist
 List of dead PcodeOps.
 
list< PcodeOp * > alivelist
 List of alive PcodeOps.
 
list< PcodeOp * > storelist
 List of STORE PcodeOps.
 
list< PcodeOp * > loadlist
 list of LOAD PcodeOps
 
list< PcodeOp * > returnlist
 List of RETURN PcodeOps.
 
list< PcodeOp * > useroplist
 List of user-defined PcodeOps.
 
list< PcodeOp * > deadandgone
 List of retired PcodeOps.
 
uintm uniqid
 Counter for producing unique id's for each op.
 

Detailed Description

Container class for PcodeOps associated with a single function.

The PcodeOp objects are maintained under multiple different sorting criteria to facilitate quick access in various situations. The main sort (PcodeOpTree) is by sequence number (SeqNum). PcodeOps are also grouped into alive and dead lists to distinguish between raw p-code ops and those that are fully linked into control-flow. Several lists group PcodeOps with important op-codes (like STORE and RETURN).

Member Function Documentation

◆ addToCodeList()

void ghidra::PcodeOpBank::addToCodeList ( PcodeOp op)
private

Add given PcodeOp to specific op-code list.

Add the PcodeOp to the list of ops with the same op-code. Currently only certain op-codes have a dedicated list.

Parameters
opis the given PcodeOp

References ghidra::PcodeOp::code(), ghidra::PcodeOp::codeiter, ghidra::CPUI_CALLOTHER, ghidra::CPUI_LOAD, ghidra::CPUI_RETURN, and ghidra::CPUI_STORE.

◆ changeOpcode()

void ghidra::PcodeOpBank::changeOpcode ( PcodeOp op,
TypeOp newopc 
)

Change the op-code for the given PcodeOp.

The PcodeOp is assigned the new op-code, which may involve moving it between the internal op-code specific lists.

Parameters
opis the given PcodeOp to change
newopcis the new op-code object

References ghidra::PcodeOp::opcode, and ghidra::PcodeOp::setOpcode().

Referenced by ghidra::Funcdata::opSetOpcode().

◆ create() [1/2]

PcodeOp * ghidra::PcodeOpBank::create ( int4  inputs,
const Address pc 
)

Create a PcodeOp with at a given Address.

A new PcodeOp is allocated with the indicated number of input slots, which start out empty. A sequence number is assigned, and the op is added to the end of the dead list.

Parameters
inputsis the number of input slots
pcis the Address to associate with the PcodeOp
Returns
the newly allocated PcodeOp

References ghidra::PcodeOp::dead, ghidra::PcodeOp::getSeqNum(), ghidra::PcodeOp::insertiter, ghidra::PcodeOp::PcodeOp(), and ghidra::PcodeOp::setFlag().

Referenced by ghidra::Funcdata::newOp().

◆ create() [2/2]

PcodeOp * ghidra::PcodeOpBank::create ( int4  inputs,
const SeqNum sq 
)

Create a PcodeOp with a given sequence number.

A new PcodeOp is allocated with the indicated number of input slots and the specific sequence number, suitable for cloning and restoring from XML. The op is added to the end of the dead list.

Parameters
inputsis the number of input slots
sqis the specified sequence number
Returns
the newly allocated PcodeOp

References ghidra::PcodeOp::dead, ghidra::PcodeOp::getSeqNum(), ghidra::SeqNum::getTime(), ghidra::PcodeOp::insertiter, ghidra::PcodeOp::PcodeOp(), and ghidra::PcodeOp::setFlag().

◆ destroy()

void ghidra::PcodeOpBank::destroy ( PcodeOp op)

Destroy/retire the given PcodeOp.

The given PcodeOp is removed from all internal lists and added to a final deadandgone list. The memory is not reclaimed until the whole container is destroyed, in case pointer references still exist. These will all still be marked as dead.

Parameters
opis the given PcodeOp to destroy

References ghidra::PcodeOp::getSeqNum(), ghidra::PcodeOp::insertiter, and ghidra::PcodeOp::isDead().

Referenced by ghidra::Funcdata::opDeadAndGone(), and ghidra::Funcdata::opDestroyRaw().

◆ fallthru()

PcodeOp * ghidra::PcodeOpBank::fallthru ( const PcodeOp op) const

Find the PcodeOp considered a fallthru of the given PcodeOp.

The term fallthru in this context refers to p-code not assembly instructions.

Parameters
opis the given PcodeOp
Returns
the fallthru PcodeOp

References ghidra::PcodeOp::getSeqNum(), ghidra::PcodeOp::insertiter, ghidra::PcodeOp::isDead(), ghidra::PcodeOp::isInstructionStart(), and ghidra::PcodeOp::nextOp().

◆ findOp()

PcodeOp * ghidra::PcodeOpBank::findOp ( const SeqNum num) const

Find a PcodeOp by sequence number.

Parameters
numis the given sequence number
Returns
the matching PcodeOp (or NULL)

Referenced by ghidra::Funcdata::findOp(), ghidra::FlowInfo::findRelTarget(), and ghidra::FlowInfo::target().

◆ insertAfterDead()

void ghidra::PcodeOpBank::insertAfterDead ( PcodeOp op,
PcodeOp prev 
)

Insert the given PcodeOp after a point in the dead list.

The op is moved to right after a specified op in the dead list.

Parameters
opis the given PcodeOp to move
previs the specified op in the dead list

References ghidra::PcodeOp::insertiter, and ghidra::PcodeOp::isDead().

Referenced by ghidra::Funcdata::opDeadInsertAfter().

◆ markAlive()

void ghidra::PcodeOpBank::markAlive ( PcodeOp op)

Mark the given PcodeOp as alive.

The PcodeOp is moved out of the dead list into the alive list. The PcodeOp::isDead() method will now return false.

Parameters
opis the given PcodeOp to mark

References ghidra::PcodeOp::clearFlag(), ghidra::PcodeOp::dead, and ghidra::PcodeOp::insertiter.

Referenced by ghidra::Funcdata::opInsert().

◆ markDead()

void ghidra::PcodeOpBank::markDead ( PcodeOp op)

Mark the given PcodeOp as dead.

The PcodeOp is moved out of the alive list into the dead list. The PcodeOp::isDead() method will now return true.

Parameters
opis the given PcodeOp to mark

References ghidra::PcodeOp::dead, ghidra::PcodeOp::insertiter, and ghidra::PcodeOp::setFlag().

Referenced by ghidra::Funcdata::opDestroy(), and ghidra::Funcdata::opUninsert().

◆ markIncidentalCopy()

void ghidra::PcodeOpBank::markIncidentalCopy ( PcodeOp firstop,
PcodeOp lastop 
)

Mark any COPY ops in the given range as incidental.

Incidental COPYs are not considered active use of parameter passing Varnodes by parameter analysis algorithms.

Parameters
firstopis the start of the range of incidental COPY ops
lastopis the end of the range of incidental COPY ops

References ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::PcodeOp::incidental_copy, ghidra::PcodeOp::insertiter, and ghidra::PcodeOp::setAdditionalFlag().

Referenced by ghidra::FlowInfo::doInjection().

◆ moveSequenceDead()

void ghidra::PcodeOpBank::moveSequenceDead ( PcodeOp firstop,
PcodeOp lastop,
PcodeOp prev 
)

Move a sequence of PcodeOps to a point in the dead list.

The point is right after a provided op. All ops must be in the dead list.

Parameters
firstopis the first PcodeOp in the sequence to be moved
lastopis the last PcodeOp in the sequence to be moved
previs the provided point to move to

References ghidra::PcodeOp::insertiter.

Referenced by ghidra::FlowInfo::doInjection(), and ghidra::Funcdata::inlineFlow().

◆ removeFromCodeList()

void ghidra::PcodeOpBank::removeFromCodeList ( PcodeOp op)
private

Remove given PcodeOp from specific op-code list.

Remove the PcodeOp from its list of ops with the same op-code. Currently only certain op-codes have a dedicated list.

Parameters
opis the given PcodeOp

References ghidra::PcodeOp::code(), ghidra::PcodeOp::codeiter, ghidra::CPUI_CALLOTHER, ghidra::CPUI_LOAD, ghidra::CPUI_RETURN, and ghidra::CPUI_STORE.

◆ target()

PcodeOp * ghidra::PcodeOpBank::target ( const Address addr) const

Find the first executing PcodeOp for a target address.

Find the first PcodeOp at or after the given Address assuming they have not yet been broken up into basic blocks. Take into account delay slots.

Parameters
addris the given Address
Returns
the targeted PcodeOp (or NULL)

References ghidra::PcodeOp::target().

Referenced by ghidra::Funcdata::target().


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