decompiler  1.0.0
Classes | Public Member Functions | Static Private Member Functions | List of all members
ActionNameVars Class Reference

Choose names for all high-level variables (HighVariables) More...

#include <coreaction.hh>

Inheritance diagram for ActionNameVars:


struct  OpRecommend
 This class is a record in a database used to store and lookup potential names. More...

Public Member Functions

 ActionNameVars (const string &g)
virtual Actionclone (const ActionGroupList &grouplist) const
 Clone the Action. More...
virtual int4 apply (Funcdata &data)
 Make a single attempt to apply this Action. More...
- Public Member Functions inherited from Action
 Action (uint4 f, const string &nm, const string &g)
 Base constructor for an Action. More...
virtual ~Action (void)
virtual void printStatistics (ostream &s) const
 Dump statistics to stream. More...
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 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 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 void saveXml (ostream &s) const
 Save specifics of this action to stream.
virtual void restoreXml (const Element *el, Funcdata *fd)
 Load specifics of action from XML.
virtual ActiongetSubAction (const string &specify)
 Retrieve a specific sub-action by name. More...
virtual RulegetSubRule (const string &specify)
 Retrieve a specific sub-rule by name. More...

Static Private Member Functions

static void makeRec (ProtoParameter *param, Varnode *vn, map< HighVariable *, OpRecommend > &recmap)
 Add a recommendation to the database based on a particular sub-function parameter. More...
static void lookForBadJumpTables (Funcdata &data)
 Mark the switch variable for bad jump-tables. More...
static void lookForRecommendedNames (Funcdata &data)
 Try to apply names from unlocked symbols. More...
static void lookForFuncParamNames (Funcdata &data, const vector< Varnode * > &varlist)
 Collect potential variable names from sub-function parameters. More...

Additional Inherited Members

- Public Types inherited from 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 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 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

Choose names for all high-level variables (HighVariables)

Member Function Documentation

◆ apply()

int4 ActionNameVars::apply ( Funcdata data)

◆ clone()

virtual Action* ActionNameVars::clone ( const ActionGroupList grouplist) const

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.

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

Implements Action.

References ActionNameVars(), ActionGroupList::contains(), and Action::getGroup().

◆ lookForBadJumpTables()

void ActionNameVars::lookForBadJumpTables ( Funcdata data)

Mark the switch variable for bad jump-tables.

Name the Varnode which seems to be the putative switch variable for an unrecovered jump-table with a special name.

datais the function being analyzed

References PcodeOp::code(), CPUI_CAST, Funcdata::getCallSpecs(), Varnode::getDef(), Varnode::getHigh(), PcodeOp::getIn(), FuncCallSpecs::getOp(), Symbol::getScope(), Funcdata::getScopeLocal(), HighVariable::getSymbol(), FuncCallSpecs::isBadJumpTable(), Varnode::isFree(), Varnode::isImplied(), Symbol::isNameLocked(), Varnode::isWritten(), ScopeInternal::makeNameUnique(), Funcdata::numCalls(), and Scope::renameSymbol().

Referenced by apply().

◆ lookForFuncParamNames()

void ActionNameVars::lookForFuncParamNames ( Funcdata data,
const vector< Varnode * > &  varlist 

Collect potential variable names from sub-function parameters.

Run through all sub-functions with a known prototype and collect potential names for current Varnodes used to pass the parameters. For these Varnodes, select from among these names.

datais the function being analyzed
varlistis a list of Varnodes representing HighVariables that need names

References HighVariable::clearMark(), Funcdata::getCallSpecs(), Varnode::getHigh(), PcodeOp::getIn(), FuncCallSpecs::getOp(), FuncProto::getParam(), Symbol::getScope(), Funcdata::getScopeLocal(), HighVariable::getSymbol(), Varnode::isFree(), FuncProto::isInputLocked(), HighVariable::isMark(), Symbol::isNameUndefined(), ScopeInternal::makeNameUnique(), makeRec(), Funcdata::numCalls(), PcodeOp::numInput(), FuncProto::numParams(), Scope::renameSymbol(), and HighVariable::setMark().

Referenced by apply().

◆ lookForRecommendedNames()

void ActionNameVars::lookForRecommendedNames ( Funcdata data)

Try to apply names from unlocked symbols.

From among the name recommendations (symbol information that wasn't locked) find current symbols for which the name can still apply and apply it.

datais the function being analyzed

References Symbol::getScope(), Funcdata::getScopeLocal(), ScopeInternal::makeNameUnique(), and Scope::renameSymbol().

Referenced by apply().

◆ makeRec()

void ActionNameVars::makeRec ( ProtoParameter param,
Varnode vn,
map< HighVariable *, OpRecommend > &  recmap 

Add a recommendation to the database based on a particular sub-function parameter.

We know vn holds data-flow for parameter param, try to attach its name to vn's symbol. We update map from vn to a name recommendation record. If vn is input to multiple functions, the one whose parameter has the most specified type will be preferred. If vn is passed to the function via a cast, this name will only be used if there is no other function that takes vn as a parameter.

paramis function prototype symbol
vnis the Varnode associated with the parameter
recmapis the recommendation map

References PcodeOp::code(), CPUI_CAST, ActionNameVars::OpRecommend::ct, Varnode::getDef(), Varnode::getHigh(), PcodeOp::getIn(), ProtoParameter::getName(), Varnode::getSize(), ProtoParameter::getSize(), ProtoParameter::getType(), Varnode::isImplied(), HighVariable::isMark(), ProtoParameter::isNameLocked(), ProtoParameter::isNameUndefined(), Varnode::isWritten(), ActionNameVars::OpRecommend::namerec, and Datatype::typeOrder().

Referenced by lookForFuncParamNames().

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