Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
18 #ifndef __CPUI_ACTION__
19 #define __CPUI_ACTION__
37 bool contains(
const string &nm)
const {
return (list.find(nm)!=list.end()); }
93 Action(uint4 f,
const string &nm,
const string &g);
96 virtual bool turnOnDebug(
const string &nm);
97 virtual bool turnOffDebug(
const string &nm);
103 bool setWarning(
bool val,
const string &specify);
106 const string &getName(
void)
const {
return name; }
107 const string &getGroup(
void)
const {
return basegroup; }
108 uint4 getStatus(
void)
const {
return status; }
129 virtual int4
print(ostream &s,int4 num,int4 depth)
const;
131 virtual void saveXml(ostream &s)
const {}
156 virtual int4
print(ostream &s,int4 num,int4 depth)
const;
160 #ifdef OPACTION_DEBUG
161 virtual bool turnOnDebug(
const string &nm);
162 virtual bool turnOffDebug(
const string &nm);
213 Rule(
const string &g,uint4 fl,
const string &nm);
214 virtual ~
Rule(
void) {}
215 const string &getName(
void)
const {
return name; }
216 const string &getGroup(
void)
const {
return basegroup; }
220 void clearBreak(uint4 tp) {
breakpoint &= ~tp; }
228 uint4 getBreakPoint(
void)
const {
return breakpoint; }
237 virtual void getOpList(vector<uint4> &oplist)
const;
250 #ifdef OPACTION_DEBUG
251 virtual bool turnOnDebug(
const string &nm);
252 virtual bool turnOffDebug(
const string &nm);
263 vector<Rule *> allrules;
265 PcodeOpTree::const_iterator op_state;
277 virtual int4
print(ostream &s,int4 num,int4 depth)
const;
281 #ifdef OPACTION_DEBUG
282 virtual bool turnOnDebug(
const string &nm);
283 virtual bool turnOffDebug(
const string &nm);
300 string currentactname;
301 map<string,ActionGroupList> groupmap;
302 map<string,Action *> actionmap;
303 bool isDefaultGroups;
304 static const char universalname[];
305 void registerAction(
const string &nm,
Action *act);
306 void buildDefaultGroups(
void);
307 Action *getAction(
const string &nm)
const;
308 Action *deriveAction(
const string &baseaction,
const string &grp);
313 Action *getCurrent(
void)
const {
return currentact; }
314 const string &getCurrentName(
void)
const {
return currentactname; }
319 void setGroup(
const string &grp,
const char **argv);
320 void cloneGroup(
const string &oldname,
const string &newname);
321 bool addToGroup(
const string &grp,
const string &basegroup);
virtual int4 applyOp(PcodeOp *op, Funcdata &data)
Attempt to apply this Rule.
Definition: action.hh:246
@ rule_oneactperfunc
Makes a change only once per function.
Definition: action.hh:56
Action(uint4 f, const string &nm, const string &g)
Base constructor for an Action.
Definition: action.cc:25
int4 lcount
Changes not including last call to apply()
Definition: action.hh:78
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: action.cc:504
uint4 count_apply
Number of times apply() made changes.
Definition: action.hh:84
virtual void printStatistics(ostream &s) const
Dump statistics to stream.
Definition: action.cc:91
~ActionDatabase(void)
Destructor.
Definition: action.cc:974
@ break_action
Break if a change has been made.
Definition: action.hh:74
Action which checks if restart (sub)actions have been generated and restarts itself.
Definition: action.hh:173
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: action.cc:875
@ status_end
getFuncdata has completed once (for onceperfunc)
Definition: action.hh:67
@ rule_debug
Print debug messages specifically for this action.
Definition: action.hh:57
void resetDefaults(void)
(Re)set the default configuration
Definition: action.cc:984
virtual void clearBreakPoints(void)
Clear all breakpoints set on this Action.
Definition: action.cc:185
Classes related to basic blocks and control-flow structuring.
virtual void clearBreakPoints(void)
Clear all breakpoints set on this Action.
Definition: action.cc:888
Class for performing a single transformation on a PcodeOp or Varnode.
Definition: action.hh:194
void addRule(Rule *rl)
Add a Rule to the pool.
Definition: action.cc:738
int4 perform(Funcdata &data)
Perform this action (if necessary)
Definition: action.cc:296
A pool of Rules that apply simultaneously.
Definition: action.hh:262
@ rule_warnings_given
A warning has been issued for this action.
Definition: action.hh:59
vector< Action * >::iterator state
Current action being applied.
Definition: action.hh:146
ruleflags
Boolean behavior properties governing this particular Action.
Definition: action.hh:53
virtual Rule * getSubRule(const string &specify)
Retrieve a specific sub-rule by name.
Definition: action.cc:787
void setGroup(const string &grp, const char **argv)
Establish a new root Action.
Definition: action.cc:1057
@ break_start
Break at beginning of action.
Definition: action.hh:72
uint4 breakpoint
Breakpoint properties.
Definition: action.hh:81
virtual void printStatistics(ostream &s) const
Dump statistics to stream.
Definition: action.cc:962
@ status_mid
In middle of action (use subclass status)
Definition: action.hh:66
Action * setCurrent(const string &actname)
Set the current root Action.
Definition: action.cc:1019
Action * toggleAction(const string &grp, const string &basegrp, bool val)
Toggle a group of Actions with a root Action.
Definition: action.cc:1034
The list of groups defining a root Action.
Definition: action.hh:29
@ rule_repeatapply
Apply rule repeatedly until no change.
Definition: action.hh:54
virtual Rule * clone(const ActionGroupList &grouplist) const =0
Clone the Rule.
virtual Rule * getSubRule(const string &specify)
Retrieve a specific sub-rule by name.
Definition: action.cc:479
A group of actions (generally) applied in sequence.
Definition: action.hh:143
virtual ~ActionPool(void)
Destructor.
Definition: action.cc:726
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: action.cc:98
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: action.cc:406
statusflags
Boolean properties describing the status of an action.
Definition: action.hh:62
virtual Action * getSubAction(const string &specify)
Retrieve a specific sub-action by name.
Definition: action.cc:273
Large scale transformations applied to the varnode/op graph.
Definition: action.hh:50
uint4 flags
Behavior properties.
Definition: action.hh:82
Database of root Action objects that can be used to transform a function.
Definition: action.hh:298
An XML element. A node in the DOM tree.
Definition: xml.hh:150
const ActionGroupList & getGroup(const string &grp) const
Get a specific grouplist by name.
Definition: action.cc:1004
breakflags
Break points associated with an Action.
Definition: action.hh:71
@ status_actionbreak
Completed full action last time but indicated action break.
Definition: action.hh:68
Lowest level operation of the p-code language.
Definition: op.hh:58
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
vector< Action * > list
List of actions to perform in the group.
Definition: action.hh:145
virtual void reset(Funcdata &data)
Reset this Rule.
Definition: action.cc:648
@ warnings_on
A warning is issued if this rule is applied.
Definition: action.hh:200
uint4 count_tests
Number of times apply() has been called.
Definition: action.hh:83
int4 count
Number of changes made by this action so far.
Definition: action.hh:79
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: action.cc:551
bool setBreakPoint(uint4 tp, const string &specify)
Set a breakpoint on this action.
Definition: action.cc:169
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: action.cc:914
bool removeFromGroup(const string &grp, const string &basegroup)
Remove a group from a root Action.
Definition: action.cc:1101
virtual void resetStats(void)
Reset all the counts to zero.
Definition: action.cc:924
virtual int4 print(ostream &s, int4 num, int4 depth) const
Print a description of this Action to stream.
Definition: action.cc:751
@ CPUI_MAX
Value indicating the end of the op-code values.
Definition: opcodes.hh:127
@ status_repeat
Repeating the same action.
Definition: action.hh:65
virtual Rule * getSubRule(const string &specify)
Retrieve a specific sub-rule by name.
Definition: action.cc:283
virtual void resetStats(void)
Reset all the counts to zero.
Definition: action.cc:106
virtual int4 apply(Funcdata &data)=0
Make a single attempt to apply this Action.
uint4 status
Current status.
Definition: action.hh:80
@ tmpbreak_start
Temporary break at start of action.
Definition: action.hh:73
string basegroup
Base group this action belongs to.
Definition: action.hh:86
bool checkActionBreak(void)
Check if an action breakpoint is turned on.
Definition: action.cc:716
bool disableRule(const string &specify)
Disable a specific Rule within this.
Definition: action.cc:224
bool addToGroup(const string &grp, const string &basegroup)
Add a group to a root Action.
Definition: action.cc:1088
bool contains(const string &nm) const
Check if this ActionGroupList contains a given group.
Definition: action.hh:37
@ type_disable
Is this rule disabled.
Definition: action.hh:198
@ warnings_given
Set if a warning for this rule has been given before.
Definition: action.hh:201
Container for data structures associated with a single function.
Definition: funcdata.hh:45
@ status_start
At start of action.
Definition: action.hh:63
string name
Name of the action.
Definition: action.hh:85
virtual void getOpList(vector< uint4 > &oplist) const
List of op codes this rule operates on.
Definition: action.cc:704
bool checkStartBreak(void)
Check start breakpoint.
Definition: action.cc:50
virtual void clearBreakPoints(void)
Clear all breakpoints set on this Action.
Definition: action.cc:380
void cloneGroup(const string &oldname, const string &newname)
Clone a root Action.
Definition: action.cc:1075
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: action.cc:527
virtual void printState(ostream &s) const
Print status to stream.
Definition: action.cc:442
virtual int4 print(ostream &s, int4 num, int4 depth) const
Print a description of this Action to stream.
Definition: action.cc:426
virtual int4 print(ostream &s, int4 num, int4 depth) const
Print a description of this Action to stream.
Definition: action.cc:130
bool checkActionBreak(void)
Check action breakpoint.
Definition: action.cc:115
virtual void printStatistics(ostream &s) const
Print statistics for this Rule.
Definition: action.cc:695
@ status_breakstarthit
At start after breakpoint.
Definition: action.hh:64
void issueWarning(Architecture *glb)
Warn that this Action has applied.
Definition: action.cc:39
virtual void printState(ostream &s) const
Print status to stream.
Definition: action.cc:775
bool enableRule(const string &specify)
Enable a specific Rule within this.
Definition: action.cc:240
virtual Action * getSubAction(const string &specify)
Retrieve a specific sub-action by name.
Definition: action.cc:454
virtual void resetStats(void)
Reset all the counts to zero.
Definition: action.cc:416
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: action.cc:544
Rule(const string &g, uint4 fl, const string &nm)
Construct given group, properties name.
Definition: action.cc:620
virtual void printStatistics(ostream &s) const
Dump statistics to stream.
Definition: action.cc:608
@ rule_debug
Print debug info specific for this rule.
Definition: action.hh:199
@ rule_onceperfunc
Apply rule once per function.
Definition: action.hh:55
void universalAction(Architecture *glb)
Build the universal action.
Definition: coreaction.cc:4878
virtual Action * clone(const ActionGroupList &grouplist) const =0
Clone the Action.
virtual void printState(ostream &s) const
Print status to stream.
Definition: action.cc:146
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: action.cc:389
virtual ~ActionGroup(void)
Destructor.
Definition: action.cc:362
void addAction(Action *ac)
Add an Action to the group.
Definition: action.cc:374
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: action.cc:897
@ rule_warnings_on
If this action makes a change, issue a warning.
Definition: action.hh:58
typeflags
Properties associated with a Rule.
Definition: action.hh:197
bool setWarning(bool val, const string &specify)
Set a warning on this action.
Definition: action.cc:197
virtual void resetStats(void)
Reset Rule statistics.
Definition: action.cc:656