[docs]def__init__(self,man=None):SimStatePlugin.__init__(self)ifman:self._region_base=man._region_baseself._pos=man._posself._alloc_depth_map=man._alloc_depth_map.copy()else:self._region_base=None# It will be set later when self.state is setself._pos=0self._alloc_depth_map={}## Some constants## The size of each region, in bytesself._region_size=0x1000# The maximum allocation depthself._max_alloc_depth=20
[docs]defassign(self,dst_addr_ast):""" Assign a new region for under-constrained symbolic execution. :param dst_addr_ast: the symbolic AST which address of the new allocated region will be assigned to. :return: as ast of memory address that points to a new region """ifdst_addr_ast.uc_alloc_depth>self._max_alloc_depth:raiseSimUCManagerAllocationError("Current allocation depth %d is greater than the cap (%d)"%(dst_addr_ast.uc_alloc_depth,self._max_alloc_depth))abs_addr=self._region_base+self._posptr=self.state.solver.BVV(abs_addr,self.state.arch.bits)self._pos+=self._region_sizeself._alloc_depth_map[(abs_addr-self._region_base)//self._region_size]=dst_addr_ast.uc_alloc_depthl.debug("Assigned new memory region %s",ptr)returnptr
[docs]defis_bounded(self,ast):""" Test whether an AST is bounded by any existing constraint in the related solver. :param ast: an claripy.AST object :return: True if there is at least one related constraint, False otherwise """returnlen(ast.variables.intersection(self.state.solver._solver.variables))!=0