decompiler
1.0.0
|
Fill-in CPUI_CAST p-code ops as required by the casting strategy. More...
#include <coreaction.hh>
Public Member Functions | |
ActionSetCasts (const string &g) | |
Constructor. | |
virtual Action * | clone (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) |
Destructor. | |
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 Action * | getSubAction (const string &specify) |
Retrieve a specific sub-action by name. More... | |
virtual Rule * | getSubRule (const string &specify) |
Retrieve a specific sub-rule by name. More... | |
Static Private Member Functions | |
static int4 | castOutput (PcodeOp *op, Funcdata &data, CastStrategy *castStrategy) |
Insert cast to output Varnode type after given PcodeOp if it is necessary. More... | |
static int4 | castInput (PcodeOp *op, int4 slot, Funcdata &data, CastStrategy *castStrategy) |
Insert cast to produce the input Varnode to a given PcodeOp if necessary. 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. | |
Fill-in CPUI_CAST p-code ops as required by the casting strategy.
Setting the casts is complicated by type inference and implied variables. By the time this Action is run, the type inference algorithm has labeled every Varnode with what it thinks the type should be. This casting algorithm tries to get the code to legally match this inference result by adding casts. Following the data flow, it tries the best it can to get each token to match the inferred type. For implied variables, the type is completely determined by the syntax of the output language, so implied casts won't work in this case. For most of these cases, the algorithm just changes the type to that dictated by syntax and gets back on track at the next explicit variable in the flow. It tries to avoid losing pointer types however because any CPUI_PTRADD mst have a pointer input. In this case, it casts to the necessary pointer type immediately.
|
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.
data | is the function to inspect/modify |
Implements Action.
References BlockBasic::beginOp(), castInput(), castOutput(), PcodeOp::code(), Action::count, CPUI_CAST, CPUI_LOAD, CPUI_STORE, BlockBasic::endOp(), PcodeOp::getAddr(), Funcdata::getArch(), Funcdata::getBasicBlocks(), PrintLanguage::getCastStrategy(), Varnode::getHigh(), PcodeOp::getIn(), Datatype::getMetatype(), PcodeOp::getOut(), TypePointer::getPtrTo(), Datatype::getSize(), Varnode::getSize(), HighVariable::getType(), PcodeOp::notPrinted(), PcodeOp::numInput(), Architecture::print, Funcdata::startCastPhase(), TYPE_PTR, and Funcdata::warning().
|
staticprivate |
Insert cast to produce the input Varnode to a given PcodeOp if necessary.
This method can also mark a Varnode as an explicit integer constant. Guard against chains of casts.
op | is the given PcodeOp |
slot | is the slot of the input Varnode |
data | is the function being analyzed |
castStrategy | is used to determine if a cast is necessary |
References PcodeOp::code(), CPUI_CAST, PcodeOp::getAddr(), Funcdata::getArch(), Varnode::getDef(), PcodeOp::getIn(), TypeOp::getInputCast(), PcodeOp::getOpcode(), Varnode::getSize(), Varnode::getType(), Varnode::isConstant(), Varnode::isImplied(), Varnode::isWritten(), Varnode::loneDescend(), PcodeOp::markExplicitUnsigned(), Funcdata::newOp(), Funcdata::newUniqueOut(), Funcdata::opInsertBefore(), Funcdata::opSetInput(), Funcdata::opSetOpcode(), Varnode::setImplied(), and Varnode::updateType().
Referenced by apply().
|
staticprivate |
Insert cast to output Varnode type after given PcodeOp if it is necessary.
op | is the given PcodeOp |
data | is the function being analyzed |
castStrategy | is used to determine if the cast is necessary |
References CastStrategy::castStandard(), CPUI_CAST, PcodeOp::getAddr(), Funcdata::getArch(), Varnode::getHigh(), Datatype::getMetatype(), PcodeOp::getOpcode(), PcodeOp::getOut(), TypeOp::getOutputToken(), Varnode::getSize(), HighVariable::getType(), Varnode::getType(), Varnode::isImplied(), Funcdata::newOp(), Funcdata::newUnique(), Funcdata::opInsertAfter(), Funcdata::opSetInput(), Funcdata::opSetOpcode(), Funcdata::opSetOutput(), Varnode::setImplied(), TYPE_ARRAY, TYPE_PTR, TYPE_STRUCT, and Varnode::updateType().
Referenced by apply().
|
inlinevirtual |
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.
grouplist | is the list of groups being cloned |
Implements Action.
References ActionSetCasts(), ActionGroupList::contains(), and Action::getGroup().