Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
19 #ifndef __CPUI_FSPEC__
20 #define __CPUI_FSPEC__
73 void resolveJoin(
void);
80 int4 getGroup(
void)
const {
return group; }
81 int4 getGroupSize(
void)
const {
return groupsize; }
82 int4 getSize(
void)
const {
return size; }
83 int4 getMinSize(
void)
const {
return minsize; }
84 int4 getAlign(
void)
const {
return alignment; }
86 bool isExclusion(
void)
const {
return (alignment==0); }
87 bool isReverseStack(
void)
const {
return ((flags &
reverse_stack)!=0); }
94 AddrSpace *getSpace(
void)
const {
return spaceid; }
95 uintb getBase(
void)
const {
return addressbase; }
99 bool isParamCheckHigh(
void)
const {
return ((flags &
extracheck_high)!=0); }
100 bool isParamCheckLow(
void)
const {
return ((flags &
extracheck_low)!=0); }
116 InitData(int4 pos,
ParamEntry *e) { position = pos; entry = e; }
120 class SubsortPosition {
123 SubsortPosition(
void) {}
124 SubsortPosition(int4 pos) { position = pos; }
125 SubsortPosition(
bool val) { position = val ? 1000000 : 0; }
126 bool operator<(
const SubsortPosition &op2) {
return position < op2.position; }
134 first = f; last = l; position = data.position; entry = data.entry; }
135 uintb getFirst(
void)
const {
return first; }
136 uintb getLast(
void)
const {
return last; }
137 subsorttype getSubsort(
void)
const {
return SubsortPosition(position); }
138 ParamEntry *getParamEntry(
void)
const {
return entry; }
179 const Address &getAddress(
void)
const {
return addr; }
180 int4 getSize(
void)
const {
return size; }
181 int4 getSlot(
void)
const {
return slot; }
182 void setSlot(int4 val) { slot = val; }
183 const ParamEntry *getEntry(
void)
const {
return entry; }
184 int4 getOffset(
void)
const {
return offset; }
185 void setEntry(
const ParamEntry *ent,int4 off) { entry=ent; offset=off; }
186 void markUsed(
void) { flags |=
used; }
188 void markInactive(
void) { flags &= ~((uint4)
active); flags |=
checked; }
190 void markUnref(
void) { flags |= (
unref|
checked); slot = -1; }
192 bool isChecked(
void)
const {
return ((flags &
checked)!=0); }
193 bool isActive(
void)
const {
return ((flags &
active)!=0); }
194 bool isDefinitelyNotUsed(
void)
const {
return ((flags &
defnouse)!=0); }
195 bool isUsed(
void)
const {
return ((flags &
used)!=0); }
196 bool isUnref(
void)
const {
return ((flags &
unref)!=0); }
197 bool isKilledByCall(
void)
const {
return ((flags &
killedbycall)!=0); }
198 void setRemFormed(
void) { flags |=
rem_formed; }
199 bool isRemFormed(
void)
const {
return ((flags &
rem_formed)!=0); }
201 bool isIndCreateFormed(
void)
const {
return ((flags &
indcreate_formed)!=0); }
203 bool hasCondExeEffect(
void)
const {
return ((flags &
condexe_effect)!=0); }
204 int4 slotGroup(
void)
const {
return entry->
getSlot(addr,size-1); }
205 void setAddress(
const Address &ad,int4 sz) { addr=ad; size=sz; }
223 vector<ParamTrial> trial;
225 int4 stackplaceholder;
229 bool needsfinalcheck;
235 int4 getNumTrials(
void)
const {
return trial.size(); }
236 ParamTrial &getTrial(int4 i) {
return trial[i]; }
239 bool needsFinalCheck(
void)
const {
return needsfinalcheck; }
240 void markNeedsFinalCheck(
void) { needsfinalcheck =
true; }
241 bool isRecoverSubcall(
void)
const {
return recoversubcall; }
242 bool isFullyChecked(
void)
const {
return isfullychecked; }
243 void markFullyChecked(
void) { isfullychecked =
true; }
244 void setPlaceholderSlot(
void) { stackplaceholder = slotbase; slotbase += 1; }
246 int4 getNumPasses(
void)
const {
return numpasses; }
247 int4 getMaxPass(
void)
const {
return maxpass; }
248 void setMaxPass(int4 val) { maxpass = val; }
249 void finishPass(
void) { numpasses += 1; }
250 void sortTrials(
void) { sort(trial.begin(),trial.end()); }
262 bool testShrink(int4 i,
const Address &addr,int4 sz)
const {
return trial[i].testShrink(addr,sz); }
269 void shrink(int4 i,
const Address &addr,int4 sz) { trial[i].setAddress(addr,sz); }
287 virtual void printRaw(ostream &s,uintb offset)
const;
288 virtual void saveXml(ostream &s)
const;
329 uint4 getType(
void)
const {
return type; }
331 int4 getSize(
void)
const {
return address.
size; }
335 void saveXml(ostream &s)
const;
355 virtual uint4
getType(
void)
const=0;
364 virtual void assignMap(
const vector<Datatype *> &proto,
bool isinput,
365 TypeFactory &typefactory,vector<ParameterPieces> &res)
const=0;
521 const list<ParamEntry> &getEntry(
void)
const {
return entry; }
523 virtual void assignMap(
const vector<Datatype *> &proto,
bool isinput,
524 TypeFactory &typefactory,vector<ParameterPieces> &res)
const;
553 virtual void assignMap(
const vector<Datatype *> &proto,
bool isinput,
554 TypeFactory &typefactory,vector<ParameterPieces> &res)
const;
592 virtual void assignMap(
const vector<Datatype *> &proto,
bool isinput,
593 TypeFactory &typefactory,vector<ParameterPieces> &res)
const {
594 throw LowlevelError(
"Cannot assign prototype before model has been resolved"); }
596 throw LowlevelError(
"Cannot determine prototype before model has been resolved"); }
630 vector<EffectRecord> effectlist;
631 vector<VarnodeData> likelytrash;
632 int4 injectUponEntry;
633 int4 injectUponReturn;
636 bool stackgrowsnegative;
639 void defaultLocalRange(
void);
640 void defaultParamRange(
void);
641 void buildParamList(
const string &strategy);
649 const string &getName(
void)
const {
return name; }
652 int4 getExtraPop(
void)
const {
return extrapop; }
653 void setExtraPop(int4 ep) { extrapop = ep; }
654 int4 getInjectUponEntry(
void)
const {
return injectUponEntry; }
655 int4 getInjectUponReturn(
void)
const {
return injectUponReturn; }
672 void assignParameterStorage(
const vector<Datatype *> &typelist,vector<ParameterPieces> &res,
bool ignoreOutputError);
684 return input->
checkJoin(hiaddr,hisize,loaddr,losize); }
696 return output->
checkJoin(hiaddr,hisize,loaddr,losize); }
707 return input->
checkSplit(loc,size,splitpoint); }
709 const RangeList &getLocalRange(
void)
const {
return localrange; }
710 const RangeList &getParamRange(
void)
const {
return paramrange; }
711 vector<EffectRecord>::const_iterator effectBegin(
void)
const {
return effectlist.begin(); }
712 vector<EffectRecord>::const_iterator effectEnd(
void)
const {
return effectlist.end(); }
713 int4 numLikelyTrash(
void)
const {
return likelytrash.size(); }
714 const VarnodeData &getLikelyTrash(int4 i)
const {
return likelytrash[i]; }
821 bool isStackGrowsNegative(
void)
const {
return stackgrowsnegative; }
822 bool hasThisPointer(
void)
const {
return hasThis; }
823 bool isConstructor(
void)
const {
return isConstruct; }
841 virtual bool isMerged(
void)
const {
return false; }
843 static uint4
lookupEffect(
const vector<EffectRecord> &efflist,
const Address &addr,int4 size);
859 bool operator<(
const PEntry &op2)
const {
return (slot < op2.slot); }
866 vector<PEntry> entry;
874 int4 getScore(
void)
const {
return finalscore; }
875 int4 getNumMismatch(
void)
const {
return mismatch; }
890 vector<ProtoModel *> modellist;
891 void intersectEffects(
const vector<EffectRecord> &efflist);
892 void intersectLikelyTrash(
const vector<VarnodeData> &trashlist);
896 int4 numModels(
void)
const {
return modellist.size(); }
897 ProtoModel *getModel(int4 i)
const {
return modellist[i]; }
900 virtual bool isMerged(
void)
const {
return true; }
916 virtual const string &
getName(
void)
const=0;
919 virtual int4
getSize(
void)
const=0;
967 return !(*
this==op2); }
982 name = nm; addr = ad; type = tp; flags=fl; }
984 type = tp; flags = 0; }
985 virtual const string &
getName(
void)
const {
return name; }
988 virtual int4
getSize(
void)
const {
return type->getSize(); }
1053 virtual void saveXml(ostream &s)
const=0;
1072 virtual const string &
getName(
void)
const;
1075 virtual int4
getSize(
void)
const;
1100 vector<ProtoParameter *> inparam;
1115 virtual void saveXml(ostream &s)
const;
1125 vector<ProtoParameter *> inparam;
1139 virtual void saveXml(ostream &s)
const;
1171 paramshift_applied = 32,
1172 error_inputparam = 64,
1173 error_outputparam = 128,
1174 custom_storage = 256,
1175 unknown_model = 512,
1176 is_constructor = 0x400,
1177 is_destructor = 0x800,
1178 has_thisptr= 0x1000,
1179 is_override = 0x2000
1185 vector<EffectRecord> effectlist;
1186 vector<VarnodeData> likelytrash;
1188 int4 returnBytesConsumed;
1189 void updateThisPointer(
void);
1192 bool isParamshiftApplied(
void)
const {
return ((flags¶mshift_applied)!=0); }
1193 void setParamshiftApplied(
bool val) { flags = val ? (flags|paramshift_applied) : (flags & ~((uint4)paramshift_applied)); }
1198 Architecture *getArch(
void)
const {
return model->getArch(); }
1206 bool hasModel(
void)
const {
return (model != (
ProtoModel *)0); }
1208 bool hasMatchingModel(
const FuncProto *op2)
const {
return (model == op2->model); }
1209 bool hasMatchingModel(
const ProtoModel *op2)
const {
return (model == op2); }
1210 const string &getModelName(
void)
const {
return model->getName(); }
1211 int4 getModelExtraPop(
void)
const {
return model->getExtraPop(); }
1215 bool isModelLocked(
void)
const {
return ((flags&modellock)!=0); }
1216 bool isUnknownModel(
void)
const {
return ((flags&unknown_model)!=0); }
1217 bool hasCustomStorage(
void)
const {
return ((flags&custom_storage)!=0); }
1226 void setModelLock(
bool val) { flags = val ? (flags|modellock) : (flags & ~((uint4)modellock)); }
1228 bool isInline(
void)
const {
return ((flags & is_inline)!=0); }
1234 void setInline(
bool val) { flags = val ? (flags|is_inline) : (flags & ~((uint4)is_inline)); }
1256 void setNoReturn(
bool val) { flags = val ? (flags|no_return) : (flags & ~((uint4)no_return)); }
1267 void setConstructor(
bool val) { flags = val ? (flags|is_constructor) : (flags & ~((uint4)is_constructor)); }
1275 void setDestructor(
bool val) { flags = val ? (flags|is_destructor) : (flags & ~((uint4)is_destructor)); }
1286 void setInputErrors(
bool val) { flags = val ? (flags|error_inputparam) : (flags & ~((uint4)error_inputparam)); }
1291 void setOutputErrors(
bool val) { flags = val ? (flags|error_outputparam) : (flags & ~((uint4)error_outputparam)); }
1293 int4 getExtraPop(
void)
const {
return extrapop; }
1294 void setExtraPop(int4 ep) { extrapop = ep; }
1295 int4 getInjectUponEntry(
void)
const {
return model->getInjectUponEntry(); }
1296 int4 getInjectUponReturn(
void)
const {
return model->getInjectUponReturn(); }
1347 void updateAllTypes(
const vector<string> &namelist,
const vector<Datatype *> &typelist,
bool dtdtdt);
1349 void removeParam(int4 i) { store->
clearInput(i); }
1350 int4 numParams(
void)
const {
return store->
getNumInputs(); }
1353 const RangeList &getLocalRange(
void)
const {
return model->getLocalRange(); }
1354 const RangeList &getParamRange(
void)
const {
return model->getParamRange(); }
1355 bool isStackGrowsNegative(
void)
const {
return model->isStackGrowsNegative(); }
1356 bool isDotdotdot(
void)
const {
return ((flags&dotdotdot)!=0); }
1357 void setDotdotdot(
bool val) { flags = val ? (flags|dotdotdot) : (flags & ~((uint4)dotdotdot)); }
1358 bool isOverride(
void)
const {
return ((flags&is_override)!=0); }
1359 void setOverride(
bool val) { flags = val ? (flags|is_override) : (flags & ~((uint4)is_override)); }
1361 vector<EffectRecord>::const_iterator
effectBegin(
void)
const;
1362 vector<EffectRecord>::const_iterator
effectEnd(
void)
const;
1417 AddrSpace *getSpacebase(
void)
const {
return model->getSpacebase(); }
1418 void printRaw(
const string &funcname,ostream &s)
const;
1424 uint4
getComparableFlags(
void)
const {
return (flags & (dotdotdot | is_constructor | is_destructor | has_thisptr )); }
1426 void saveXml(ostream &s)
const;
1454 int4 effective_extrapop;
1456 int4 stackPlaceholderSlot;
1458 int4 matchCallCount;
1461 mutable vector<int4> inputConsume;
1463 bool isoutputactive;
1464 bool isbadjumptable;
1465 Varnode *getSpacebaseRelative(
void)
const;
1469 bool transferLockedInput(vector<Varnode *> &newinput);
1470 bool transferLockedOutput(
Varnode *&newoutput);
1471 void commitNewInputs(
Funcdata &data,vector<Varnode *> &newinput);
1473 void collectOutputTrialVarnodes(vector<Varnode *> &trialvn);
1479 void setAddress(
const Address &addr) { entryaddress = addr; }
1480 PcodeOp *getOp(
void)
const {
return op; }
1481 Funcdata *getFuncdata(
void)
const {
return fd; }
1484 const string &getName(
void)
const {
return name; }
1485 const Address &getEntryAddress(
void)
const {
return entryaddress; }
1486 void setEffectiveExtraPop(int4 epop) { effective_extrapop = epop; }
1487 int4 getEffectiveExtraPop(
void)
const {
return effective_extrapop; }
1488 uintb getSpacebaseOffset(
void)
const {
return stackoffset; }
1489 void setParamshift(int4 val) { paramshift = val; }
1490 int4 getParamshift(
void)
const {
return paramshift; }
1491 int4 getMatchCallCount(
void)
const {
return matchCallCount; }
1492 int4 getStackPlaceholderSlot(
void)
const {
return stackPlaceholderSlot; }
1493 void setStackPlaceholderSlot(int4 slot) { stackPlaceholderSlot = slot;
1494 if (isinputactive) activeinput.setPlaceholderSlot(); }
1495 void clearStackPlaceholderSlot(
void) {
1499 void clearActiveInput(
void) { isinputactive =
false; }
1500 void initActiveOutput(
void) { isoutputactive =
true; }
1501 void clearActiveOutput(
void) { isoutputactive =
false; }
1502 bool isInputActive(
void)
const {
return isinputactive; }
1503 bool isOutputActive(
void)
const {
return isoutputactive; }
1504 void setBadJumpTable(
bool val) { isbadjumptable = val; }
1505 bool isBadJumpTable(
void)
const {
return isbadjumptable; }
1506 ParamActive *getActiveInput(
void) {
return &activeinput; }
1507 ParamActive *getActiveOutput(
void) {
return &activeoutput; }
1552 slot -= ((stackplaceholder<0)||(slot<stackplaceholder)) ? 1 : 2;
1562 if (address < op2.address)
return true;
1563 if (address != op2.address)
return false;
1564 return (type < op2.type);
1570 if (address != op2.address)
return false;
1571 return (type == op2.type);
1577 if (address != op2.address)
return true;
1578 return (type != op2.type);
bool lateRestriction(const FuncProto &restrictedProto, vector< Varnode * > &newinput, Varnode *&newoutput)
Update this prototype to match a given (more specialized) prototype.
Definition: fspec.cc:4535
Datatype * outtype
Return data-type.
Definition: fspec.hh:1147
@ hiddenretparm
Parameter is hidden pointer to return value, mirrors Varnode::hiddenretparm.
Definition: fspec.hh:296
@ typelock
Parameter's data-type is locked, mirrors Varnode::typelock.
Definition: fspec.hh:299
virtual void saveXml(ostream &s) const =0
Save any parameters that are not backed by symbols to an XML stream.
virtual const string & getName(void) const =0
Get the name of the parameter ("" for return value)
virtual void resetSizeLockType(TypeFactory *factory)
Clear this parameter's data-type preserving any size-lock.
Definition: fspec.cc:2324
virtual OpCode assumedExtension(const Address &addr, int4 size, VarnodeData &res) const =0
Get the type of extension and containing parameter for the given storage.
Exception thrown when a prototype can't be modeled properly.
Definition: fspec.hh:28
A collection parameter descriptions making up a function prototype.
Definition: fspec.hh:1010
int4 getMaxOutputDelay(void) const
Return the maximum heritage delay across all possible return values.
Definition: fspec.hh:839
virtual bool checkJoin(const Address &hiaddr, int4 hisize, const Address &loaddr, int4 losize) const
Check if the given two storage locations can represent a single logical parameter.
Definition: fspec.cc:887
static uint4 lookupEffect(const vector< EffectRecord > &efflist, const Address &addr, int4 size)
Look up an effect from the given EffectRecord list.
Definition: fspec.cc:1874
virtual void setTypeLock(bool val)
Toggle the lock on the data-type.
Definition: fspec.cc:2282
virtual void overrideSizeLockType(Datatype *ct)=0
Change (override) the data-type of a size-locked parameter.
bool possibleInputParam(const Address &loc, int4 size) const
Does the given storage location make sense as an input parameter.
Definition: fspec.hh:736
@ smallsize_inttype
Assume values that are below the max size are sign OR zero extended based on integer type.
Definition: fspec.hh:56
virtual ProtoStore * clone(void) const =0
Clone the entire collection of parameter descriptions.
ProtoModel * model
(Optional) model on which prototype is based
Definition: fspec.hh:1145
virtual ProtoParameter * setInput(int4 i, const string &nm, const ParameterPieces &pieces)=0
Establish name, data-type, storage of a specific input parameter.
@ smallsize_floatext
Assume values smaller than max size are floating-point extended to full size.
Definition: fspec.hh:57
ParamTrial(const Address &ad, int4 sz, int4 sl)
Construct from components.
Definition: fspec.hh:178
@ active
Trial looks active (hint that it is used)
Definition: fspec.hh:162
A register or memory register that may be used to pass a parameter or return value.
Definition: fspec.hh:156
void setFuncdata(Funcdata *f)
Set the Funcdata object associated with the called function.
Definition: fspec.cc:4108
void clearInput(void)
Clear all input parameters regardless of lock.
Definition: fspec.cc:3240
virtual bool isNameLocked(void) const =0
Is the parameter name locked.
virtual void clearInput(int4 i)=0
Clear the input parameter at the specified slot.
A region where processor data is stored.
Definition: space.hh:73
void assignParameterStorage(const vector< Datatype * > &typelist, vector< ParameterPieces > &res, bool ignoreOutputError)
Calculate input and output storage locations given a function prototype.
Definition: fspec.cc:1845
int4 nonfloatgroup
Group of first entry which is not marked float.
Definition: fspec.hh:504
AddrSpace * space
The address space.
Definition: pcoderaw.hh:34
Address getAddrBySlot(int4 &slot, int4 sz) const
Calculate the storage address assigned when allocating a parameter of a given size.
Definition: fspec.cc:257
@ unknown_effect
An unknown effect (indicates the absence of an EffectRecord)
Definition: fspec.hh:318
virtual void clearAllInputs(void)=0
Clear all input parameters (and any backing symbols)
A standard model for passing back return values from a function.
Definition: fspec.hh:548
virtual void setThisPointer(bool val)
Toggle whether this is the "this" pointer for a class method.
Definition: fspec.cc:2303
void saveXml(ostream &s) const
Save this to an XML stream as a <prototype> tag.
Definition: fspec.cc:3738
virtual void getRangeList(AddrSpace *spc, RangeList &res) const =0
For a given address space, collect all the parameter locations within that space.
void deriveInputMap(ParamActive *active) const
Given a list of input trials, derive the most likely input prototype.
Definition: fspec.hh:662
virtual int4 getNumInputs(void) const
Get the number of input parameters for this prototype.
Definition: fspec.cc:2706
void deriveOutputMap(ParamActive *active) const
Given a list of output trials, derive the most likely return value for this prototype.
Definition: fspec.hh:1317
virtual void setTypeLock(bool val)=0
Toggle the lock on the data-type.
The lowest level error generated by the decompiler.
Definition: error.hh:44
int4 numgroup
Number of groups in this parameter convention.
Definition: fspec.hh:500
const ParamTrial & getTrialForInputVarnode(int4 slot) const
Get trial corresponding to the given input Varnode.
Definition: fspec.hh:1549
ParamEntry(type_metatype t, int4 grp, int4 grpsize, const Address &loc, int4 sz, int4 mnsz, int4 align, bool normalstack)
Construct entry from components.
Definition: fspec.cc:38
ProtoStoreInternal(Datatype *vt)
Constructor.
Definition: fspec.cc:2646
virtual void overrideSizeLockType(Datatype *ct)
Change (override) the data-type of a size-locked parameter.
Definition: fspec.cc:2312
void setInputErrors(bool val)
Toggle the input error setting for this prototype.
Definition: fspec.hh:1286
virtual ProtoParameter * getInput(int4 i)
Get the i-th input parameter (or NULL if it doesn't exist)
Definition: fspec.cc:2585
bool paramshiftModifyStop(Funcdata &data)
Throw out any paramshift parameters.
Definition: fspec.cc:5016
virtual uint4 getType(void) const
Get the type of parameter list.
Definition: fspec.hh:591
void forceExclusionGroup(ParamActive *active) const
Enforce exclusion rules for the given set of parameter trials.
Definition: fspec.cc:711
virtual int4 getSize(void) const =0
Get the number of bytes occupied by this parameter.
A prototype model made by merging together other models.
Definition: fspec.hh:889
virtual void saveXml(ostream &s) const
Save any parameters that are not backed by symbols to an XML stream.
Definition: fspec.cc:2633
bool contains(const ParamEntry &op2) const
Does this contain the indicated entry.
Definition: fspec.cc:63
ProtoModel * selectModel(ParamActive *active) const
Select the best model given a set of trials.
Definition: fspec.cc:2237
void forceInactiveChain(ParamActive *active, int4 maxchain, int4 start, int4 stop) const
Enforce rules about chains of inactive slots.
Definition: fspec.cc:778
virtual Datatype * getType(void) const
Get the data-type associate with this.
Definition: fspec.cc:2345
@ checked
Trial has been checked.
Definition: fspec.hh:159
An unstructured model for passing input parameters to a function.
Definition: fspec.hh:568
int4 justifiedContain(const Address &addr, int4 sz) const
Calculate endian aware containment.
Definition: fspec.cc:94
virtual void assignMap(const vector< Datatype * > &proto, bool isinput, TypeFactory &typefactory, vector< ParameterPieces > &res) const
Given list of data-types, map the list positions to storage locations.
Definition: fspec.hh:592
A collection of parameter descriptions without backing symbols.
Definition: fspec.hh:1123
virtual bool checkJoin(const Address &hiaddr, int4 hisize, const Address &loaddr, int4 losize) const =0
Check if the given two storage locations can represent a single logical parameter.
virtual bool unjustifiedContainer(const Address &loc, int4 size, VarnodeData &res) const =0
Check if the given storage location looks like an unjustified parameter.
static void countMatchingCalls(const vector< FuncCallSpecs * > &qlst)
Calculate the number of times an individual sub-function is called.
Definition: fspec.cc:5055
int4 maxdelay
Maximum heritage delay across all parameters.
Definition: fspec.hh:501
void deriveOutputMap(ParamActive *active) const
Given a list of output trials, derive the most likely output prototype.
Definition: fspec.hh:669
virtual Symbol * getSymbol(void) const
Retrieve the formal Symbol associated with this parameter.
Definition: fspec.cc:2453
virtual void setThisPointer(bool val)=0
Toggle whether this is the "this" pointer for a class method.
virtual ProtoParameter * clone(void) const
Clone the parameter.
Definition: fspec.cc:2332
static FuncCallSpecs * getFspecFromConst(const Address &addr)
Convert FspecSpace addresses to the underlying FuncCallSpecs object.
Definition: fspec.hh:1533
A record describing how logical values are split.
Definition: translate.hh:195
void setOutputLock(bool val)
Toggle the data-type lock on the return value.
Definition: fspec.cc:3169
virtual int4 getMaxDelay(void) const
Return the maximum heritage delay across all possible parameters.
Definition: fspec.hh:536
void deriveInputMap(ParamActive *active) const
Given a list of input trials, derive the most likely inputs for this prototype.
Definition: fspec.hh:1310
ParamActive(bool recoversub)
Constructor an empty container.
Definition: fspec.cc:1382
virtual bool isHiddenReturn(void) const
Is this a pointer to storage for a return value.
Definition: fspec.hh:994
virtual ProtoParameter * getInput(int4 i)=0
Get the i-th input parameter (or NULL if it doesn't exist)
bool getContainer(const Address &addr, int4 sz, VarnodeData &res) const
Calculate the containing memory range.
Definition: fspec.cc:141
virtual int4 getNumInputs(void) const =0
Get the number of input parameters for this prototype.
@ smallsize_zext
Assume values that are below the max size are zero extended into this container.
Definition: fspec.hh:53
virtual void restoreXml(const Element *el)
Restore this model from an XML stream.
Definition: fspec.cc:2264
AddrSpace * spacebase
Address space containing relative offset parameters.
Definition: fspec.hh:507
void doInputJoin(int4 slot1, bool ishislot)
Join two parameter trials.
Definition: fspec.cc:4503
bool hasOutputErrors(void) const
Has this prototype been marked as having an incorrect return value description.
Definition: fspec.hh:1281
void saveXml(ostream &s) const
Save the record to an XML stream.
Definition: fspec.cc:1659
An interval map container.
Definition: rangemap.hh:64
void initActiveInput(void)
Turn on analysis recovering input parameters.
Definition: fspec.cc:4458
@ offset_unknown
"Magic" stack offset indicating the offset is unknown
Definition: fspec.hh:1476
void calcDelay(void)
Calculate the maximum heritage delay for any potential parameter in this list.
Definition: fspec.cc:823
InitData inittype
Initialization data for a ScopeMapper.
Definition: fspec.hh:131
void splitTrial(int4 i, int4 sz)
Split the given trial in two.
Definition: fspec.cc:1477
virtual bool isNameUndefined(void) const
Is the name of this parameter undefined.
Definition: fspec.hh:995
bool isInputLocked(void) const
Are input data-types locked.
Definition: fspec.cc:3133
A stand-alone parameter with no backing symbol.
Definition: fspec.hh:975
void copy(const FuncProto &op2)
Copy another function prototype.
Definition: fspec.cc:3009
void checkInputTrialUse(Funcdata &data, AliasChecker &aliascheck)
Mark if input trials are being actively used.
Definition: fspec.cc:4705
virtual ParamList * clone(void) const
Clone this parameter list model.
Definition: fspec.cc:1079
virtual AddrSpace * getSpacebase(void) const
Get the address space associated with any stack based parameters in this list.
Definition: fspec.hh:534
rangemap< ParamEntryRange > ParamEntryResolver
A map from offset to ParamEntry.
Definition: fspec.hh:140
virtual void setThisPointer(bool val)
Toggle whether this is the "this" pointer for a class method.
Definition: fspec.cc:2428
virtual Symbol * getSymbol(void) const
Retrieve the formal Symbol associated with this parameter.
Definition: fspec.hh:1002
virtual bool isIndirectStorage(void) const
Is this really a pointer to the true parameter.
Definition: fspec.hh:993
virtual ProtoParameter * clone(void) const
Clone the parameter.
Definition: fspec.cc:2447
@ indcreate_formed
The trial is built out of an indirect creation.
Definition: fspec.hh:166
virtual bool isTypeLocked(void) const
Is the parameter data-type locked.
Definition: fspec.hh:989
bool operator!=(const EffectRecord &op2) const
Inequality operator.
Definition: fspec.hh:1574
virtual void assignMap(const vector< Datatype * > &proto, bool isinput, TypeFactory &typefactory, vector< ParameterPieces > &res) const
Given list of data-types, map the list positions to storage locations.
Definition: fspec.cc:1086
int4 getInjectId(void) const
Get the injection id associated with this.
Definition: fspec.hh:1240
virtual void saveXml(ostream &s) const
Write the details of this space as XML.
Definition: fspec.cc:1613
ProtoModel(Architecture *g)
Constructor for use with restoreXml()
Definition: fspec.cc:1756
int4 characterizeAsInputParam(const Address &addr, int4 size) const
Decide whether a given storage location could be, or could hold, an input parameter.
Definition: fspec.cc:3502
A collection of Symbol objects within a single (namespace or functional) scope.
Definition: database.hh:402
virtual void setNameLock(bool val)=0
Toggle the lock on the name.
virtual bool isNameUndefined(void) const =0
Is the name of this parameter undefined.
OpCode assumedOutputExtension(const Address &addr, int4 size, VarnodeData &res) const
Get the type of extension and containing return value location for the given storage.
Definition: fspec.hh:1410
virtual void getRangeList(AddrSpace *spc, RangeList &res) const
For a given address space, collect all the parameter locations within that space.
Definition: fspec.cc:1011
void freePlaceholderSlot(void)
Free the stack placeholder slot.
Definition: fspec.cc:1439
A function parameter viewed as a name, data-type, and storage address.
Definition: fspec.hh:912
uintb getOffset(void) const
Get the address offset.
Definition: address.hh:300
virtual void resetSizeLockType(TypeFactory *factory)
Clear this parameter's data-type preserving any size-lock.
Definition: fspec.cc:2441
virtual void restoreXml(const Element *el)
Restore this model from an XML stream.
Definition: fspec.cc:1913
bool testShrink(const Address &newaddr, int4 sz) const
Test if this trial can be made smaller.
Definition: fspec.cc:1336
virtual int4 getSize(void) const
Get the number of bytes occupied by this parameter.
Definition: fspec.hh:988
int4 getMaxOutputDelay(void) const
Return the maximum heritage delay across all possible return values.
Definition: fspec.hh:1383
bool checkInputSplit(const Address &loc, int4 size, int4 splitpoint) const
Check if it makes sense to split a single storage location into two input parameters.
Definition: fspec.hh:1340
bool isConstructor(void) const
Is this prototype for a class constructor method.
Definition: fspec.hh:1262
virtual void assignMap(const vector< Datatype * > &proto, bool isinput, TypeFactory &typefactory, vector< ParameterPieces > &res) const =0
Given list of data-types, map the list positions to storage locations.
bool containedBy(const Address &addr, int4 sz) const
Is this entry contained by the given range.
Definition: fspec.cc:77
virtual void restoreXml(const Element *el, const AddrSpaceManager *manage, vector< EffectRecord > &effectlist, bool normalstack)=0
Restore the model from an XML stream.
virtual bool isThisPointer(void) const
Is this the "this" pointer for a class method.
Definition: fspec.hh:992
bool operator==(const ProtoParameter &op2) const
Compare storage location and data-type for equality.
Definition: fspec.hh:956
virtual int4 characterizeAsParam(const Address &loc, int4 size) const
Characterize whether the given range overlaps parameter storage.
Definition: fspec.cc:469
virtual Datatype * getType(void) const
Get the data-type associate with this.
Definition: fspec.hh:986
A class for analyzing parameters to a sub-function call.
Definition: fspec.hh:1449
void getPieces(PrototypePieces &pieces) const
Get the raw pieces of the prototype.
Definition: fspec.cc:3084
uint4 hasEffect(const Address &addr, int4 size) const
Determine side-effect of this on the given memory range.
Definition: fspec.cc:1905
static bool compareByEntryAddress(const FuncCallSpecs *a, const FuncCallSpecs *b)
Compare FuncCallSpecs by function entry address.
Definition: fspec.hh:1540
An XML element. A node in the DOM tree.
Definition: xml.hh:150
void deindirect(Funcdata &data, Funcdata *newfd)
Convert this call site from an indirect to a direct function call.
Definition: fspec.cc:4568
virtual Symbol * getSymbol(void) const =0
Retrieve the formal Symbol associated with this parameter.
virtual bool possibleParam(const Address &loc, int4 size) const =0
Does the given storage location make sense as a parameter.
virtual Datatype * getType(void) const =0
Get the data-type associate with this.
Lowest level operation of the p-code language.
Definition: op.hh:58
virtual ProtoParameter * getInput(int4 i)
Get the i-th input parameter (or NULL if it doesn't exist)
Definition: fspec.cc:2712
virtual void restoreXml(const Element *el, ProtoModel *model)
Restore any internal parameter descriptions from an XML stream.
Definition: fspec.cc:2639
Datatype * type
The datatype of the parameter.
Definition: fspec.hh:303
virtual void setNameLock(bool val)
Toggle the lock on the name.
Definition: fspec.cc:2418
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
void finalInputCheck(void)
Make final activity check on trials that might have been affected by conditional execution.
Definition: fspec.cc:4684
void setConstructor(bool val)
Toggle whether this prototype is a constructor method.
Definition: fspec.hh:1267
virtual uint4 getType(void) const =0
Get the type of parameter list.
@ p_standard_out
Standard output (return value) model.
Definition: fspec.hh:350
Address addr
Storage address of the parameter.
Definition: fspec.hh:302
bool operator<(const ParamTrial &b) const
Sort trials in formal parameter order.
Definition: fspec.cc:1358
A parameter with a formal backing Symbol.
Definition: fspec.hh:1067
virtual ParamList * clone(void) const
Clone this parameter list model.
Definition: fspec.cc:1221
FspecSpace(AddrSpaceManager *m, const Translate *t, const string &nm, int4 ind)
Constructor.
Definition: fspec.cc:1559
virtual ProtoParameter * setInput(int4 i, const string &nm, const ParameterPieces &pieces)
Establish name, data-type, storage of a specific input parameter.
Definition: fspec.cc:2669
bool checkInputJoin(const Address &hiaddr, int4 hisz, const Address &loaddr, int4 losz) const
Check if the given two input storage locations can represent a single logical parameter.
Definition: fspec.hh:1329
FuncProto(void)
Constructor.
Definition: fspec.cc:2998
vector< EffectRecord >::const_iterator effectEnd(void) const
Get iterator to end of EffectRecord list.
Definition: fspec.cc:3464
virtual bool isHiddenReturn(void) const =0
Is this a pointer to storage for a return value.
void paramshiftModifyStart(void)
Prepend any extra parameters if a paramshift is required.
Definition: fspec.cc:5006
void shrink(int4 i, const Address &addr, int4 sz)
Shrink the given trial to a new given range.
Definition: fspec.hh:269
bool setInputBytesConsumed(int4 slot, int4 val) const
Set the estimated number of bytes within the given parameter that are consumed.
Definition: fspec.cc:4994
virtual void fillinMap(ParamActive *active) const
Given an unordered list of storage locations, calculate a function prototype.
Definition: fspec.cc:1228
Description of the indirect effect a sub-function has on a memory range.
Definition: fspec.hh:312
virtual bool possibleParamWithSlot(const Address &loc, int4 size, int4 &slot, int4 &slotsize) const
Pass-back the slot and slot size for the given storage location as a parameter.
Definition: fspec.cc:932
void registerTrial(const Address &addr, int4 sz)
Add a new trial to the container.
Definition: fspec.cc:1407
A collection of parameter descriptions backed by Symbol information.
Definition: fspec.hh:1097
void clear(void)
Reset to an empty container.
Definition: fspec.cc:1394
A prototype model: a model for passing parameters between functions.
Definition: fspec.hh:622
virtual void clearOutput(void)=0
Clear the return value to TYPE_VOID.
void resolveExtraPop(void)
Assuming this prototype is locked, calculate the extrapop.
Definition: fspec.cc:3195
vector< string > innames
Identifiers for input types.
Definition: fspec.hh:1149
virtual bool unjustifiedContainer(const Address &loc, int4 size, VarnodeData &res) const
Check if the given storage location looks like an unjustified parameter.
Definition: fspec.cc:983
uint4 getComparableFlags(void) const
Get the comparable properties of this prototype.
Definition: fspec.hh:1424
virtual bool isTypeLocked(void) const =0
Is the parameter data-type locked.
OpCode assumedOutputExtension(const Address &addr, int4 size, VarnodeData &res) const
Get the type of extension and containing return value location for the given storage.
Definition: fspec.hh:807
virtual Address getAddress(void) const
Get the storage address for this parameter.
Definition: fspec.cc:2351
virtual int4 characterizeAsParam(const Address &loc, int4 size) const =0
Characterize whether the given range overlaps parameter storage.
bool testShrink(int4 i, const Address &addr, int4 sz) const
Test if the given trial can be shrunk to the given range.
Definition: fspec.hh:262
void extraChecks(list< ParamEntry > &entry)
Check if this entry represents a joined parameter and requires extra scrutiny.
Definition: fspec.cc:399
Class for storing ParamEntry objects in an interval range (rangemap)
Definition: fspec.hh:104
uintb offset
The offset within the space.
Definition: pcoderaw.hh:35
uint4 size
The number of bytes in the location.
Definition: pcoderaw.hh:36
virtual ProtoParameter * setOutput(const ParameterPieces &piece)
Establish the data-type and storage of the return value.
Definition: fspec.cc:2720
@ condexe_effect
This trial may be affected by conditional execution.
Definition: fspec.hh:167
string name
Identifier (function name) associated with prototype.
Definition: fspec.hh:1146
bool hasInputErrors(void) const
Has this prototype been marked as having an incorrect input parameter descriptions.
Definition: fspec.hh:1278
void setInternal(ProtoModel *m, Datatype *vt)
Set internal backing storage for this.
Definition: fspec.cc:3118
void cancelInjectId(void)
Turn-off any in-lining for this function.
Definition: fspec.cc:3247
ScoreProtoModel(bool isinput, const ProtoModel *mod, int4 numparam)
Constructor.
Definition: fspec.cc:2068
bool unjustifiedInputParam(const Address &addr, int4 size, VarnodeData &res) const
Check if the given storage location looks like an unjustified input parameter.
Definition: fspec.cc:3597
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
A disjoint set of Ranges, possibly across multiple address spaces.
Definition: address.hh:203
void foldIn(ProtoModel *model)
Fold-in an additional prototype model.
Definition: fspec.cc:2195
vector< ParamEntryResolver * > resolverMap
Map from space id to resolver.
Definition: fspec.hh:506
int4 getSlot(const Address &addr, int4 skip) const
Calculate the slot occupied by a specific address.
Definition: fspec.cc:231
@ reverse_stack
Slots (for non-exlusion entries) are allocated in reverse order.
Definition: fspec.hh:52
list< ParamEntry > entry
The ordered list of parameter entries.
Definition: fspec.hh:505
uint4 hasEffectTranslate(const Address &addr, int4 size) const
Calculate type of side-effect for a given storage location (with caller translation)
Definition: fspec.cc:5039
int4 getMaxInputDelay(void) const
Return the maximum heritage delay across all possible input parameters.
Definition: fspec.hh:831
Container class for ParamTrial objects.
Definition: fspec.hh:222
bool possibleInputParam(const Address &addr, int4 size) const
Decide whether a given storage location could be an input parameter.
Definition: fspec.cc:3537
virtual void clearOutput(void)
Clear the return value to TYPE_VOID.
Definition: fspec.cc:2605
bool operator!=(const ProtoParameter &op2) const
Compare storage location and data-type for inequality.
Definition: fspec.hh:966
SubsortPosition subsorttype
The sub-sort object for a rangemap.
Definition: fspec.hh:130
A union of other input parameter passing models.
Definition: fspec.hh:585
virtual bool isHiddenReturn(void) const
Is this a pointer to storage for a return value.
Definition: fspec.cc:2393
@ killedbycall
The memory is changed and is completely unrelated to its original value.
Definition: fspec.hh:316
void updateAllTypes(const vector< string > &namelist, const vector< Datatype * > &typelist, bool dtdtdt)
Set this entire function prototype based on a list of names and data-types.
Definition: fspec.cc:3407
Class for calculating "goodness of fit" of parameter trials against a prototype model.
Definition: fspec.hh:852
ParamListStandard(const ParamListStandard &op2)
Copy constructor.
Definition: fspec.cc:421
virtual void resetSizeLockType(TypeFactory *factory)=0
Clear this parameter's data-type preserving any size-lock.
void insertPcode(Funcdata &data)
Inject any upon-return p-code at this call site.
Definition: fspec.cc:4637
void setScope(Scope *s, const Address &startpoint)
Set a backing symbol Scope for this.
Definition: fspec.cc:3106
void updateInputTypes(Funcdata &data, const vector< Varnode * > &triallist, ParamActive *activeinput)
Update input parameters based on Varnode trials.
Definition: fspec.cc:3263
bool unjustifiedInputParam(const Address &loc, int4 size, VarnodeData &res) const
Check if the given storage location looks like an unjustified input parameter.
Definition: fspec.hh:781
@ p_register
Unordered parameter passing locations model.
Definition: fspec.hh:351
virtual bool checkSplit(const Address &loc, int4 size, int4 splitpoint) const =0
Check if it makes sense to split a single storage location into two parameters.
OpCode assumedInputExtension(const Address &addr, int4 size, VarnodeData &res) const
Get the type of extension and containing input parameter for the given storage.
Definition: fspec.hh:1397
virtual void clearInput(int4 i)
Clear the input parameter at the specified slot.
Definition: fspec.cc:2680
void paramShift(int4 paramshift)
Add parameters to the front of the input parameter list.
Definition: fspec.cc:2925
virtual bool isIndirectStorage(void) const
Is this really a pointer to the true parameter.
Definition: fspec.cc:2387
ParamTrial splitLo(int4 sz) const
Create a trial representing the last part of this.
Definition: fspec.cc:1321
void resolveModel(ParamActive *active)
If this has a merged model, pick the most likely model (from the merged set)
Definition: fspec.cc:2987
@ smallsize_sext
Assume values that are below the max size are sign extended into this container.
Definition: fspec.hh:54
void buildTrialMap(ParamActive *active) const
Build map from parameter trials to model ParamEntrys.
Definition: fspec.cc:586
uint4 hasEffect(const Address &addr, int4 size) const
Calculate the effect this has an a given storage location.
Definition: fspec.cc:3447
bool checkOutputJoin(const Address &hiaddr, int4 hisize, const Address &loaddr, int4 losize) const
Check if the given two output storage locations can represent a single logical return value.
Definition: fspec.hh:695
virtual void saveXmlAttributes(ostream &s, uintb offset) const
Save an address as XML.
Definition: fspec.cc:1567
int4 characterizeAsInputParam(const Address &loc, int4 size) const
Characterize whether the given range overlaps parameter storage.
Definition: fspec.hh:726
bool possibleInputParamWithSlot(const Address &loc, int4 size, int4 &slot, int4 &slotsize) const
Pass-back the slot and slot size for the given storage location as an input parameter.
Definition: fspec.hh:757
bool isCompatible(const ProtoModel *op2) const
Return true if other given model can be substituted for this.
Definition: fspec.cc:1820
virtual bool isSizeTypeLocked(void) const =0
Is the size of the parameter locked.
EffectRecord(const Address &addr, int4 size)
Construct a memory range with an unknown effect.
Definition: fspec.cc:1628
bool dotdotdot
True if prototype takes variable arguments.
Definition: fspec.hh:1150
int4 numLikelyTrash(void) const
Get the number of likely-trash locations.
Definition: fspec.cc:3473
bool operator==(const EffectRecord &op2) const
Equality operator.
Definition: fspec.hh:1567
void buildInputFromTrials(Funcdata &data)
Set the final input Varnodes to this CALL based on ParamActive analysis.
Definition: fspec.cc:4805
virtual bool isSizeTypeLocked(void) const
Is the size of the parameter locked.
Definition: fspec.hh:991
void printRaw(const string &funcname, ostream &s) const
Print this prototype as a single line of text.
Definition: fspec.cc:3709
const ParamEntry * findEntry(const Address &loc, int4 size) const
Given storage location find matching ParamEntry.
Definition: fspec.cc:448
ProtoStoreSymbol(Scope *sc, const Address &usepoint)
Constructor.
Definition: fspec.cc:2461
@ extracheck_high
Perform extra checks during parameter recovery on most sig portion of the double.
Definition: fspec.hh:58
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
vector< Datatype * > intypes
Input data-types.
Definition: fspec.hh:1148
int4 pointermax
If non-zero, maximum size of a data-type before converting to a pointer.
Definition: fspec.hh:502
void clearUnlockedInput(void)
Clear input parameters that have not been locked.
Definition: fspec.cc:3218
virtual int4 getMaxDelay(void) const =0
Return the maximum heritage delay across all possible parameters.
void setParamshiftApplied(bool val)
Toggle whether a parameter shift has been applied.
Definition: fspec.hh:1194
Basic elements of a parameter: address, data-type, properties.
Definition: fspec.hh:293
Raw components of a function prototype (obtained from parsing source code)
Definition: fspec.hh:1144
virtual void clearInput(int4 i)
Clear the input parameter at the specified slot.
Definition: fspec.cc:2556
int4 getNumUsed(void) const
Get number of trials marked as formal parameters.
Definition: fspec.cc:1541
virtual void restoreXml(const Element *el, const AddrSpaceManager *manage, vector< EffectRecord > &effectlist, bool normalstack)
Restore the model from an XML stream.
Definition: fspec.cc:1023
virtual bool possibleParam(const Address &loc, int4 size) const
Does the given storage location make sense as a parameter.
Definition: fspec.cc:926
virtual bool isNameLocked(void) const
Is the parameter name locked.
Definition: fspec.hh:990
void updateOutputNoTypes(const vector< Varnode * > &triallist, TypeFactory *factory)
Update the return value based on Varnode trials, but don't store the data-type.
Definition: fspec.cc:3383
Container for data structures associated with a single function.
Definition: funcdata.hh:45
The base datatype class for the decompiler.
Definition: type.hh:62
virtual void restoreXml(const Element *el, ProtoModel *model)=0
Restore any internal parameter descriptions from an XML stream.
bool possibleOutputParamWithSlot(const Address &loc, int4 size, int4 &slot, int4 &slotsize) const
Pass-back the slot and slot size for the given storage location as a return value.
Definition: fspec.hh:769
virtual uint4 getType(void) const
Get the type of parameter list.
Definition: fspec.hh:522
virtual uint4 getType(void) const
Get the type of parameter list.
Definition: fspec.hh:552
@ namelock
Parameter's name is locked, mirrors Varnode::namelock.
Definition: fspec.hh:298
Container class for all Datatype objects in an Architecture.
Definition: type.hh:396
LowlevelError(const string &s)
Initialize the error with an explanatory string.
Definition: error.hh:47
~FuncProto(void)
Destructor.
Definition: fspec.cc:3126
@ used
Trial is definitely used (final verdict)
Definition: fspec.hh:160
virtual void setNameLock(bool val)
Toggle the lock on the name.
Definition: fspec.cc:2294
A contiguous range of memory that can be used to pass parameters.
Definition: fspec.hh:48
@ extrapop_unknown
Reserved extrapop value meaning the function's extrapop is unknown.
Definition: fspec.hh:644
A special space for encoding FuncCallSpecs.
Definition: fspec.hh:282
void copyFlowEffects(const FuncProto &op2)
Copy properties that affect data-flow.
Definition: fspec.cc:3026
virtual bool isNameUndefined(void) const
Is the name of this parameter undefined.
Definition: fspec.cc:2399
virtual const string & getName(void) const
Get the name of the parameter ("" for return value)
Definition: fspec.cc:2339
void forceNoUse(ParamActive *active, int4 start, int4 stop) const
Mark every trial above the first "definitely not used" as inactive.
Definition: fspec.cc:739
void buildOutputFromTrials(Funcdata &data, vector< Varnode * > &trialvn)
Set the final output Varnode of this CALL based on ParamActive analysis of trials.
Definition: fspec.cc:4884
void setDestructor(bool val)
Toggle whether this prototype is a destructor method.
Definition: fspec.hh:1275
virtual ParamList * clone(void) const
Clone this parameter list model.
Definition: fspec.cc:1300
virtual void fillinMap(ParamActive *active) const =0
Given an unordered list of storage locations, calculate a function prototype.
virtual bool isTypeLocked(void) const
Is the parameter data-type locked.
Definition: fspec.cc:2363
The interface to a translation engine for a processor.
Definition: translate.hh:294
virtual Address getAddress(void) const
Get the storage address for this parameter.
Definition: fspec.hh:987
@ killedbycall
Data in this location is unlikely to flow thru a func and still be a param.
Definition: fspec.hh:164
void populateResolver(void)
Build the ParamEntry resolver maps.
Definition: fspec.cc:836
A standard model for parameters as an ordered list of storage resources.
Definition: fspec.hh:498
void doScore(void)
Compute the fitness score.
Definition: fspec.cc:2101
The PcodeOp and PcodeOpBank classes.
virtual void clearAllInputs(void)
Clear all input parameters (and any backing symbols)
Definition: fspec.cc:2696
void foldIn(const ParamListStandard &op2)
Add another model to the union.
Definition: fspec.cc:1259
bool hasThisPointer(void) const
Is this a prototype for a class method, taking a this pointer.
Definition: fspec.hh:1259
virtual int4 getNumInputs(void) const
Get the number of input parameters for this prototype.
Definition: fspec.cc:2579
virtual ParamList * clone(void) const
Clone this parameter list model.
Definition: fspec.cc:1248
OpCode
The op-code defining a specific p-code operation (PcodeOp)
Definition: opcodes.hh:35
bool possibleOutputParam(const Address &addr, int4 size) const
Decide whether a given storage location could be a return value.
Definition: fspec.cc:3569
void setInline(bool val)
Toggle the in-line setting for functions with this prototype.
Definition: fspec.hh:1234
virtual ProtoStore * clone(void) const
Clone the entire collection of parameter descriptions.
Definition: fspec.cc:2743
virtual bool isNameLocked(void) const
Is the parameter name locked.
Definition: fspec.cc:2369
virtual void fillinMap(ParamActive *active) const
Given an unordered list of storage locations, calculate a function prototype.
Definition: fspec.cc:1119
const VarnodeData & getLikelyTrash(int4 i) const
Get the i-th likely-trash location.
Definition: fspec.cc:3483
FuncCallSpecs(PcodeOp *call_op)
Construct based on CALL or CALLIND.
Definition: fspec.cc:4084
virtual uint4 getType(void) const
Get the type of parameter list.
Definition: fspec.hh:572
@ defnouse
Trial is definitely not used.
Definition: fspec.hh:161
OpCode assumedExtension(const Address &addr, int4 sz, VarnodeData &res) const
Calculate the type of extension to expect for the given logical value.
Definition: fspec.cc:190
virtual ProtoParameter * setOutput(const ParameterPieces &piece)
Establish the data-type and storage of the return value.
Definition: fspec.cc:2596
void updateInputNoTypes(Funcdata &data, const vector< Varnode * > &triallist, ParamActive *activeinput)
Update input parameters based on Varnode trials, but do not store the data-type.
Definition: fspec.cc:3308
virtual void clearAllInputs(void)
Clear all input parameters (and any backing symbols)
Definition: fspec.cc:2573
virtual ProtoParameter * setOutput(const ParameterPieces &piece)=0
Establish the data-type and storage of the return value.
virtual void fillinMap(ParamActive *active) const
Given an unordered list of storage locations, calculate a function prototype.
Definition: fspec.cc:864
void setModel(ProtoModel *m)
Set the prototype model for this.
Definition: fspec.cc:3038
bool isBigEndian(void) const
Return true if values in this space are big endian.
Definition: space.hh:417
bool getBiggestContainedInputParam(const Address &loc, int4 size, VarnodeData &res) const
Pass-back the biggest input parameter contained within the given range.
Definition: fspec.hh:816
uintb linetype
The linear element for a rangemap.
Definition: fspec.hh:129
bool checkInputSplit(const Address &loc, int4 size, int4 splitpoint) const
Check if it makes sense to split a single storage location into two input parameters.
Definition: fspec.hh:706
OpCode assumedInputExtension(const Address &addr, int4 size, VarnodeData &res) const
Get the type of extension and containing input parameter for the given storage.
Definition: fspec.hh:794
@ unaffected
The sub-function does not change the value at all.
Definition: fspec.hh:315
void updateOutputTypes(const vector< Varnode * > &triallist)
Update the return value based on Varnode trials.
Definition: fspec.cc:3347
virtual ProtoParameter * clone(void) const =0
Clone the parameter.
virtual void fillinMap(ParamActive *active) const
Given an unordered list of storage locations, calculate a function prototype.
Definition: fspec.hh:595
void setInputLock(bool val)
Toggle the data-type lock on input parameters.
Definition: fspec.cc:3148
virtual void clearOutput(void)
Clear the return value to TYPE_VOID.
Definition: fspec.cc:2729
void joinTrial(int4 slot, const Address &addr, int4 sz)
Join adjacent parameter trials.
Definition: fspec.cc:1507
@ indirectstorage
Parameter is indirect pointer to true parameter, mirrors Varnode::indirectstorage.
Definition: fspec.hh:297
void abortSpacebaseRelative(Funcdata &data)
Abort the attempt to recover the relative stack offset for this function.
Definition: fspec.cc:4074
@ force_left_justify
Big endian values are left justified within their slot.
Definition: fspec.hh:51
@ isthis
Parameter is "this" pointer.
Definition: fspec.hh:295
virtual void restoreXml(const Element *el, const AddrSpaceManager *manage, vector< EffectRecord > &effectlist, bool normalstack)
Restore the model from an XML stream.
Definition: fspec.cc:1211
virtual bool getBiggestContainedParam(const Address &loc, int4 size, VarnodeData &res) const =0
Pass-back the biggest parameter contained within the given range.
void forceSet(Funcdata &data, const FuncProto &fp)
Force a more restrictive prototype on this call site.
Definition: fspec.cc:4608
@ sizelock
Size of the parameter is locked (but not the data-type)
Definition: fspec.hh:300
vector< EffectRecord >::const_iterator effectBegin(void) const
Get iterator to front of EffectRecord list.
Definition: fspec.cc:3456
uint4 flags
additional attributes of the parameter
Definition: fspec.hh:304
virtual AddrSpace * getSpacebase(void) const =0
Get the address space associated with any stack based parameters in this list.
virtual ProtoStore * clone(void) const
Clone the entire collection of parameter descriptions.
Definition: fspec.cc:2620
virtual bool isSizeTypeLocked(void) const
Is the size of the parameter locked.
Definition: fspec.cc:2375
virtual int4 getSize(void) const
Get the number of bytes occupied by this parameter.
Definition: fspec.cc:2357
bool thisbeforeret
Does a this parameter come before a hidden return parameter.
Definition: fspec.hh:503
void setPieces(const PrototypePieces &pieces)
Set this prototype based on raw pieces.
Definition: fspec.cc:3062
virtual ProtoParameter * getOutput(void)
Get the return-value description.
Definition: fspec.cc:2737
FuncCallSpecs * clone(PcodeOp *newop) const
Clone this given the mirrored p-code CALL.
Definition: fspec.cc:4123
virtual void setTypeLock(bool val)
Toggle the lock on the data-type.
Definition: fspec.cc:2405
@ p_standard
Standard input parameter model.
Definition: fspec.hh:349
Data defining a specific memory location.
Definition: pcoderaw.hh:33
int4 getReturnBytesConsumed(void) const
Get an estimate of the number of bytes consumed by callers of this prototype.
Definition: fspec.hh:1246
void addParameter(const Address &addr, int4 sz)
Register a trial to be scored.
Definition: fspec.cc:2080
int4 whichTrial(const Address &addr, int4 sz) const
Get the trial overlapping with the given memory range.
Definition: fspec.cc:1426
virtual ~ProtoModel(void)
Destructor.
Definition: fspec.cc:1806
virtual bool isIndirectStorage(void) const =0
Is this really a pointer to the true parameter.
bool checkInputJoin(const Address &hiaddr, int4 hisize, const Address &loaddr, int4 losize) const
Check if the given two input storage locations can represent a single logical parameter.
Definition: fspec.hh:683
void separateFloat(ParamActive *active, int4 &floatstart, int4 &floatstop, int4 &start, int4 &stop) const
Calculate the range of floating-point entries within a given set of parameter trials.
Definition: fspec.cc:690
void clearUnlockedOutput(void)
Clear the return value if it has not been locked.
Definition: fspec.cc:3225
bool operator<(const EffectRecord &op2) const
Comparator for EffectRecords.
Definition: fspec.hh:1559
bool possibleOutputParam(const Address &loc, int4 size) const
Does the given storage location make sense as a return value.
Definition: fspec.hh:745
@ p_merged
A merged model (multiple models merged together)
Definition: fspec.hh:352
virtual ProtoParameter * setInput(int4 i, const string &nm, const ParameterPieces &pieces)
Establish name, data-type, storage of a specific input parameter.
Definition: fspec.cc:2505
A manager for different address spaces.
Definition: translate.hh:218
void resolveSpacebaseRelative(Funcdata &data, Varnode *phvn)
Calculate the stack offset of this call site.
Definition: fspec.cc:4033
int4 getInputBytesConsumed(int4 slot) const
Get the estimated number of bytes within the given parameter that are consumed.
Definition: fspec.cc:4977
virtual ParamList * clone(void) const =0
Clone this parameter list model.
virtual bool possibleParam(const Address &loc, int4 size) const
Does the given storage location make sense as a parameter.
Definition: fspec.cc:1200
void checkOutputTrialUse(Funcdata &data, vector< Varnode * > &trialvn)
Mark if output trials are being actively used.
Definition: fspec.cc:4781
void restoreXml(const Element *el, Architecture *glb)
Restore this from an XML stream.
Definition: fspec.cc:3837
A function prototype.
Definition: fspec.hh:1164
bool getBiggestContainedInputParam(const Address &loc, int4 size, VarnodeData &res) const
Pass-back the biggest potential input parameter contained within the given range.
Definition: fspec.cc:3632
virtual bool isThisPointer(void) const =0
Is this the "this" pointer for a class method.
static Varnode * findPreexistingWhole(Varnode *vn1, Varnode *vn2)
Check if given two Varnodes are merged into a whole.
Definition: fspec.cc:4864
void setModelLock(bool val)
Toggle the lock on the prototype model for this.
Definition: fspec.hh:1226
virtual ProtoParameter * getOutput(void)
Get the return-value description.
Definition: fspec.cc:2614
A light-weight class for analyzing pointers and aliasing on the stack.
Definition: varmap.hh:122
virtual bool getBiggestContainedParam(const Address &loc, int4 size, VarnodeData &res) const
Pass-back the biggest parameter contained within the given range.
Definition: fspec.cc:947
ParamTrial splitHi(int4 sz) const
Create a trial representing the first part of this.
Definition: fspec.cc:1310
type_metatype
Definition: type.hh:33
@ return_address
The memory is being used to pass back a return value from the sub-function.
Definition: fspec.hh:317
virtual void assignMap(const vector< Datatype * > &proto, bool isinput, TypeFactory &typefactory, vector< ParameterPieces > &res) const
Given list of data-types, map the list positions to storage locations.
Definition: fspec.cc:534
Address assignAddress(const Datatype *tp, vector< int4 > &status) const
Assign storage for given parameter data-type.
Definition: fspec.cc:510
virtual bool checkSplit(const Address &loc, int4 size, int4 splitpoint) const
Check if it makes sense to split a single storage location into two parameters.
Definition: fspec.cc:914
@ rem_formed
The trial is built out of a remainder operation.
Definition: fspec.hh:165
The base class for a symbol in a symbol table or scope.
Definition: database.hh:152
virtual Address getAddress(void) const =0
Get the storage address for this parameter.
@ unref
There is no direct reference to this parameter trial.
Definition: fspec.hh:163
virtual const string & getName(void) const
Get the name of the parameter ("" for return value)
Definition: fspec.hh:985
virtual ProtoParameter * getOutput(void)=0
Get the return-value description.
void setOutputErrors(bool val)
Toggle the output error setting for this prototype.
Definition: fspec.hh:1291
void deleteUnusedTrials(void)
Remove trials that were found not to be parameters.
Definition: fspec.cc:1457
void restoreXml(const Element *el, const AddrSpaceManager *manage, bool normalstack)
Restore the entry from an XML stream.
Definition: fspec.cc:302
virtual void restoreXml(const Element *el)
Recover the details of this space from XML.
Definition: fspec.cc:1619
bool checkInputJoin(int4 slot1, bool ishislot, Varnode *vn1, Varnode *vn2) const
Check if adjacent parameter trials can be combined into a single logical parameter.
Definition: fspec.cc:4476
virtual bool possibleParamWithSlot(const Address &loc, int4 size, int4 &slot, int4 &slotsize) const =0
Pass-back the slot and slot size for the given storage location as a parameter.
Templates to define interval map containers.
virtual void restoreXml(const Element *el, ProtoModel *model)
Restore any internal parameter descriptions from an XML stream.
Definition: fspec.cc:2801
@ extracheck_low
Perform extra checks during parameter recovery on least sig portion of the double.
Definition: fspec.hh:59
void setNoReturn(bool val)
Toggle the no-return setting for functions with this prototype.
Definition: fspec.hh:1256
virtual OpCode assumedExtension(const Address &addr, int4 size, VarnodeData &res) const
Get the type of extension and containing parameter for the given storage.
Definition: fspec.cc:998
virtual void saveXml(ostream &s) const
Save any parameters that are not backed by symbols to an XML stream.
Definition: fspec.cc:2761
virtual void printRaw(ostream &s, uintb offset) const
Write an address in this space to a stream.
Definition: fspec.cc:1600
bool isNoReturn(void) const
Does a function with this prototype never return.
Definition: fspec.hh:1251
virtual void overrideSizeLockType(Datatype *ct)
Change (override) the data-type of a size-locked parameter.
Definition: fspec.cc:2435
bool isDestructor(void) const
Is this prototype for a class destructor method.
Definition: fspec.hh:1270
bool setReturnBytesConsumed(int4 val)
Set the number of bytes consumed by callers of this.
Definition: fspec.cc:3181
int4 getMaxInputDelay(void) const
Return the maximum heritage delay across all possible input parameters.
Definition: fspec.hh:1375
void restoreXml(uint4 grouptype, const Element *el, const AddrSpaceManager *manage)
Restore the record from an XML stream.
Definition: fspec.cc:1673
bool isCompatible(const FuncProto &op2) const
Decide if this can be safely restricted to match another prototype.
Definition: fspec.cc:3668
virtual bool isThisPointer(void) const
Is this the "this" pointer for a class method.
Definition: fspec.cc:2381