[docs]classCodeLocation:""" Stands for a specific program point by specifying basic block address and statement ID (for IRSBs), or SimProcedure name (for SimProcedures). """__slots__=("block_addr","stmt_idx","sim_procedure","ins_addr","context","info","block_idx","_hash",)
[docs]def__init__(self,block_addr:int,stmt_idx:Optional[int],sim_procedure=None,ins_addr:Optional[int]=None,context:Any=None,block_idx:int=None,**kwargs,):""" Constructor. :param block_addr: Address of the block :param stmt_idx: Statement ID. None for SimProcedures or if the code location is meant to refer to the entire block. :param class sim_procedure: The corresponding SimProcedure class. :param ins_addr: The instruction address. :param context: A tuple that represents the context of this CodeLocation in contextful mode, or None in contextless mode. :param kwargs: Optional arguments, will be stored, but not used in __eq__ or __hash__. """self.block_addr:int=block_addrself.stmt_idx:Optional[int]=stmt_idxself.sim_procedure=sim_procedureself.ins_addr:Optional[int]=ins_addrself.context:Optional[Tuple[int]]=contextself.block_idx=block_idxself._hash=Noneself.info:Optional[Dict]=Noneifkwargs:self._store_kwargs(**kwargs)
def__repr__(self):ifself.block_addrisNone:return"<%s>"%self.sim_procedureifself.stmt_idxisNone:s="<{}{:#x}(-)".format(("%#x "%self.ins_addr)ifself.ins_addrelse"",self.block_addr,)else:s="<%s%#x[%d]"%(("%#x id="%self.ins_addr)ifself.ins_addrelse"",self.block_addr,self.stmt_idx,)ifself.contextisNone:s+=" contextless"else:s+=f" context: {self.context!r}"ss=[]ifself.info:fork,vinself.info.items():ifv!=()andvisnotNone:ss.append(f"{k}={v}")ifss:s+=" with %s"%", ".join(ss)s+=">"returns@propertydefshort_repr(self):ifself.ins_addrisnotNone:return"%#x"%self.ins_addrelse:returnrepr(self)def__eq__(self,other):""" Check if self is the same as other. """return(type(self)istype(other)andself.block_addr==other.block_addrandself.stmt_idx==other.stmt_idxandself.sim_procedureisother.sim_procedureandself.context==other.contextandself.block_idx==other.block_idxandself.ins_addr==other.ins_addr)def__lt__(self,other):ifself.block_addr!=other.block_addr:ifself.block_addrisNoneandother.block_addrisnotNone:returnTrueelifself.block_addrisnotNoneandother.block_addrisNone:returnFalse# elif self.block_addr is not None and other.block_addr is not None:returnself.block_addr<other.block_addrifself.stmt_idx!=other.stmt_idx:ifself.stmt_idxisNoneandother.stmt_idxisnotNone:returnTrueelifself.stmt_idxisnotNoneandother.stmt_idxisNone:returnFalse# elif self.stmt_idx is not None and other.stmt_idx is not Nonereturnself.stmt_idx<other.stmt_idxifself.ins_addrisnotNoneandother.ins_addrisnotNone:ifself.ins_addr!=other.ins_addr:returnself.ins_addr<other.ins_addrreturnFalsedef__hash__(self):""" returns the hash value of self. """ifself._hashisNone:self._hash=hash((self.block_addr,self.stmt_idx,self.sim_procedure,self.ins_addr,self.context,self.block_idx))returnself._hashdef_store_kwargs(self,**kwargs):ifself.infoisNone:self.info={}fork,vinkwargs.items():self.info[k]=v
[docs]classExternalCodeLocation(CodeLocation):""" Stands for a program point that originates from outside an analysis' scope. i.e. a value loaded from rdi in a callee where the caller has not been analyzed. """__slots__=("call_string",)
def__repr__(self):returnf"[External {[hex(x)ifisinstance(x,int)elsexforxinself.call_string]}]"def__hash__(self):""" returns the hash value of self. """ifself._hashisNone:self._hash=hash((self.call_string,))returnself._hash