(self, job)
Some code executed before actually processing the job.

        :param VFGJob job: the VFGJob object.
        :return: None
Some code executed before actually processing the job.
Some code executed before actually processing the job .
def _pre_job_handling(self, job):
        """
        Some code executed before actually processing the job.

        :param VFGJob job: the VFGJob object.
        :return: None
        """

        # did we reach the final address?
        if self._final_address is not None and job.addr == self._final_address:
            # our analysis should be termianted here
            l.debug("%s is viewed as a final state. Skip.", job)
            raise AngrSkipJobNotice()

        l.debug("Handling VFGJob %s", job)

        if not self._top_task:
            l.debug("No more tasks available. Skip the job.")
            raise AngrSkipJobNotice()

        assert isinstance(self._top_task, FunctionAnalysis)

        if job not in self._top_task.jobs:
            # it seems that all jobs of the top task has been done. unwind the task stack
            # make sure this job is at least recorded somewhere
            unwind_count = None
            for i, task in enumerate(reversed(self._task_stack)):
                if isinstance(task, FunctionAnalysis):
                    if job in task.jobs:
                        # nice
                        unwind_count = i

            if unwind_count is None:
                l.debug("%s is not recorded. Skip the job.", job)
                raise AngrSkipJobNotice()
            else:
                # unwind the stack till the target, unless we see any pending jobs for each new top task
                for i in range(unwind_count):
                    if isinstance(self._top_task, FunctionAnalysis):
                        # are there any pending job belonging to the current function that we should handle first?
                        pending_job_key = self._get_pending_job(self._top_task.function_address)
                        if pending_job_key is not None:
                            # ah there is
                            # analyze it first
                            self._trace_pending_job(pending_job_key)
                            l.debug("A pending job is found for function %#x. Delay %s.",
                                    self._top_task.function_address, job)
                            raise AngrDelayJobNotice()

                    task = self._task_stack.pop()

                    if not task.done:
                        l.warning("Removing an unfinished task %s. Might be a bug.", task)

                assert job in self._top_task.jobs

        # check if this is considered to be a final state
        if self._final_state_callback is not None and self._final_state_callback(job.state, job.call_stack):
            l.debug("%s.state is considered as a final state. Skip the job.", job)
            self.final_states.append(job.state)
            raise AngrSkipJobNotice()

        # increment the execution counter
        self._execution_counter[job.addr] += 1

        self._top_task.jobs.remove(job)

        # set up some essential variables and parameters
        job.call_stack_suffix = job.get_call_stack_suffix()
        job.jumpkind = 'Ijk_Boring' if job.state.history.jumpkind is None else \
            job.state.history.jumpkind

        src_block_id = job.src_block_id
        src_exit_stmt_idx = job.src_exit_stmt_idx

        addr = job.state.solver.eval(job.state.regs.ip)
        input_state = job.state
        block_id = BlockID.new(addr, job.call_stack_suffix, job.jumpkind)

        if self._tracing_times[block_id] > self._max_iterations:
            l.debug('%s has been traced too many times. Skip', job)
            raise AngrSkipJobNotice()

        self._tracing_times[block_id] += 1

        if block_id not in self._nodes:
            vfg_node = VFGNode(addr, block_id, state=input_state)
            self._nodes[block_id] = vfg_node

        else:
            vfg_node = self._nodes[block_id]

        job.vfg_node = vfg_node
        # log the current state
        vfg_node.state = input_state

        # Execute this basic block with input state, and get a new SimSuccessors instance
        # unused result var is `error_occured`
        job.sim_successors, _, restart_analysis = self._get_simsuccessors(input_state, addr)

        if restart_analysis:
            # We should restart the analysis because of something must be changed in the very initial state
            raise AngrVFGRestartAnalysisNotice()

        if job.sim_successors is None:
            # Ouch, we cannot get the SimSuccessors for some reason
            # Skip this guy
            l.debug('Cannot create SimSuccessors for %s. Skip.', job)
            raise AngrSkipJobNotice()

        self._graph_add_edge(src_block_id,
                             block_id,
                             jumpkind=job.jumpkind,
                             src_exit_stmt_idx=src_exit_stmt_idx
                             )
def _pre_job_handling ( self , job ) : # did we reach the final address? if self . _final_address is not None and job . addr == self . _final_address : # our analysis should be termianted here l . debug ( "%s is viewed as a final state. Skip." , job ) raise AngrSkipJobNotice ( ) l . debug ( "Handling VFGJob %s" , job ) if not self . _top_task : l . debug ( "No more tasks available. Skip the job." ) raise AngrSkipJobNotice ( ) assert isinstance ( self . _top_task , FunctionAnalysis ) if job not in self . _top_task . jobs : # it seems that all jobs of the top task has been done. unwind the task stack # make sure this job is at least recorded somewhere unwind_count = None for i , task in enumerate ( reversed ( self . _task_stack ) ) : if isinstance ( task , FunctionAnalysis ) : if job in task . jobs : # nice unwind_count = i if unwind_count is None : l . debug ( "%s is not recorded. Skip the job." , job ) raise AngrSkipJobNotice ( ) else : # unwind the stack till the target, unless we see any pending jobs for each new top task for i in range ( unwind_count ) : if isinstance ( self . _top_task , FunctionAnalysis ) : # are there any pending job belonging to the current function that we should handle first? pending_job_key = self . _get_pending_job ( self . _top_task . function_address ) if pending_job_key is not None : # ah there is # analyze it first self . _trace_pending_job ( pending_job_key ) l . debug ( "A pending job is found for function %#x. Delay %s." , self . _top_task . function_address , job ) raise AngrDelayJobNotice ( ) task = self . _task_stack . pop ( ) if not task . done : l . warning ( "Removing an unfinished task %s. Might be a bug." , task ) assert job in self . _top_task . jobs # check if this is considered to be a final state if self . _final_state_callback is not None and self . _final_state_callback ( job . state , job . call_stack ) : l . debug ( "%s.state is considered as a final state. Skip the job." , job ) self . final_states . append ( job . state ) raise AngrSkipJobNotice ( ) # increment the execution counter self . _execution_counter [ job . addr ] += 1 self . _top_task . jobs . remove ( job ) # set up some essential variables and parameters job . call_stack_suffix = job . get_call_stack_suffix ( ) job . jumpkind = 'Ijk_Boring' if job . state . history . jumpkind is None else job . state . history . jumpkind src_block_id = job . src_block_id src_exit_stmt_idx = job . src_exit_stmt_idx addr = job . state . solver . eval ( job . state . regs . ip ) input_state = job . state block_id = BlockID . new ( addr , job . call_stack_suffix , job . jumpkind ) if self . _tracing_times [ block_id ] > self . _max_iterations : l . debug ( '%s has been traced too many times. Skip' , job ) raise AngrSkipJobNotice ( ) self . _tracing_times [ block_id ] += 1 if block_id not in self . _nodes : vfg_node = VFGNode ( addr , block_id , state = input_state ) self . _nodes [ block_id ] = vfg_node else : vfg_node = self . _nodes [ block_id ] job . vfg_node = vfg_node # log the current state vfg_node . state = input_state # Execute this basic block with input state, and get a new SimSuccessors instance # unused result var is `error_occured` job . sim_successors , _ , restart_analysis = self . _get_simsuccessors ( input_state , addr ) if restart_analysis : # We should restart the analysis because of something must be changed in the very initial state raise AngrVFGRestartAnalysisNotice ( ) if job . sim_successors is None : # Ouch, we cannot get the SimSuccessors for some reason # Skip this guy l . debug ( 'Cannot create SimSuccessors for %s. Skip.' , job ) raise AngrSkipJobNotice ( ) self . _graph_add_edge ( src_block_id , block_id , jumpkind = job . jumpkind , src_exit_stmt_idx = src_exit_stmt_idx )