Ghidra 11.3.2
Ghidra internal decompiler documentation.
|
Database of root Action objects that can be used to transform a function. More...
#include <action.hh>
Public Member Functions | |
ActionDatabase (void) | |
Constructor. | |
~ActionDatabase (void) | |
Destructor. | |
void | resetDefaults (void) |
(Re)set the default configuration | |
Action * | getCurrent (void) const |
Get the current root Action. | |
const string & | getCurrentName (void) const |
Get the name of the current root Action. | |
const ActionGroupList & | getGroup (const string &grp) const |
Get a specific grouplist by name. | |
Action * | setCurrent (const string &actname) |
Set the current root Action. | |
Action * | toggleAction (const string &grp, const string &basegrp, bool val) |
Toggle a group of Actions with a root Action. | |
void | setGroup (const string &grp, const char **argv) |
Establish a new root Action. | |
void | cloneGroup (const string &oldname, const string &newname) |
Clone a root Action. | |
bool | addToGroup (const string &grp, const string &basegroup) |
Add a group to a root Action. | |
bool | removeFromGroup (const string &grp, const string &basegroup) |
Remove a group from a root Action. | |
void | universalAction (Architecture *glb) |
Build the universal action. | |
Private Member Functions | |
void | registerAction (const string &nm, Action *act) |
Register a root Action. | |
void | buildDefaultGroups (void) |
Set up descriptions of preconfigured root Actions. | |
Action * | getAction (const string &nm) const |
Look up a root Action by name. | |
Action * | deriveAction (const string &baseaction, const string &grp) |
Derive a root Action. | |
Private Attributes | |
Action * | currentact |
This is the current root Action. | |
string | currentactname |
The name associated with the current root Action. | |
map< string, ActionGroupList > | groupmap |
Map from root Action name to the grouplist it uses. | |
map< string, Action * > | actionmap |
Map from name to root Action. | |
bool | isDefaultGroups |
true if only the default groups are set | |
Static Private Attributes | |
static const char | universalname [] = "universal" |
The name of the universal root Action. | |
Database of root Action objects that can be used to transform a function.
This is a container for Action objects. It also manages root Action objects, which encapsulate a complete transformation system that can be applied to functions. Root Action objects are derived from a single universal Action object that has every possible sub-action within it. A root Action has its own name and is derived from the universal via a grouplist, which lists a particular subset of Action and Rule groups to use for the root. A new root Action is created by providing a new grouplist via setGroup() or modifying an existing grouplist. This class is intended to be instantiated as a singleton and keeps track of the current root Action, which is the one that will be actively applied to functions.
bool ghidra::ActionDatabase::addToGroup | ( | const string & | grp, |
const string & | basegroup | ||
) |
Add a group to a root Action.
Add a group to the grouplist for a particular root Action. Do not use to redefine a root Action that has already been instantiated.
grp | is the name of the root Action |
basegroup | is the group to add |
References groupmap, isDefaultGroups, and ghidra::ActionGroupList::list.
Referenced by toggleAction().
|
private |
Set up descriptions of preconfigured root Actions.
(Re)build the default root Actions: decompile, jumptable, normalize, paramid, register, firstpass
Referenced by resetDefaults().
void ghidra::ActionDatabase::cloneGroup | ( | const string & | oldname, |
const string & | newname | ||
) |
Clone a root Action.
Copy an existing root Action by copying its grouplist, giving it a new name. This is suitable for a copy then modify strategy to create a new root Action. Do not use to redefine a root Action that has already been instantiated
oldname | is the name of an existing root Action |
newname | is the name of the copy |
References getGroup(), groupmap, and isDefaultGroups.
Referenced by ghidra::OptionSetAction::apply().
|
private |
Derive a root Action.
Internal method to build the Action object corresponding to a root Action The new Action object is created by selectively cloning components from an existing object based on a grouplist.
baseaction | is the name of the model Action object to derive from |
grp | is the name of the grouplist steering the clone |
References actionmap, ghidra::Action::clone(), getAction(), getGroup(), and registerAction().
Referenced by setCurrent().
|
private |
Look up a root Action by name.
nm | is the name of the root Action |
References actionmap.
Referenced by deriveAction(), and toggleAction().
|
private |
Register a root Action.
Internal method for associated a root Action name with its Action object. The database takes over memory management of the object.
nm | is the name to register as |
act | is the Action object |
References actionmap.
Referenced by deriveAction(), resetDefaults(), and toggleAction().
bool ghidra::ActionDatabase::removeFromGroup | ( | const string & | grp, |
const string & | basegrp | ||
) |
Remove a group from a root Action.
The group is removed from the grouplist of a root Action. Do not use to redefine a root Action that has already been instantiated.
grp | is the name of the root Action |
basegrp | is the group to remove |
References groupmap, isDefaultGroups, and ghidra::ActionGroupList::list.
Referenced by toggleAction().
void ghidra::ActionDatabase::resetDefaults | ( | void | ) |
(Re)set the default configuration
Clear out (possibly altered) root Actions. Reset the default groups. Set the default root action "decompile"
References actionmap, buildDefaultGroups(), registerAction(), setCurrent(), universalAction(), and universalname.
Referenced by ghidra::Architecture::buildAction(), and ghidra::Architecture::resetDefaults().
Action * ghidra::ActionDatabase::setCurrent | ( | const string & | actname | ) |
Set the current root Action.
The Action is specified by name. A grouplist must already exist for this name. If the Action doesn't already exist, it will be derived from the universal action via this grouplist.
actname | is the name of the root Action |
References currentact, currentactname, deriveAction(), and universalname.
Referenced by ghidra::OptionSetAction::apply(), ghidra::OptionCurrentAction::apply(), ghidra::SetAction::rawAction(), ghidra::SignaturesAt::rawAction(), resetDefaults(), and ghidra::Funcdata::stageJumpTable().
void ghidra::ActionDatabase::setGroup | ( | const string & | grp, |
const char ** | argv | ||
) |
Establish a new root Action.
(Re)set the grouplist for a particular root Action. Do not use this routine to redefine an existing root Action.
grp | is the name of the root Action |
argv | is a list of static char pointers, which must end with a NULL pointer, or a zero length string. |
References groupmap, isDefaultGroups, and ghidra::ActionGroupList::list.
Action * ghidra::ActionDatabase::toggleAction | ( | const string & | grp, |
const string & | basegrp, | ||
bool | val | ||
) |
Toggle a group of Actions with a root Action.
A particular group is either added or removed from the grouplist defining a particular root Action. The root Action is then (re)derived from the universal
grp | is the name of the root Action |
basegrp | is name of group (within the grouplist) to toggle |
val | is true if the group should be added or false if it should be removed |
References addToGroup(), ghidra::Action::clone(), currentact, currentactname, getAction(), getGroup(), registerAction(), removeFromGroup(), and universalname.
Referenced by ghidra::OptionCurrentAction::apply(), and ghidra::OptionSplitDatatypes::apply().
void ghidra::ActionDatabase::universalAction | ( | Architecture * | conf | ) |
Build the universal action.
Construct the universal Action that contains all possible components
conf | is the Architecture that will use the Action |
References ghidra::ActionGroup::addAction(), ghidra::ActionPool::addRule(), ghidra::Architecture::extra_pool_rules, ghidra::AddrSpaceManager::getStackSpace(), ghidra::Action::rule_onceperfunc, and ghidra::Action::rule_repeatapply.
Referenced by ghidra::Architecture::buildAction(), and resetDefaults().