[docs]defcondition_to_lambda(condition,default=False):""" Translates an integer, set, list or function into a lambda that checks if state's current basic block matches some condition. :param condition: An integer, set, list or lambda to convert to a lambda. :param default: The default return value of the lambda (in case condition is None). Default: false. :returns: A tuple of two items: a lambda that takes a state and returns the set of addresses that it matched from the condition, and a set that contains the normalized set of addresses to stop at, or None if no addresses were provided statically. """ifconditionisNone:defcondition_function(state):returndefaultstatic_addrs=set()elifisinstance(condition,int):returncondition_to_lambda((condition,))elifisinstance(condition,(tuple,set,list)):static_addrs=set(condition)defcondition_function(state):ifstate.addrinstatic_addrs:# returning {state.addr} instead of True to properly handle find/avoid conflictsreturn{state.addr}ifnotisinstance(state.project.factory.default_engine,engines.vex.VEXLifter):returnFalsetry:# If the address is not in the set (which could mean it is# not at the top of a block), check directly in the blocks# (Blocks are repeatedly created for every check, but with# the IRSB cache in angr lifter it should be OK.)returnstatic_addrs.intersection(set(state.block().instruction_addrs))except(AngrError,SimError):returnFalseelifhasattr(condition,"__call__"):condition_function=conditionstatic_addrs=Noneelse:raiseAngrExplorationTechniqueError("ExplorationTechnique is unable to convert given type (%s) to a callable condition function."%condition.__class__)returncondition_function,static_addrs