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

A pool of Rules that apply simultaneously. More...

#include <action.hh>

Inheritance diagram for ghidra::ActionPool:
ghidra::Action

Public Member Functions

 ActionPool (uint4 f, const string &nm)
 Construct providing properties and name.
 
virtual ~ActionPool (void)
 Destructor.
 
void addRule (Rule *rl)
 Add a Rule to the pool. More...
 
virtual void clearBreakPoints (void)
 Clear all breakpoints set on this Action.
 
virtual Actionclone (const ActionGroupList &grouplist) const
 Clone the Action. More...
 
virtual void reset (Funcdata &data)
 Reset the Action for a new function. More...
 
virtual void resetStats (void)
 Reset all the counts to zero. More...
 
virtual int4 apply (Funcdata &data)
 Make a single attempt to apply this Action. More...
 
virtual int4 print (ostream &s, int4 num, int4 depth) const
 Print a description of this Action to stream. More...
 
virtual void printState (ostream &s) const
 Print status to stream. More...
 
virtual RulegetSubRule (const string &specify)
 Retrieve a specific sub-rule by name. More...
 
virtual void printStatistics (ostream &s) const
 Dump statistics to stream. More...
 
- Public Member Functions inherited from ghidra::Action
 Action (uint4 f, const string &nm, const string &g)
 Base constructor for an Action. More...
 
virtual ~Action (void)
 Destructor.
 
int4 perform (Funcdata &data)
 Perform this action (if necessary) More...
 
bool setBreakPoint (uint4 tp, const string &specify)
 Set a breakpoint on this action. More...
 
bool setWarning (bool val, const string &specify)
 Set a warning on this action. More...
 
bool disableRule (const string &specify)
 Disable a specific Rule within this. More...
 
bool enableRule (const string &specify)
 Enable a specific Rule within this. More...
 
const string & getName (void) const
 Get the Action's name.
 
const string & getGroup (void) const
 Get the Action's group.
 
uint4 getStatus (void) const
 Get the current status of this Action.
 
uint4 getNumTests (void)
 Get the number of times apply() was invoked.
 
uint4 getNumApply (void)
 
virtual ActiongetSubAction (const string &specify)
 Retrieve a specific sub-action by name. More...
 

Private Member Functions

int4 processOp (PcodeOp *op, Funcdata &data)
 Apply the next possible Rule to a PcodeOp. More...
 

Private Attributes

vector< Rule * > allrules
 The set of Rules in this ActionPool.
 
vector< Rule * > perop [CPUI_MAX]
 Rules associated with each OpCode.
 
PcodeOpTree::const_iterator op_state
 Current PcodeOp up for rule application.
 
int4 rule_index
 Iterator over Rules for one OpCode.
 

Additional Inherited Members

- Public Types inherited from ghidra::Action
enum  ruleflags {
  rule_repeatapply = 4, rule_onceperfunc = 8, rule_oneactperfunc = 16, rule_debug = 32,
  rule_warnings_on = 64, rule_warnings_given = 128
}
 Boolean behavior properties governing this particular Action. More...
 
enum  statusflags {
  status_start =1, status_breakstarthit =2, status_repeat =4, status_mid =8,
  status_end =16, status_actionbreak =32
}
 Boolean properties describing the status of an action. More...
 
enum  breakflags { break_start = 1, tmpbreak_start = 2, break_action = 4, tmpbreak_action = 8 }
 Break points associated with an Action. More...
 
- Protected Member Functions inherited from ghidra::Action
void issueWarning (Architecture *glb)
 Warn that this Action has applied. More...
 
bool checkStartBreak (void)
 Check start breakpoint. More...
 
bool checkActionBreak (void)
 Check action breakpoint. More...
 
void turnOnWarnings (void)
 Enable warnings for this Action.
 
void turnOffWarnings (void)
 Disable warnings for this Action.
 
- Protected Attributes inherited from ghidra::Action
int4 lcount
 Changes not including last call to apply()
 
int4 count
 Number of changes made by this action so far.
 
uint4 status
 Current status.
 
uint4 breakpoint
 Breakpoint properties.
 
uint4 flags
 Behavior properties.
 
uint4 count_tests
 Number of times apply() has been called.
 
uint4 count_apply
 Number of times apply() made changes.
 
string name
 Name of the action.
 
string basegroup
 Base group this action belongs to.
 

Detailed Description

A pool of Rules that apply simultaneously.

This class groups together a set of Rules as a formal Action. Rules are given an opportunity to apply to every PcodeOp in a function. Usually rule_repeatapply is enabled for this action, which causes all Rules to apply repeatedly until no Rule can make an additional change.

Member Function Documentation

◆ addRule()

void ghidra::ActionPool::addRule ( Rule rl)

Add a Rule to the pool.

This method should only be invoked during construction of this ActionPool A single Rule is added to the pool. The Rule's OpCode is inspected by this method.

Parameters
rlis the Rule to add

References ghidra::Rule::getOpList().

Referenced by clone(), and ghidra::ActionDatabase::universalAction().

◆ apply()

int4 ghidra::ActionPool::apply ( Funcdata data)
virtual

Make a single attempt to apply this Action.

This is the main entry point for applying changes to a function that are specific to this Action. The method can inspect whatever it wants to decide if the Action does or does not apply. Changes are indicated by incrementing the count field.

Parameters
datais the function to inspect/modify
Returns
0 for a complete application, -1 for a partial completion (due to breakpoint)

Implements ghidra::Action.

References ghidra::Funcdata::beginOpAll(), ghidra::Funcdata::endOpAll(), ghidra::Action::status, and ghidra::Action::status_mid.

◆ clone()

Action * ghidra::ActionPool::clone ( const ActionGroupList grouplist) const
virtual

Clone the Action.

If this Action is a member of one of the groups in the grouplist, this returns a clone of the Action, otherwise NULL is returned.

Parameters
grouplistis the list of groups being cloned
Returns
the cloned Action or NULL

Implements ghidra::Action.

References addRule(), ghidra::Rule::clone(), ghidra::Action::flags, and ghidra::Action::getName().

◆ getSubRule()

Rule * ghidra::ActionPool::getSubRule ( const string &  specify)
virtual

Retrieve a specific sub-rule by name.

Find a Rule, as a component of this Action, with the given name.

Parameters
specifyis the name of the rule
Returns
the matching sub-rule

Reimplemented from ghidra::Action.

References ghidra::Rule::getName(), and ghidra::Action::name.

◆ print()

int4 ghidra::ActionPool::print ( ostream &  s,
int4  num,
int4  depth 
) const
virtual

Print a description of this Action to stream.

The description is suitable for a console mode listing of actions

Parameters
sis the output stream
numis a starting index to associate with the action (and its sub-actions)
depthis amount of indent necessary before printing
Returns
the next available index

Reimplemented from ghidra::Action.

References ghidra::Action::break_action, ghidra::Rule::getBreakPoint(), ghidra::Rule::getName(), ghidra::Rule::isDisabled(), and ghidra::Action::print().

◆ printState()

void ghidra::ActionPool::printState ( ostream &  s) const
virtual

Print status to stream.

This will the Action name and the next step to execute

Parameters
sis the output stream

Reimplemented from ghidra::Action.

References ghidra::PcodeOp::getSeqNum(), ghidra::Action::printState(), ghidra::Action::status, and ghidra::Action::status_mid.

◆ printStatistics()

void ghidra::ActionPool::printStatistics ( ostream &  s) const
virtual

Dump statistics to stream.

Print out the collected statistics for the Action to stream

Parameters
sis the output stream

Reimplemented from ghidra::Action.

References ghidra::Action::printStatistics(), and ghidra::ActionDatabase::universalname.

◆ processOp()

int4 ghidra::ActionPool::processOp ( PcodeOp op,
Funcdata data 
)
private

Apply the next possible Rule to a PcodeOp.

This method attempts to apply each Rule to the current PcodeOp Action breakpoints are checked if the Rule successfully applies. 0 is returned for no breakpoint, -1 if a breakpoint occurs. If a breakpoint did occur, an additional call to processOp() will pick up where it left off before the breakpoint. The PcodeOp iterator is advanced.

Parameters
opis the current PcodeOp
datais the function being transformed
Returns
0 if no breakpoint, -1 otherwise

References ghidra::Rule::applyOp(), ghidra::Rule::checkActionBreak(), ghidra::PcodeOp::code(), ghidra::Action::count, ghidra::Rule::count_apply, ghidra::Rule::count_tests, ghidra::Funcdata::getArch(), ghidra::Rule::getName(), ghidra::PcodeOp::isDead(), ghidra::Rule::isDisabled(), ghidra::Rule::issueWarning(), ghidra::Funcdata::opDeadAndGone(), and ghidra::Architecture::printMessage().

◆ reset()

void ghidra::ActionPool::reset ( Funcdata data)
virtual

Reset the Action for a new function.

Parameters
datais the new function this Action may affect

Reimplemented from ghidra::Action.

References ghidra::Action::reset().

◆ resetStats()

void ghidra::ActionPool::resetStats ( void  )
virtual

Reset all the counts to zero.

Reset the statistics

Reimplemented from ghidra::Action.

References ghidra::Action::resetStats().


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