decompiler
1.0.0
|
Class for performing a single transformation on a PcodeOp or Varnode. More...
#include <action.hh>
Public Types | |
enum | typeflags { type_disable = 1, rule_debug = 2, warnings_on = 4, warnings_given = 8 } |
Properties associated with a Rule. More... | |
Public Member Functions | |
Rule (const string &g, uint4 fl, const string &nm) | |
Construct given group, properties name. More... | |
virtual | ~Rule (void) |
Destructor. | |
const string & | getName (void) const |
Return the name of this Rule. | |
const string & | getGroup (void) const |
Return the group this Rule belongs to. | |
uint4 | getNumTests (void) |
Get number of attempted applications. | |
uint4 | getNumApply (void) |
Get number of successful applications. | |
void | setBreak (uint4 tp) |
Set a breakpoint on this Rule. | |
void | clearBreak (uint4 tp) |
Clear a breakpoint on this Rule. | |
void | clearBreakPoints (void) |
Clear all breakpoints on this Rule. | |
void | turnOnWarnings (void) |
Enable warnings for this Rule. | |
void | turnOffWarnings (void) |
Disable warnings for this Rule. | |
bool | isDisabled (void) const |
Return true if this Rule is disabled. | |
void | setDisable (void) |
Disable this Rule (within its pool) | |
void | clearDisable (void) |
Enable this Rule (within its pool) | |
bool | checkActionBreak (void) |
Check if an action breakpoint is turned on. More... | |
uint4 | getBreakPoint (void) const |
Return breakpoint toggles. | |
virtual Rule * | clone (const ActionGroupList &grouplist) const =0 |
Clone the Rule. More... | |
virtual void | getOpList (vector< uint4 > &oplist) const |
List of op codes this rule operates on. More... | |
virtual int4 | applyOp (PcodeOp *op, Funcdata &data) |
Attempt to apply this Rule. More... | |
virtual void | reset (Funcdata &data) |
Reset this Rule. More... | |
virtual void | resetStats (void) |
Reset Rule statistics. More... | |
virtual void | printStatistics (ostream &s) const |
Print statistics for this Rule. More... | |
Private Member Functions | |
void | issueWarning (Architecture *glb) |
If enabled, print a warning that this Rule has been applied. More... | |
Private Attributes | |
uint4 | flags |
Properties enabled with this Rule. | |
uint4 | breakpoint |
Breakpoint(s) enabled for this Rule. | |
string | name |
Name of the Rule. | |
string | basegroup |
Group to which this Rule belongs. | |
uint4 | count_tests |
Number of times this Rule has attempted to apply. | |
uint4 | count_apply |
Number of times this Rule has successfully been applied. | |
Friends | |
class | ActionPool |
Class for performing a single transformation on a PcodeOp or Varnode.
A Rule, through its applyOp() method, is handed a specific PcodeOp as a potential point to apply. It determines if it can apply at that point, then makes any changes. Rules inform the system of what types of PcodeOps they can possibly apply to through the getOpList() method. A set of Rules are pooled together into a single Action via the ActionPool, which efficiently applies each Rule across a whole function. A Rule supports the same breakpoint properties as an Action. A Rule is allowed to keep state that is specific to a given function (Funcdata). The reset() method is invoked to purge this state for each new function to be transformed.
Properties associated with a Rule.
ghidra::Rule::Rule | ( | const string & | g, |
uint4 | fl, | ||
const string & | nm | ||
) |
Construct given group, properties name.
g | is the groupname to which this Rule belongs |
fl | is the set of properties |
nm | is the name of the Rule |
References ghidra::Action::basegroup, ghidra::Action::breakpoint, ghidra::Action::count_apply, ghidra::Action::count_tests, ghidra::Action::flags, and ghidra::Action::name.
Attempt to apply this Rule.
This method contains the main logic for applying the Rule. It must use a given PcodeOp as the point at which the Rule applies. If it does apply, changes are made directly to the function and 1 (non-zero) is returned, otherwise 0 is returned.
Reimplemented in ghidra::RuleLzcountShiftBool, ghidra::RuleXorSwap, ghidra::RulePiecePathology, ghidra::RuleOrMultiBool, ghidra::RulePopcountBoolXor, ghidra::RuleThreeWayCompare, ghidra::RuleFuncPtrEncoding, ghidra::RuleIgnoreNan, ghidra::RuleFloatCast, ghidra::RuleConditionalMove, ghidra::RuleNegateNegate, ghidra::RuleSubfloatConvert, ghidra::RuleSubvarSext, ghidra::RuleSubvarZext, ghidra::RuleSubvarShift, ghidra::RuleSubvarCompZero, ghidra::RulePtrFlow, ghidra::RuleSplitFlow, ghidra::RuleSubvarSubpiece, ghidra::RuleSubvarAnd, ghidra::RuleSegment, ghidra::RuleSignMod2nOpt2, ghidra::RuleSignMod2Opt, ghidra::RuleSignMod2nOpt, ghidra::RuleModOpt, ghidra::RuleSignNearMult, ghidra::RuleSignForm2, ghidra::RuleSignForm, ghidra::RuleDivChain, ghidra::RuleSignDiv2, ghidra::RuleDivOpt, ghidra::RuleDivTermAdd2, ghidra::RuleDivTermAdd, ghidra::RulePositiveDiv, ghidra::RuleSubNormal, ghidra::RuleSplitStore, ghidra::RuleSplitLoad, ghidra::RuleSplitCopy, ghidra::RulePieceStructure, ghidra::RuleExtensionPush, ghidra::RulePtrsubCharConstant, ghidra::RuleSubRight, ghidra::Rule2Comp2Sub, ghidra::RuleAddUnsigned, ghidra::RuleMultNegOne, ghidra::RulePtrsubUndo, ghidra::RulePtraddUndo, ghidra::RulePushPtr, ghidra::RuleStructOffset0, ghidra::RulePtrArith, ghidra::RuleEqual2Constant, ghidra::RuleEqual2Zero, ghidra::RuleSLess2Zero, ghidra::RuleLessEqual2Zero, ghidra::RuleLess2Zero, ghidra::RuleBoolNegate, ghidra::RuleCondNegate, ghidra::RuleSwitchSingle, ghidra::RuleHumptyOr, ghidra::RuleDumptyHump, ghidra::RuleHumptyDumpty, ghidra::RuleShiftSub, ghidra::RuleSubCancel, ghidra::RuleSubZext, ghidra::RuleConcatLeftShift, ghidra::RuleConcatZero, ghidra::RuleShiftAnd, ghidra::RuleZextShiftZext, ghidra::RuleZextCommute, ghidra::RuleConcatZext, ghidra::RuleConcatCommute, ghidra::RuleSubCommute, ghidra::RuleSubExtComm, ghidra::RuleStoreVarnode, ghidra::RuleLoadVarnode, ghidra::RuleAddMultCollapse, ghidra::RuleXorCollapse, ghidra::RuleSub2Add, ghidra::RuleCarryElim, ghidra::Rule2Comp2Mult, ghidra::RulePropagateCopy, ghidra::RuleTransformCpool, ghidra::RuleCollapseConstants, ghidra::RuleShiftPiece, ghidra::RuleShift2Mult, ghidra::RuleIdentityEl, ghidra::RuleTestSign, ghidra::RuleSignShift, ghidra::RuleTrivialShift, ghidra::RuleSborrow, ghidra::RuleMultiCollapse, ghidra::RuleIndirectCollapse, ghidra::RuleLogic2Bool, ghidra::RuleBoolZext, ghidra::RuleBooleanNegate, ghidra::RuleBitUndistribute, ghidra::RuleZextSless, ghidra::RuleSlessToLess, ghidra::RuleZextEliminate, ghidra::RuleTrivialBool, ghidra::RuleTrivialArith, ghidra::RuleLessNotEqual, ghidra::RuleLessEqual, ghidra::RuleShiftCompare, ghidra::RuleLeftRight, ghidra::RuleConcatShift, ghidra::RuleDoubleArithShift, ghidra::RuleDoubleShift, ghidra::RuleDoubleSub, ghidra::RuleAndCompare, ghidra::RuleAndZext, ghidra::RuleAndPiece, ghidra::RuleAndCommute, ghidra::RuleFloatRange, ghidra::RuleRangeMeld, ghidra::RuleLessOne, ghidra::RuleAndDistribute, ghidra::RuleHighOrderAnd, ghidra::RuleNotDistribute, ghidra::RulePushMulti, ghidra::RulePullsubIndirect, ghidra::RulePullsubMulti, ghidra::RuleTermOrder, ghidra::RuleEquality, ghidra::RuleIntLessEqual, ghidra::RuleOrPredicate, ghidra::RuleRightShiftAnd, ghidra::RuleShiftBitops, ghidra::RuleNegateIdentity, ghidra::RuleAndOrLump, ghidra::RuleOrCollapse, ghidra::RuleOrConsume, ghidra::RuleAndMask, ghidra::RuleOrMask, ghidra::RuleBxor2NotEqual, ghidra::RulePiece2Sext, ghidra::RulePiece2Zext, ghidra::RuleSelectCse, ghidra::RuleCollectTerms, and ghidra::RuleEarlyRemoval.
Referenced by ghidra::ActionPool::processOp().
bool ghidra::Rule::checkActionBreak | ( | void | ) |
Check if an action breakpoint is turned on.
This method is called every time the Rule successfully applies. If it returns true, this indicates to the system that an action breakpoint has occurred.
References ghidra::Action::break_action, and ghidra::Action::breakpoint.
Referenced by ghidra::ActionPool::processOp().
|
pure virtual |
Clone the Rule.
If this Rule is a member of one of the groups in the grouplist, this returns a clone of the Rule, otherwise NULL is returned.
grouplist | is the list of groups being cloned |
Implemented in ghidra::RuleLzcountShiftBool, ghidra::RuleXorSwap, ghidra::RulePiecePathology, ghidra::RuleOrMultiBool, ghidra::RulePopcountBoolXor, ghidra::RuleThreeWayCompare, ghidra::RuleFuncPtrEncoding, ghidra::RuleIgnoreNan, ghidra::RuleFloatCast, ghidra::RuleConditionalMove, ghidra::RuleNegateNegate, ghidra::RuleSubfloatConvert, ghidra::RuleSubvarSext, ghidra::RuleSubvarZext, ghidra::RuleSubvarShift, ghidra::RuleSubvarCompZero, ghidra::RulePtrFlow, ghidra::RuleSplitFlow, ghidra::RuleSubvarSubpiece, ghidra::RuleSubvarAnd, ghidra::RuleSegment, ghidra::RuleSignMod2nOpt2, ghidra::RuleSignMod2Opt, ghidra::RuleSignMod2nOpt, ghidra::RuleModOpt, ghidra::RuleSignNearMult, ghidra::RuleSignForm2, ghidra::RuleSignForm, ghidra::RuleDivChain, ghidra::RuleSignDiv2, ghidra::RuleDivOpt, ghidra::RuleDivTermAdd2, ghidra::RuleDivTermAdd, ghidra::RulePositiveDiv, ghidra::RuleSubNormal, ghidra::RuleSplitStore, ghidra::RuleSplitLoad, ghidra::RuleSplitCopy, ghidra::RulePieceStructure, ghidra::RuleExtensionPush, ghidra::RulePtrsubCharConstant, ghidra::RuleSubRight, ghidra::Rule2Comp2Sub, ghidra::RuleAddUnsigned, ghidra::RuleMultNegOne, ghidra::RulePtrsubUndo, ghidra::RulePtraddUndo, ghidra::RulePushPtr, ghidra::RuleStructOffset0, ghidra::RulePtrArith, ghidra::RuleEqual2Constant, ghidra::RuleEqual2Zero, ghidra::RuleSLess2Zero, ghidra::RuleLessEqual2Zero, ghidra::RuleLess2Zero, ghidra::RuleBoolNegate, ghidra::RuleCondNegate, ghidra::RuleSwitchSingle, ghidra::RuleHumptyOr, ghidra::RuleDumptyHump, ghidra::RuleHumptyDumpty, ghidra::RuleShiftSub, ghidra::RuleSubCancel, ghidra::RuleSubZext, ghidra::RuleConcatLeftShift, ghidra::RuleConcatZero, ghidra::RuleShiftAnd, ghidra::RuleZextShiftZext, ghidra::RuleZextCommute, ghidra::RuleConcatZext, ghidra::RuleConcatCommute, ghidra::RuleSubCommute, ghidra::RuleSubExtComm, ghidra::RuleStoreVarnode, ghidra::RuleLoadVarnode, ghidra::RuleAddMultCollapse, ghidra::RuleXorCollapse, ghidra::RuleSub2Add, ghidra::RuleCarryElim, ghidra::Rule2Comp2Mult, ghidra::RulePropagateCopy, ghidra::RuleTransformCpool, ghidra::RuleCollapseConstants, ghidra::RuleShiftPiece, ghidra::RuleShift2Mult, ghidra::RuleIdentityEl, ghidra::RuleTestSign, ghidra::RuleSignShift, ghidra::RuleTrivialShift, ghidra::RuleSborrow, ghidra::RuleMultiCollapse, ghidra::RuleIndirectCollapse, ghidra::RuleLogic2Bool, ghidra::RuleBoolZext, ghidra::RuleBooleanNegate, ghidra::RuleBitUndistribute, ghidra::RuleZextSless, ghidra::RuleSlessToLess, ghidra::RuleZextEliminate, ghidra::RuleTrivialBool, ghidra::RuleTrivialArith, ghidra::RuleLessNotEqual, ghidra::RuleLessEqual, ghidra::RuleShiftCompare, ghidra::RuleLeftRight, ghidra::RuleConcatShift, ghidra::RuleDoubleArithShift, ghidra::RuleDoubleShift, ghidra::RuleDoubleSub, ghidra::RuleAndCompare, ghidra::RuleAndZext, ghidra::RuleAndPiece, ghidra::RuleAndCommute, ghidra::RuleFloatRange, ghidra::RuleRangeMeld, ghidra::RuleLessOne, ghidra::RuleAndDistribute, ghidra::RuleHighOrderAnd, ghidra::RuleNotDistribute, ghidra::RulePushMulti, ghidra::RulePullsubIndirect, ghidra::RulePullsubMulti, ghidra::RuleTermOrder, ghidra::RuleEquality, ghidra::RuleIntLessEqual, ghidra::RuleOrPredicate, ghidra::RuleRightShiftAnd, ghidra::RuleShiftBitops, ghidra::RuleNegateIdentity, ghidra::RuleAndOrLump, ghidra::RuleOrCollapse, ghidra::RuleOrConsume, ghidra::RuleAndMask, ghidra::RuleOrMask, ghidra::RuleBxor2NotEqual, ghidra::RulePiece2Sext, ghidra::RulePiece2Zext, ghidra::RuleSelectCse, ghidra::RuleCollectTerms, and ghidra::RuleEarlyRemoval.
Referenced by ghidra::ActionPool::clone().
|
virtual |
List of op codes this rule operates on.
Populate the given array with all possible OpCodes this Rule might apply to. By default, this method returns all possible OpCodes
oplist | is the array to populate |
Reimplemented in ghidra::RuleLzcountShiftBool, ghidra::RuleXorSwap, ghidra::RulePiecePathology, ghidra::RuleOrMultiBool, ghidra::RulePopcountBoolXor, ghidra::RuleThreeWayCompare, ghidra::RuleFuncPtrEncoding, ghidra::RuleIgnoreNan, ghidra::RuleFloatCast, ghidra::RuleConditionalMove, ghidra::RuleNegateNegate, ghidra::RuleSubfloatConvert, ghidra::RuleSubvarSext, ghidra::RuleSubvarZext, ghidra::RuleSubvarShift, ghidra::RuleSubvarCompZero, ghidra::RulePtrFlow, ghidra::RuleSplitFlow, ghidra::RuleSubvarSubpiece, ghidra::RuleSubvarAnd, ghidra::RuleSegment, ghidra::RuleSignMod2nOpt2, ghidra::RuleSignMod2Opt, ghidra::RuleSignMod2nOpt, ghidra::RuleModOpt, ghidra::RuleSignNearMult, ghidra::RuleSignForm2, ghidra::RuleSignForm, ghidra::RuleDivChain, ghidra::RuleSignDiv2, ghidra::RuleDivOpt, ghidra::RuleDivTermAdd2, ghidra::RuleDivTermAdd, ghidra::RulePositiveDiv, ghidra::RuleSubNormal, ghidra::RuleSplitStore, ghidra::RuleSplitLoad, ghidra::RuleSplitCopy, ghidra::RulePieceStructure, ghidra::RuleExtensionPush, ghidra::RulePtrsubCharConstant, ghidra::RuleSubRight, ghidra::Rule2Comp2Sub, ghidra::RuleAddUnsigned, ghidra::RuleMultNegOne, ghidra::RulePtrsubUndo, ghidra::RulePtraddUndo, ghidra::RulePushPtr, ghidra::RuleStructOffset0, ghidra::RulePtrArith, ghidra::RuleEqual2Constant, ghidra::RuleEqual2Zero, ghidra::RuleSLess2Zero, ghidra::RuleLessEqual2Zero, ghidra::RuleLess2Zero, ghidra::RuleBoolNegate, ghidra::RuleCondNegate, ghidra::RuleSwitchSingle, ghidra::RuleHumptyOr, ghidra::RuleDumptyHump, ghidra::RuleHumptyDumpty, ghidra::RuleShiftSub, ghidra::RuleSubCancel, ghidra::RuleSubZext, ghidra::RuleConcatLeftShift, ghidra::RuleConcatZero, ghidra::RuleShiftAnd, ghidra::RuleZextShiftZext, ghidra::RuleZextCommute, ghidra::RuleConcatZext, ghidra::RuleConcatCommute, ghidra::RuleSubCommute, ghidra::RuleSubExtComm, ghidra::RuleStoreVarnode, ghidra::RuleLoadVarnode, ghidra::RuleAddMultCollapse, ghidra::RuleXorCollapse, ghidra::RuleSub2Add, ghidra::RuleCarryElim, ghidra::Rule2Comp2Mult, ghidra::RuleTransformCpool, ghidra::RuleShiftPiece, ghidra::RuleShift2Mult, ghidra::RuleIdentityEl, ghidra::RuleTestSign, ghidra::RuleSignShift, ghidra::RuleTrivialShift, ghidra::RuleSborrow, ghidra::RuleMultiCollapse, ghidra::RuleIndirectCollapse, ghidra::RuleLogic2Bool, ghidra::RuleBoolZext, ghidra::RuleBooleanNegate, ghidra::RuleBitUndistribute, ghidra::RuleZextSless, ghidra::RuleSlessToLess, ghidra::RuleZextEliminate, ghidra::RuleTrivialBool, ghidra::RuleTrivialArith, ghidra::RuleLessNotEqual, ghidra::RuleLessEqual, ghidra::RuleShiftCompare, ghidra::RuleLeftRight, ghidra::RuleConcatShift, ghidra::RuleDoubleArithShift, ghidra::RuleDoubleShift, ghidra::RuleDoubleSub, ghidra::RuleAndCompare, ghidra::RuleAndZext, ghidra::RuleAndPiece, ghidra::RuleAndCommute, ghidra::RuleFloatRange, ghidra::RuleRangeMeld, ghidra::RuleLessOne, ghidra::RuleAndDistribute, ghidra::RuleHighOrderAnd, ghidra::RuleNotDistribute, ghidra::RulePushMulti, ghidra::RulePullsubIndirect, ghidra::RulePullsubMulti, ghidra::RuleTermOrder, ghidra::RuleEquality, ghidra::RuleIntLessEqual, ghidra::RuleOrPredicate, ghidra::RuleRightShiftAnd, ghidra::RuleShiftBitops, ghidra::RuleNegateIdentity, ghidra::RuleAndOrLump, ghidra::RuleOrCollapse, ghidra::RuleOrConsume, ghidra::RuleAndMask, ghidra::RuleOrMask, ghidra::RuleBxor2NotEqual, ghidra::RulePiece2Sext, ghidra::RulePiece2Zext, ghidra::RuleSelectCse, and ghidra::RuleCollectTerms.
References ghidra::CPUI_MAX.
Referenced by ghidra::ActionPool::addRule().
|
private |
If enabled, print a warning that this Rule has been applied.
This method is called whenever this Rule applies. If warnings have been enabled for the Rule via turnOnWarnings(), this method will print a message indicating the Rule has been applied. Even with repeat calls, the message will only be printed once (until reset() is called)
glb | is the Architecture holding the console to print to |
References ghidra::Action::flags, ghidra::Action::name, and ghidra::Architecture::printMessage().
Referenced by ghidra::ActionPool::processOp().
|
virtual |
Print statistics for this Rule.
Print the accumulated counts associated with applying this Rule to stream. This method is intended for console mode debugging. Derived Rules may override this to display their own statistics.
s | is the output stream |
References ghidra::Action::count_apply, ghidra::Action::count_tests, and ghidra::Action::name.
|
virtual |
Reset this Rule.
Any state that is specific to a particular function is cleared by this method. This method can be used to initialize a Rule based on a new function it will apply to
data | is the new function about to be transformed |
Reimplemented in ghidra::RuleSubvarSext.
References ghidra::Action::flags.
|
virtual |
Reset Rule statistics.
Counts of when this Rule has been attempted/applied are reset to zero. Derived Rules may reset their own statistics.
References ghidra::Action::count_apply, ghidra::Action::count_tests, ghidra::Action::flags, ghidra::Action::name, and ghidra::Action::rule_debug.