Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
16 #ifndef __CPUI_FUNCDATA__
17 #define __CPUI_FUNCDATA__
49 blocks_unreachable = 4,
50 processing_started = 8,
51 processing_complete = 0x10,
52 typerecovery_on = 0x20,
54 jumptablerecovery_on = 0x80,
55 jumptablerecovery_dont = 0x100,
56 restart_pending = 0x200,
57 unimplemented_present = 0x400,
58 baddata_present = 0x800,
59 double_precis_on = 0x1000
63 uint4 high_level_index;
64 uint4 cast_phase_index;
74 vector<FuncCallSpecs *> qlst;
75 vector<JumpTable *> jumpvec;
85 map<VarnodeData,const LanedRegister *> lanedMap;
88 void setVarnodeProperties(
Varnode *vn)
const;
91 bool syncVarnodesWithSymbol(VarnodeLocSet::const_iterator &iter,uint4 flags,
Datatype *ct);
92 bool descend2Undef(
Varnode *vn);
96 void destroyVarnode(
Varnode *vn);
97 void coverVarnodes(
SymbolEntry *entry,vector<Varnode *> &list);
101 void blockRemoveInternal(
BlockBasic *bb,
bool unreachable);
102 void branchRemoveInternal(
BlockBasic *bb,int4 num);
104 void clearBlocks(
void);
105 void structureReset(
void);
107 void switchOverJumpTables(
const FlowInfo &flow);
108 void clearJumpTables(
void);
110 void sortCallSpecs(
void);
111 void deleteCallSpecs(
PcodeOp *op);
112 void clearCallSpecs(
void);
119 static bool descendantsOutside(
Varnode *vn);
120 static void saveVarnodeXml(ostream &s,VarnodeLocSet::const_iterator iter,VarnodeLocSet::const_iterator enditer);
121 static bool checkIndirectUse(
Varnode *vn);
122 static PcodeOp *findPrimaryBranch(PcodeOpTree::const_iterator iter,PcodeOpTree::const_iterator enditer,
123 bool findbranch,
bool findcall,
bool findreturn);
127 const string &getName(
void)
const {
return name; }
128 const Address &getAddress(
void)
const {
return baseaddr; }
129 int4 getSize(
void)
const {
return size; }
132 bool isHighOn(
void)
const {
return ((flags&highlevel_on)!=0); }
133 bool isProcStarted(
void)
const {
return ((flags&processing_started)!=0); }
134 bool isProcComplete(
void)
const {
return ((flags&processing_complete)!=0); }
135 bool hasUnreachableBlocks(
void)
const {
return ((flags&blocks_unreachable)!=0); }
136 bool isTypeRecoveryOn(
void)
const {
return ((flags&typerecovery_on)!=0); }
137 bool hasNoCode(
void)
const {
return ((flags & no_code)!=0); }
138 void setNoCode(
bool val) {
if (val) flags |= no_code;
else flags &= ~no_code; }
139 void setLanedRegGenerated(
void) { minLanedSize = 1000000; }
144 void setJumptableRecovery(
bool val) {
if (val) flags &= ~jumptablerecovery_dont;
else flags |= jumptablerecovery_dont; }
146 bool isJumptableRecoveryOn(
void)
const {
return ((flags & jumptablerecovery_on)!=0); }
153 bool isDoublePrecisOn(
void)
const {
return ((flags & double_precis_on)!=0); }
154 bool hasNoStructBlocks(
void)
const {
return (sblocks.getSize() == 0); }
161 void startCastPhase(
void) { cast_phase_index = vbank.getCreateIndex(); }
162 uint4 getCastPhaseIndex(
void)
const {
return cast_phase_index; }
163 uint4 getHighLevelIndex(
void)
const {
return high_level_index; }
164 void startCleanUp(
void) { clean_up_index = vbank.getCreateIndex(); }
165 uint4 getCleanUpIndex(
void)
const {
return clean_up_index; }
177 void saveXml(ostream &s,uint8
id,
bool savetree)
const;
184 Override &getOverride(
void) {
return localoverride; }
189 void setRestartPending(
bool val) { flags = val ? (flags|restart_pending) : (flags & ~((uint4)restart_pending)); }
201 bool hasBadData(
void)
const {
return ((flags&baddata_present)!=0); }
207 int4 getHeritagePass(
void)
const {
return heritage.getPass(); }
244 const list<LoadGuard> &getLoadGuards(
void)
const {
return heritage.getLoadGuards(); }
245 const list<LoadGuard> &getStoreGuards(
void)
const {
return heritage.getStoreGuards(); }
249 int4 numCalls(
void)
const {
return qlst.size(); }
255 int4 numVarnodes(
void)
const {
return vbank.numVarnodes(); }
301 return vbank.
find(s,loc,pc,uniq); }
307 VarnodeLocSet::const_iterator
endLoc(
void)
const {
return vbank.
endLoc(); }
331 VarnodeLocSet::const_iterator
endLoc(int4 s,
const Address &addr,uint4 fl)
const {
return vbank.
endLoc(s,addr,fl); }
335 return vbank.
beginLoc(s,addr,pc,uniq); }
338 VarnodeLocSet::const_iterator
endLoc(int4 s,
const Address &addr,
const Address &pc,uintm uniq=~((uintm)0))
const {
339 return vbank.
endLoc(s,addr,pc,uniq); }
345 VarnodeDefSet::const_iterator
endDef(
void)
const {
return vbank.
endDef(); }
351 VarnodeDefSet::const_iterator
endDef(uint4 fl)
const {
return vbank.
endDef(fl); }
357 VarnodeDefSet::const_iterator
endDef(uint4 fl,
const Address &addr)
const {
return vbank.
endDef(fl,addr); }
360 map<VarnodeData,const LanedRegister *>::const_iterator beginLaneAccess(
void)
const {
return lanedMap.begin(); }
361 map<VarnodeData,const LanedRegister *>::const_iterator endLaneAccess(
void)
const {
return lanedMap.end(); }
362 void clearLanedAccessMap(
void) { lanedMap.clear(); }
376 ScopeLocal *getScopeLocal(
void) {
return localmap; }
377 const ScopeLocal *getScopeLocal(
void)
const {
return localmap; }
378 FuncProto &getFuncProto(
void) {
return funcp; }
379 const FuncProto &getFuncProto(
void)
const {
return funcp; }
383 if (activeoutput != (
ParamActive *)0)
delete activeoutput;
386 ParamActive *getActiveOutput(
void)
const {
return activeoutput; }
401 Merge &getMerge(
void) {
return covermerge; }
421 void opHeritage(
void) { heritage.
heritage(); }
458 list<PcodeOp *>::const_iterator
endOp(
OpCode opc)
const {
return obank.
end(opc); }
482 PcodeOpTree::const_iterator
endOp(
const Address &addr)
const {
return obank.
end(addr); }
491 int4 numJumpTables(
void)
const {
return jumpvec.size(); }
492 JumpTable *getJumpTable(int4 i) {
return jumpvec[i]; }
496 BlockGraph &getStructure(
void) {
return sblocks; }
497 const BlockGraph &getStructure(
void)
const {
return sblocks; }
498 const BlockGraph &getBasicBlocks(
void)
const {
return bblocks; }
512 bool fora_block1ishigh,
bool forb_block1ishigh,
const Address &addr);
524 #ifdef OPACTION_DEBUG
526 vector<PcodeOp *> modify_list;
527 vector<string> modify_before;
529 int4 opactdbg_breakcount;
531 bool opactdbg_active;
532 bool opactdbg_breakon;
533 vector<Address> opactdbg_pclow;
534 vector<Address> opactdbg_pchigh;
535 vector<uintm> opactdbg_uqlow;
536 vector<uintm> opactdbg_uqhigh;
537 void enableJTCallback(
void (*jtcb)(
Funcdata &orig,
Funcdata &fd)) { jtcallback = jtcb; }
538 void disableJTCallback(
void) { jtcallback = (void (*)(
Funcdata &orig,
Funcdata &fd))0; }
539 void debugActivate(
void) {
if (opactdbg_on) opactdbg_active=
true; }
540 void debugDeactivate(
void) { opactdbg_active =
false; }
541 void debugModCheck(
PcodeOp *op);
542 void debugModClear(
void);
543 void debugModPrint(
const string &actionname);
544 bool debugBreak(
void)
const {
return opactdbg_on&&opactdbg_breakon; }
545 int4 debugSize(
void)
const {
return opactdbg_pclow.size(); }
546 void debugEnable(
void) { opactdbg_on =
true; opactdbg_count = 0; }
547 void debugDisable(
void) { opactdbg_on =
false; }
548 void debugClear(
void) {
549 opactdbg_pclow.clear(); opactdbg_pchigh.clear(); opactdbg_uqlow.clear(); opactdbg_uqhigh.clear(); }
550 bool debugCheckRange(
PcodeOp *op);
552 uintm uqlow=~((uintm)0),uintm uqhigh=~((uintm)0));
553 void debugHandleBreak(
void) { opactdbg_breakon =
false; }
554 void debugSetBreak(int4 count) { opactdbg_breakcount = count; }
555 void debugPrintRange(int4 i)
const;
567 void setFuncdata(
Funcdata *f) { fd = f; }
597 vn = op->getIn(slot);
600 int4 getSolidSlot(
void)
const {
return ((flags & seen_solid0)!=0) ? 0 : 1; }
601 void markSolid(int4 slot) { flags |= (slot==0) ? seen_solid0 : seen_solid1; }
602 void markKill(
void) { flags |= seen_kill; }
603 bool seenSolid(
void)
const {
return ((flags & (seen_solid0|seen_solid1))!=0); }
604 bool seenKill(
void)
const {
return ((flags & seen_kill)!=0); }
615 vector<State> stateStack;
616 vector<const Varnode *> markedVn;
618 bool allowFailingPath;
624 markedVn.push_back(vn);
628 int4 enterNode(State &state);
629 int4 uponPop(State &state,int4 command);
630 bool checkConditionalExe(State &state);
642 vector<Varnode *> &outlist);
void spacebase(void)
Mark registers that map to a virtual address space.
Definition: funcdata.cc:214
JumpTable * recoverJumpTable(PcodeOp *op, FlowInfo *flow, int4 &failuremode)
Recover destinations for a BRANCHIND by analyzing nearby data and control-flow.
Definition: funcdata_block.cc:559
Varnode * newVarnodeOut(int4 s, const Address &m, PcodeOp *op)
Create a new output Varnode.
Definition: funcdata_varnode.cc:102
void clearSymbolLinks(HighVariable *high)
Clear Symbols attached to Varnodes in the given HighVariable.
Definition: funcdata_varnode.cc:975
bool deadRemovalAllowed(AddrSpace *spc) const
Return true if it is safe to remove dead code.
Definition: heritage.cc:2469
void markIndirectCreation(PcodeOp *indop, bool possibleOutput)
Convert CPUI_INDIRECT into an indirect creation.
Definition: funcdata_op.cc:689
void opSetAllInput(PcodeOp *op, const vector< Varnode * > &vvec)
Set all input Varnodes for the given PcodeOp simultaneously.
Definition: funcdata_op.cc:240
PcodeOpTree::const_iterator begin(const Address &addr) const
Start of all PcodeOps at one Address.
Definition: op.cc:1003
Abstract class for emitting pcode to an application.
Definition: translate.hh:76
Funcdata(const string &nm, Scope *conf, const Address &addr, FunctionSymbol *sym, int4 sz=0)
Constructor.
Definition: funcdata.cc:24
void switchEdge(FlowBlock *inblock, BlockBasic *outbefore, FlowBlock *outafter)
Switch an outgoing edge from the given source block to flow into another block.
Definition: funcdata_block.cc:960
A register or memory register that may be used to pass a parameter or return value.
Definition: fspec.hh:156
A control-flow block built out of sub-components.
Definition: block.hh:271
JumpTable * findJumpTable(const PcodeOp *op) const
Find a jump-table associated with a given BRANCHIND.
Definition: funcdata_block.cc:440
bool forceGoto(const Address &pcop, const Address &pcdest)
Force a specific control-flow edge to be marked as unstructured.
Definition: funcdata_block.cc:658
Utilities for merging low-level Varnodes into high-level variables.
A region where processor data is stored.
Definition: space.hh:73
void opInsert(PcodeOp *op, BlockBasic *bl, list< PcodeOp * >::iterator iter)
Insert the given PcodeOp at specific point in a basic block.
Definition: funcdata_op.cc:148
Description of a control-flow block containing PcodeOps.
Definition: block.hh:60
void adjustInputVarnodes(const Address &addr, int4 size)
Adjust input Varnodes contained in the given range.
Definition: funcdata_varnode.cc:381
Varnode * find(int4 s, const Address &loc, const Address &pc, uintm uniq=~((uintm) 0)) const
Find a Varnode.
Definition: varnode.cc:1074
Varnode * newUnique(int4 s, Datatype *ct=(Datatype *) 0)
Create a new temporary Varnode.
Definition: funcdata_varnode.cc:81
bool hasUnimplemented(void) const
Does this function have instructions marked as unimplemented.
Definition: funcdata.hh:199
void opSetOutput(PcodeOp *op, Varnode *vn)
Set a specific output Varnode for the given PcodeOp.
Definition: funcdata_op.cc:68
void setJumptableRecovery(bool val)
Toggle whether this is being used for jump-table recovery.
Definition: funcdata.hh:144
PcodeOpTree::const_iterator beginOpAll(void) const
Start of all (alive) PcodeOp objects sorted by sequence number.
Definition: funcdata.hh:473
bool deadRemovalAllowedSeen(AddrSpace *spc)
Check if dead code removal is safe and mark that removal has happened.
Definition: heritage.cc:2483
VarnodeLocSet::const_iterator beginLoc(int4 s, const Address &addr) const
Start of Varnodes with given storage.
Definition: funcdata.hh:322
list< PcodeOp * >::const_iterator beginOpAlive(void) const
Start of PcodeOp objects in the alive list.
Definition: funcdata.hh:461
VarnodeLocSet::const_iterator endLoc(AddrSpace *spaceid) const
Ending of Varnodes in given address space sorted by location.
Definition: varnode.cc:1182
A class for uniquely labelling and comparing PcodeOps.
Definition: address.hh:111
int4 fillinExtrapop(void)
Recover and return the extrapop for this function.
Definition: funcdata.cc:479
list< PcodeOp * >::const_iterator endDead(void) const
End of all PcodeOps marked as dead.
Definition: op.hh:309
VarnodeDefSet::const_iterator endDef(void) const
End of all Varnodes sorted by definition address.
Definition: funcdata.hh:345
VarnodeLocSet::const_iterator endLoc(int4 s, const Address &addr) const
End of Varnodes with given storage.
Definition: funcdata.hh:325
bool removeUnreachableBlocks(bool issuewarning, bool checkexistence)
Remove any unreachable basic blocks.
Definition: funcdata_block.cc:341
VarnodeLocSet::const_iterator endLoc(AddrSpace *spaceid) const
End of Varnodes stored in a given address space.
Definition: funcdata.hh:313
void saveXmlTree(ostream &s) const
Save an XML description of the p-code tree to stream.
Definition: funcdata.cc:625
void opUnsetOutput(PcodeOp *op)
Remove output Varnode from the given PcodeOp.
Definition: funcdata_op.cc:50
A map from values to control-flow targets within a function.
Definition: jumptable.hh:499
void setBasicBlockRange(BlockBasic *bb, const Address &beg, const Address &end)
Set the initial ownership range for the given basic block.
Definition: funcdata.hh:505
PcodeOp * getFirstReturnOp(void) const
Clone a PcodeOp into this function.
Definition: funcdata_op.cc:585
PcodeOp * target(const Address &addr) const
Find the first executing PcodeOp for a target address.
Definition: op.cc:946
Symbol * linkSymbolReference(Varnode *vn)
Discover and attach Symbol to a constant reference.
Definition: funcdata_varnode.cc:1054
Container class for PcodeOps associated with a single function.
Definition: op.hh:253
void spliceBlockBasic(BlockBasic *bl)
Merge the given basic block with the block it flows into.
Definition: funcdata_block.cc:971
A Symbol scope for local variables of a particular function.
Definition: varmap.hh:196
void opDestroy(PcodeOp *op)
Remove given PcodeOp and destroy its Varnode operands.
Definition: funcdata_op.cc:201
VarnodeLocSet::const_iterator endLoc(void) const
End of all Varnodes sorted by storage.
Definition: funcdata.hh:307
void markIndirectOnly(void)
Mark illegal input Varnodes used only in INDIRECTs.
Definition: funcdata_varnode.cc:690
void initActiveOutput(void)
Definition: funcdata_varnode.cc:472
PcodeOp * earliestUseInBlock(Varnode *vn, BlockBasic *bl)
Get the earliest use/read of a Varnode in a specified basic block.
Definition: funcdata_op.cc:1210
list< PcodeOp * >::const_iterator endOpDead(void) const
End of PcodeOp objects in the dead list.
Definition: funcdata.hh:470
void cseEliminateList(Funcdata &data, vector< pair< uintm, PcodeOp * > > &list, vector< Varnode * > &outlist)
Perform Common Subexpression Elimination on a list of Varnode descendants.
Definition: funcdata_op.cc:1334
Class for merging low-level Varnodes into high-level HighVariables.
Definition: merge.hh:80
PcodeOpTree::const_iterator endAll(void) const
End of all PcodeOps in sequence number order.
Definition: op.hh:291
VarnodeLocSet::const_iterator beginLoc(int4 s, const Address &addr, uint4 fl) const
Start of Varnodes matching storage and properties.
Definition: funcdata.hh:328
Manage the construction of Static Single Assignment (SSA) form.
Definition: heritage.hh:170
bool hasRestartPending(void) const
Does this function need to restart its analysis.
Definition: funcdata.hh:194
list< PcodeOp * >::const_iterator beginDead(void) const
Start of all PcodeOps marked as dead.
Definition: op.hh:306
VarnodeDefSet::const_iterator endDef(uint4 fl) const
End of varnodes with set definition property.
Definition: varnode.cc:1440
A container of commands that override the decompiler's default behavior for a single function.
Definition: override.hh:40
bool onlyOpUse(const Varnode *invn, const PcodeOp *opmatch, const ParamTrial &trial) const
Test if the given Varnode seems to only be used by a CALL.
Definition: funcdata_varnode.cc:1527
void clearActiveOutput(void)
Clear any analysis of the function's return prototype.
Definition: funcdata.hh:382
A p-code emitter for building PcodeOp objects.
Definition: funcdata.hh:563
void stopProcessing(void)
Mark that processing has completed for this function.
Definition: funcdata.cc:156
bool attemptDynamicMappingLate(SymbolEntry *entry, DynamicHash &dhash)
Map the name of a dynamic symbol to a Varnode.
Definition: funcdata_varnode.cc:1201
void truncatedFlow(const Funcdata *fd, const FlowInfo *flow)
Generate a clone with truncated control-flow given a partial function.
Definition: funcdata_op.cc:745
void calcNZMask(void)
Calculate non-zero masks for all Varnodes.
Definition: funcdata_varnode.cc:731
PcodeOp * cseFindInBlock(PcodeOp *op, Varnode *vn, BlockBasic *bl, PcodeOp *earliest)
Find a duplicate calculation of a given PcodeOp reading a specific Varnode.
Definition: funcdata_op.cc:1238
void totalReplace(Varnode *vn, Varnode *newvn)
Replace all read references to the first Varnode with a second Varnode.
Definition: funcdata_varnode.cc:1252
list< PcodeOp * >::const_iterator endOp(OpCode opc) const
End of PcodeOp objects with the given op-code.
Definition: funcdata.hh:458
JumpTable * installJumpTable(const Address &addr)
Install a new jump-table for the given Address.
Definition: funcdata_block.cc:458
Varnode * findSpacebaseInput(AddrSpace *id) const
Definition: funcdata.cc:275
VarnodeDefSet::const_iterator beginDef(uint4 fl, const Address &addr) const
Start of (input or free) Varnodes at a given storage address.
Definition: funcdata.hh:354
A collection of Symbol objects within a single (namespace or functional) scope.
Definition: database.hh:402
bool replaceLessequal(PcodeOp *op)
Replace INT_LESSEQUAL and INT_SLESSEQUAL expressions.
Definition: funcdata_op.cc:977
VarnodeDefSet::const_iterator endDef(uint4 fl, const Address &addr) const
End of (input or free) Varnodes at a given storage address.
Definition: funcdata.hh:357
bool execute(PcodeOp *op, int4 slot, ParamTrial *t, bool allowFail)
Perform a full ancestor check on a given parameter trial.
Definition: funcdata_varnode.cc:1843
bool syncVarnodesWithSymbols(const ScopeLocal *lm, bool typesyes)
Update Varnode properties based on (new) Symbol information.
Definition: funcdata_varnode.cc:812
void printBlockTree(ostream &s) const
Print a description of control-flow structuring to a stream.
Definition: funcdata_block.cc:25
A class for generating the control-flow structure for a single function.
Definition: flow.hh:56
PcodeOp * cloneOp(const PcodeOp *op, const SeqNum &seq)
Definition: funcdata_op.cc:569
A class for analyzing parameters to a sub-function call.
Definition: fspec.hh:1449
void opInsertInput(PcodeOp *op, Varnode *vn, int4 slot)
Insert a new Varnode into the operand list for the given PcodeOp.
Definition: funcdata_op.cc:281
PcodeOp * newOpBefore(PcodeOp *follow, OpCode opc, Varnode *in1, Varnode *in2, Varnode *in3=(Varnode *) 0)
Allocate a new PcodeOp with sequence number.
Definition: funcdata_op.cc:609
bool moveRespectingCover(PcodeOp *op, PcodeOp *lastOp)
Move given op past lastOp respecting covers if possible.
Definition: funcdata_op.cc:1373
@ nonprinting
Op should not be directly printed as source.
Definition: op.hh:89
An XML element. A node in the DOM tree.
Definition: xml.hh:150
A basic block for p-code operations.
Definition: block.hh:365
void followFlow(const Address &baddr, const Address &eadddr)
Generate raw p-code for the function.
Definition: funcdata_op.cc:709
FuncCallSpecs * getCallSpecs(const PcodeOp *op) const
Get the call specification associated with a CALL op.
Definition: funcdata.cc:418
Lowest level operation of the p-code language.
Definition: op.hh:58
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
void opUninsert(PcodeOp *op)
Remove the given PcodeOp from its basic block.
Definition: funcdata_op.cc:162
A storage location for a particular Symbol.
Definition: database.hh:51
int4 numHeritagePasses(AddrSpace *spc) const
Get the number times heritage was performed for the given address space.
Definition: heritage.cc:2419
list< PcodeOp * >::const_iterator endAlive(void) const
End of all PcodeOps marked as alive.
Definition: op.hh:303
void printLocalRange(ostream &s) const
Print description of memory ranges associated with local scopes.
Definition: funcdata.cc:531
VarnodeDefSet::const_iterator beginDef(uint4 fl) const
Start of Varnodes with a given definition property.
Definition: funcdata.hh:348
void transferVarnodeProperties(Varnode *vn, Varnode *newVn, int4 lsbOffset)
Copy properties from an existing Varnode to a new Varnode.
Definition: funcdata_varnode.cc:501
VarnodeLocSet::const_iterator beginLoc(void) const
Start of all Varnodes sorted by storage.
Definition: funcdata.hh:304
Description of a LOAD operation that needs to be guarded.
Definition: heritage.hh:105
Varnode * createStackRef(AddrSpace *spc, uintb off, PcodeOp *op, Varnode *stackptr, bool insertafter)
Create an INT_ADD PcodeOp calculating an offset to the spacebase register.
Definition: funcdata_op.cc:432
void opSetInput(PcodeOp *op, Varnode *vn, int4 slot)
Set a specific input operand for the given PcodeOp.
Definition: funcdata_op.cc:102
VarnodeLocSet::const_iterator endLoc(int4 s, const Address &addr, const Address &pc, uintm uniq=~((uintm) 0)) const
End of Varnodes matching storage and definition address.
Definition: funcdata.hh:338
void destroy(PcodeOp *op)
Destroy/retire the given PcodeOp.
Definition: op.cc:846
void remapVarnode(Varnode *vn, Symbol *sym, const Address &usepoint)
Remap a Symbol to a given Varnode using a static mapping.
Definition: funcdata_varnode.cc:992
void doLiveInject(InjectPayload *payload, const Address &addr, BlockBasic *bl, list< PcodeOp * >::iterator pos)
Inject p-code from a payload into this live function.
Definition: funcdata.cc:793
void removeFromFlowSplit(BlockBasic *bl, bool swap)
Remove a basic block splitting its control-flow into two distinct paths.
Definition: funcdata_block.cc:944
PcodeOp * newIndirectOp(PcodeOp *indeffect, const Address &addr, int4 size, uint4 extraFlags)
Find a representative CPUI_RETURN op for this function.
Definition: funcdata_op.cc:636
VarnodeLocSet::const_iterator endLoc(int4 s, const Address &addr, uint4 fl) const
End of Varnodes matching storage and properties.
Definition: funcdata.hh:331
void setHighLevel(void)
Turn on HighVariable objects for all Varnodes.
Definition: funcdata_varnode.cc:482
bool fillinReadOnly(Varnode *vn)
Replace the given Varnode with its (constant) value in the load image.
Definition: funcdata_varnode.cc:516
An active container for a set of p-code operations that can be injected into data-flow.
Definition: pcodeinject.hh:78
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
Varnode * newUniqueOut(int4 s, PcodeOp *op)
Create a new temporary output Varnode.
Definition: funcdata_varnode.cc:127
Container class for ParamTrial objects.
Definition: fspec.hh:222
void printRaw(ostream &s) const
Print raw p-code op descriptions to a stream.
Definition: funcdata.cc:193
void opDestroyRaw(PcodeOp *op)
Remove the given raw PcodeOp.
Definition: funcdata_op.cc:226
void saveXmlHigh(ostream &s) const
Save an XML description of all HighVariables to stream.
Definition: funcdata.cc:596
VarnodeDefSet::const_iterator beginDef(void) const
Start of all Varnodes sorted by definition address.
Definition: funcdata.hh:342
void seenDeadcode(AddrSpace *spc)
Mark that dead Varnodes have been seen in a specific address space.
Definition: funcdata.hh:218
void nodeSplit(BlockBasic *b, int4 inedge)
Split control-flow into a basic block, duplicating its p-code into a new block.
Definition: funcdata_block.cc:906
void destroyDead(void)
Destroy/retire all PcodeOps in the dead list.
Definition: op.cc:828
PcodeOpTree::const_iterator end(const Address &addr) const
End of all PcodeOps at one Address.
Definition: op.cc:1009
PcodeOp * opStackStore(AddrSpace *spc, uintb off, PcodeOp *op, bool insertafter)
Create a STORE expression at an offset relative to a spacebase register for a given address space.
Definition: funcdata_op.cc:481
Varnode * findCoveringInput(int4 s, const Address &loc) const
Find the input Varnode that contains the given range.
Definition: funcdata.hh:284
Varnode * setInputVarnode(Varnode *vn)
Mark a Varnode as an input to the function.
Definition: funcdata_varnode.cc:338
VarnodeLocSet::const_iterator beginLoc(AddrSpace *spaceid) const
Start of Varnodes stored in a given address space.
Definition: funcdata.hh:310
void opSetOpcode(PcodeOp *op, OpCode opc)
Set the op-code for a specific PcodeOp.
Definition: funcdata_op.cc:23
void opFlipInPlaceExecute(Funcdata &data, vector< PcodeOp * > &fliplist)
Perform op-code flips (in-place) to change a boolean value.
Definition: funcdata_op.cc:1170
bool deadRemovalAllowed(AddrSpace *spc) const
Check if dead code removal is allowed for a specific address space.
Definition: funcdata.hh:230
void printVarnodeTree(ostream &s) const
Print a description of all Varnodes to a stream.
Definition: funcdata.cc:513
void opMarkHalt(PcodeOp *op, uint4 flag)
Mark given CPUI_RETURN op as a special halt.
Definition: funcdata_op.cc:35
void heritage(void)
Perform one pass of heritage.
Definition: heritage.cc:2306
void opInsertBefore(PcodeOp *op, PcodeOp *follow)
Insert given PcodeOp before a specific op.
Definition: funcdata_op.cc:318
void insertAfterDead(PcodeOp *op, PcodeOp *prev)
Insert the given PcodeOp after a point in the dead list.
Definition: op.cc:896
Architecture and associated classes that help manage a single processor architecture and load image.
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
uint8 restoreXml(const Element *el)
Restore the state of this function from an XML description.
Definition: funcdata.cc:708
void setRestartPending(bool val)
Toggle whether analysis needs to be restarted for this function.
Definition: funcdata.hh:189
Varnode * findCoveringInput(int4 s, const Address &loc) const
Find an input Varnode covering a range.
Definition: varnode.cc:1147
Varnode * findCoveredInput(int4 s, const Address &loc) const
Find the first input Varnode covered by the given range.
Definition: funcdata.hh:277
void opDeadInsertAfter(PcodeOp *op, PcodeOp *prev)
Moved given PcodeOp to specified point in the dead list.
Definition: funcdata.hh:419
Container for data structures associated with a single function.
Definition: funcdata.hh:45
The base datatype class for the decompiler.
Definition: type.hh:62
void seenDeadCode(AddrSpace *spc)
Inform system of dead code removal in given space.
Definition: heritage.cc:2431
bool distributeIntMultAdd(PcodeOp *op)
Distribute constant coefficient to additive input.
Definition: funcdata_op.cc:1020
void installSwitchDefaults(void)
Make sure default switch cases are properly labeled.
Definition: funcdata_block.cc:604
PcodeOp * findOp(const SeqNum &num) const
Find a PcodeOp by sequence number.
Definition: op.cc:956
void saveXml(ostream &s, uint8 id, bool savetree) const
Emit an XML description of this function to stream.
Definition: funcdata.cc:676
Varnode * findLinkedVarnode(SymbolEntry *entry) const
Find a Varnode matching the given Symbol mapping.
Definition: funcdata_varnode.cc:1079
void opRemoveInput(PcodeOp *op, int4 slot)
Remove a specific input slot for the given PcodeOp.
Definition: funcdata_op.cc:264
list< PcodeOp * >::const_iterator beginOpDead(void) const
Start of PcodeOp objects in the dead list.
Definition: funcdata.hh:467
@ calculated_bool
Output has been determined to be a 1-bit boolean value.
Definition: op.hh:97
JumpTable * linkJumpTable(PcodeOp *op)
Link jump-table with a given BRANCHIND.
Definition: funcdata_block.cc:421
void opInsertAfter(PcodeOp *op, PcodeOp *prev)
Insert given PcodeOp after a specific op.
Definition: funcdata_op.cc:346
void setDeadCodeDelay(AddrSpace *spc, int4 delay)
Set delay for a specific space.
Definition: heritage.cc:2455
int4 opFlipInPlaceTest(PcodeOp *op, vector< PcodeOp * > &fliplist)
Trace a boolean value to a set of PcodeOps that can be changed to flip the boolean value.
Definition: funcdata_op.cc:1110
VarnodeLocSet::const_iterator endLoc(const Address &addr) const
End of Varnodes at a storage address.
Definition: funcdata.hh:319
static bool compareCallspecs(const FuncCallSpecs *a, const FuncCallSpecs *b)
Compare call specification objects by call site address.
Definition: funcdata.cc:438
A hash utility to uniquely identify a temporary Varnode in data-flow.
Definition: dynamic.hh:60
void remapDynamicVarnode(Varnode *vn, Symbol *sym, const Address &usepoint, uint8 hash)
Remap a Symbol to a given Varnode using a new dynamic mapping.
Definition: funcdata_varnode.cc:1008
Symbol * linkSymbol(Varnode *vn)
Find or create Symbol associated with given Varnode.
Definition: funcdata_varnode.cc:1021
Varnode * findVarnodeInput(int4 s, const Address &loc) const
Find the input Varnode with the given size and storage address.
Definition: funcdata.hh:291
BlockBasic * nodeJoinCreateBlock(BlockBasic *block1, BlockBasic *block2, BlockBasic *exita, BlockBasic *exitb, bool fora_block1ishigh, bool forb_block1ishigh, const Address &addr)
Create a new basic block for holding a merged CBRANCH.
Definition: funcdata_block.cc:696
bool isHeritaged(Varnode *vn)
Check if a specific Varnode has been linked in fully to the syntax tree (SSA)
Definition: funcdata.hh:242
void totalReplaceConstant(Varnode *vn, uintb val)
Replace every read reference of the given Varnode with a constant value.
Definition: funcdata_varnode.cc:1274
bool inlineFlow(Funcdata *inlinefd, FlowInfo &flow, PcodeOp *callop)
In-line the p-code from another function into this function.
Definition: funcdata_op.cc:806
bool startTypeRecovery(void)
Mark that data-type analysis has started.
Definition: funcdata.cc:166
void setDoublePrecisRecovery(bool val)
Toggle whether double precision analysis is used.
Definition: funcdata.hh:151
void clearDeadVarnodes(void)
Delete any dead Varnodes.
Definition: funcdata_varnode.cc:707
A Symbol representing an executable function.
Definition: database.hh:251
A high-level variable modeled as a list of low-level variables, each written once.
Definition: variable.hh:38
void opUnlink(PcodeOp *op)
Unset inputs/output and remove given PcodeOP from its basic block.
Definition: funcdata_op.cc:177
list< PcodeOp * >::const_iterator beginOp(OpCode opc) const
Start of PcodeOp objects with the given op-code.
Definition: funcdata.hh:455
Varnode * newCodeRef(const Address &m)
Create a code address annotation Varnode.
Definition: funcdata_varnode.cc:220
bool replaceVolatile(Varnode *vn)
Replace accesses of the given Varnode with volatile operations.
Definition: funcdata_varnode.cc:598
OpCode
The op-code defining a specific p-code operation (PcodeOp)
Definition: opcodes.hh:35
void pushBranch(BlockBasic *bb, int4 slot, BlockBasic *bbnew)
Move a control-flow edge from one block to another.
Definition: funcdata_block.cc:398
VarnodeLocSet::const_iterator beginLoc(AddrSpace *spaceid) const
Beginning of Varnodes in given address space sorted by location.
Definition: varnode.cc:1171
Utilities for building Static Single Assignment (SSA) form
bool deadRemovalAllowedSeen(AddrSpace *spc)
Check if dead Varnodes have been removed for a specific address space.
Definition: funcdata.hh:236
Varnode * findCoveredInput(int4 s, const Address &loc) const
Find an input Varnode contained within this range.
Definition: varnode.cc:1119
int4 heritagePass(const Address &addr) const
Get the pass number when the given address was heritaged.
Definition: heritage.hh:277
void opSwapInput(PcodeOp *op, int4 slot1, int4 slot2)
Swap two input operands in the given PcodeOp.
Definition: funcdata_op.cc:129
void warningHeader(const string &txt) const
Add a warning comment as part of the function header.
Definition: funcdata.cc:123
VarnodeDefSet::const_iterator endDef(uint4 fl) const
End of Varnodes with a given definition property.
Definition: funcdata.hh:351
@ startmark
This op is the first in its instruction.
Definition: op.hh:81
const LoadGuard * getStoreGuard(PcodeOp *op) const
Get LoadGuard record associated with given PcodeOp.
Definition: heritage.cc:2402
Varnode * newVarnodeCallSpecs(FuncCallSpecs *fc)
Create a call specification annotation Varnode.
Definition: funcdata_varnode.cc:203
void checkForLanedRegister(int4 size, const Address &addr)
Check for a potential laned register.
Definition: funcdata_varnode.cc:296
list< PcodeOp * >::const_iterator beginAlive(void) const
Start of all PcodeOps marked as alive.
Definition: op.hh:300
Varnode * findVarnodeWritten(int4 s, const Address &loc, const Address &pc, uintm uniq=~((uintm) 0)) const
Find a defined Varnode via its storage address and its definition address.
Definition: funcdata.hh:300
void startProcessing(void)
Start processing for this function.
Definition: funcdata.cc:138
VarnodeLocSet::const_iterator beginLoc(int4 s, const Address &addr, const Address &pc, uintm uniq=~((uintm) 0)) const
Start of Varnodes matching storage and definition address.
Definition: funcdata.hh:334
Address findDisjointCover(Varnode *vn, int4 &sz)
Find range covering given Varnode and any intersecting Varnodes.
Definition: funcdata_varnode.cc:1351
@ spacebase_ptr
Loads or stores from a dynamic pointer into a spacebase.
Definition: op.hh:95
void opInsertEnd(PcodeOp *op, BlockBasic *bl)
Insert given PcodeOp at the end of a basic block.
Definition: funcdata_op.cc:408
PcodeOpTree::const_iterator endOp(const Address &addr) const
End of all (alive) PcodeOp objects attached to a specific Address.
Definition: funcdata.hh:482
void warning(const string &txt, const Address &ad) const
Add a warning comment in the function body.
Definition: funcdata.cc:107
void saveXmlJumpTable(ostream &s) const
Emit an XML description of jump-tables to stream.
Definition: funcdata.cc:562
@ is_cpool_transformed
Have we checked for cpool transforms.
Definition: op.hh:108
void buildDynamicSymbol(Varnode *vn)
Build a dynamic Symbol associated with the given Varnode.
Definition: funcdata_varnode.cc:1144
PcodeOp * newOp(int4 inputs, const Address &pc)
Definition: funcdata_op.cc:295
void clear(void)
Clear out old disassembly.
Definition: funcdata.cc:75
@ boolean_flip
Set if condition must be false to take branch.
Definition: op.hh:77
~Funcdata(void)
Destructor.
Definition: funcdata.cc:174
Helper class for determining if Varnodes can trace their value from a legitimate source.
Definition: funcdata.hh:576
Utilities for making references to dynamic variables: defined as locations and constants that can onl...
PcodeOpTree::const_iterator endOpAll(void) const
End of all (alive) PcodeOp objects sorted by sequence number.
Definition: funcdata.hh:476
Data defining a specific memory location.
Definition: pcoderaw.hh:33
void restoreXmlJumpTable(const Element *el)
Restore jump-tables from an XML description.
Definition: funcdata.cc:547
PcodeOp * cseElimination(Funcdata &data, PcodeOp *op1, PcodeOp *op2)
Perform a Common Subexpression Elimination step.
Definition: funcdata_op.cc:1271
void findLinkedVarnodes(SymbolEntry *entry, vector< Varnode * > &res) const
Find Varnodes that map to the given SymbolEntry.
Definition: funcdata_varnode.cc:1118
VarnodeDefSet::const_iterator beginDef(uint4 fl) const
Beginning of varnodes with set definition property.
Definition: varnode.cc:1402
Varnode * newVarnode(int4 s, const Address &m, Datatype *ct=(Datatype *) 0)
Create a new unattached Varnode object.
Definition: funcdata_varnode.cc:146
void destroy(Varnode *vn)
Remove a Varnode from the container.
Definition: varnode.cc:910
VarnodeLocSet::const_iterator beginLoc(const Address &addr) const
Start of Varnodes at a storage address.
Definition: funcdata.hh:316
PcodeOpTree::const_iterator beginAll(void) const
Start of all PcodeOps in sequence number order.
Definition: op.hh:288
void spacebaseConstant(PcodeOp *op, int4 slot, SymbolEntry *entry, const Address &rampoint, uintb origval, int4 origsize)
Convert a constant pointer into a ram CPUI_PTRSUB.
Definition: funcdata.cc:303
Varnode * newConstant(int4 s, uintb constant_val)
Create a new constant Varnode.
Definition: funcdata_varnode.cc:64
A function prototype.
Definition: fspec.hh:1164
void removeBranch(BlockBasic *bb, int4 num)
Remove the indicated branch from a basic block.
Definition: funcdata_block.cc:215
Varnode * findInput(int4 s, const Address &loc) const
Find an input Varnode.
Definition: varnode.cc:1099
void opUnsetInput(PcodeOp *op, int4 slot)
Clear an input operand slot for the given PcodeOp.
Definition: funcdata_op.cc:90
Varnode * newVarnodeIop(PcodeOp *op)
Create a PcodeOp annotation Varnode.
Definition: funcdata_varnode.cc:174
void setDeadCodeDelay(AddrSpace *spc, int4 delay)
Set a delay before removing dead code for a specific address space.
Definition: funcdata.hh:224
Varnode * newSpacebasePtr(AddrSpace *id)
Construct a new spacebase register for a given address space.
Definition: funcdata.cc:259
int4 numHeritagePasses(AddrSpace *spc)
Get the number of heritage passes performed for the given address space.
Definition: funcdata.hh:213
bool ancestorOpUse(int4 maxlevel, const Varnode *invn, const PcodeOp *op, ParamTrial &trial) const
Test if the given trial Varnode is likely only used for parameter passing.
Definition: funcdata_varnode.cc:1600
void mapGlobals(void)
Make sure there is a Symbol entry for all global Varnodes.
Definition: funcdata_varnode.cc:1407
@ startbasic
This instruction starts a basic block.
Definition: op.hh:67
Varnode * newVarnodeSpace(AddrSpace *spc)
Create a constant Varnode referring to an address space.
Definition: funcdata_varnode.cc:188
list< PcodeOp * >::const_iterator endOpAlive(void) const
End of PcodeOp objects in the alive list.
Definition: funcdata.hh:464
The base class for a symbol in a symbol table or scope.
Definition: database.hh:152
@ special_print
Op is marked for special printing.
Definition: op.hh:104
HighVariable * findHigh(const string &name) const
Find a high-level variable by name.
Definition: funcdata_varnode.cc:314
@ nocollapse
This op cannot be collapsed further.
Definition: op.hh:71
PcodeOpTree::const_iterator beginOp(const Address &addr) const
Start of all (alive) PcodeOp objects attached to a specific Address.
Definition: funcdata.hh:479
A container for Varnode objects from a specific function.
Definition: varnode.hh:327
void opUndoPtradd(PcodeOp *op, bool finalize)
Convert a CPUI_PTRADD back into a CPUI_INT_ADD.
Definition: funcdata_op.cc:532
Varnode * opStackLoad(AddrSpace *spc, uintb off, uint4 sz, PcodeOp *op, Varnode *stackptr, bool insertafter)
Create a LOAD expression at an offset relative to a spacebase register for a given address space.
Definition: funcdata_op.cc:514
void removeJumpTable(JumpTable *jt)
Remove/delete the given jump-table.
Definition: funcdata_block.cc:62
PcodeOp * newIndirectCreation(PcodeOp *indeffect, const Address &addr, int4 size, bool possibleout)
Build a CPUI_INDIRECT op that indirectly creates a Varnode.
Definition: funcdata_op.cc:663
bool collapseIntMultMult(Varnode *vn)
Collapse constant coefficients for two chained CPUI_INT_MULT.
Definition: funcdata_op.cc:1079
void removeDoNothingBlock(BlockBasic *bb)
Remove a basic block from control-flow that performs no operations.
Definition: funcdata_block.cc:322
void overrideFlow(const Address &addr, uint4 type)
Override the control-flow p-code for a particular instruction.
Definition: funcdata_op.cc:917
bool checkCallDoubleUse(const PcodeOp *opmatch, const PcodeOp *op, const Varnode *vn, const ParamTrial &trial) const
Test for legitimate double use of a parameter trial.
Definition: funcdata_varnode.cc:1485
A system for sending override commands to the decompiler.
bool attemptDynamicMapping(SymbolEntry *entry, DynamicHash &dhash)
Map properties of a dynamic symbol to a Varnode.
Definition: funcdata_varnode.cc:1171
void opInsertBegin(PcodeOp *op, BlockBasic *bl)
Insert given PcodeOp at the beginning of a basic block.
Definition: funcdata_op.cc:386