(self, state: 'angr.SimState', trace_curr_idx, state_desync_block_idx)
return (True, next_contain_index - trace_curr_idx)
Check if desync occurred because unicorn block was split into multiple blocks in qemu tracer. If yes, find the
        correct increment for trace index
Check if desync occurred because unicorn block was split into multiple blocks in qemu tracer. If yes, find the
        correct increment for trace index
Check if desync occurred because unicorn block was split into multiple blocks in qemu tracer . If yes find the correct increment for trace index
def _check_qemu_block_in_unicorn_block(self, state: 'angr.SimState', trace_curr_idx, state_desync_block_idx):
        """
        Check if desync occurred because unicorn block was split into multiple blocks in qemu tracer. If yes, find the
        correct increment for trace index
        """

        # We first find the block address where the trace and state's history match
        for trace_match_idx in range(trace_curr_idx - 1, -1, -1):
            if self._trace[trace_match_idx] == state.history.recent_bbl_addrs[state_desync_block_idx - 1]:
                break
        else:
            # Failed to find matching block address. qemu block is probably not contained in a previous block.
            return (False, -1)

        control_flow_insn_types = [CS_GRP_CALL, CS_GRP_IRET, CS_GRP_JUMP, CS_GRP_RET]
        big_block_start = self._trace[trace_match_idx]
        big_block_end = None
        curr_block_addr = big_block_start
        while True:
            curr_block = state.project.factory.block(self._translate_trace_addr(curr_block_addr))
            curr_block_last_insn = curr_block.capstone.insns[-1]
            if any((curr_block_last_insn.group(insn_type) for insn_type in control_flow_insn_types)):
                # Found last block
                big_block_end = curr_block.addr + curr_block.size - 1
                break

            curr_block_addr = curr_block.addr + curr_block.size

        for last_contain_index in range(trace_match_idx + 1, trace_curr_idx + 1):
            if self._trace[last_contain_index] <= big_block_start or self._trace[last_contain_index] > big_block_end:
                # This qemu block is not contained in the bigger block
                return (False, -1)

        # Check for future blocks in trace contained in big block
        for next_contain_index in range(trace_curr_idx + 1, len(self._trace)):
            if self._trace[next_contain_index] < big_block_start or self._trace[next_contain_index] > big_block_end:
                # This qemu block is not contained in bigger block
                break

        return (True, next_contain_index - trace_curr_idx)
def _check_qemu_block_in_unicorn_block ( self , state : 'angr.SimState' , trace_curr_idx , state_desync_block_idx ) : # We first find the block address where the trace and state's history match for trace_match_idx in range ( trace_curr_idx - 1 , - 1 , - 1 ) : if self . _trace [ trace_match_idx ] == state . history . recent_bbl_addrs [ state_desync_block_idx - 1 ] : break else : # Failed to find matching block address. qemu block is probably not contained in a previous block. return ( False , - 1 ) control_flow_insn_types = [ CS_GRP_CALL , CS_GRP_IRET , CS_GRP_JUMP , CS_GRP_RET ] big_block_start = self . _trace [ trace_match_idx ] big_block_end = None curr_block_addr = big_block_start while True : curr_block = state . project . factory . block ( self . _translate_trace_addr ( curr_block_addr ) ) curr_block_last_insn = curr_block . capstone . insns [ - 1 ] if any ( ( curr_block_last_insn . group ( insn_type ) for insn_type in control_flow_insn_types ) ) : # Found last block big_block_end = curr_block . addr + curr_block . size - 1 break curr_block_addr = curr_block . addr + curr_block . size for last_contain_index in range ( trace_match_idx + 1 , trace_curr_idx + 1 ) : if self . _trace [ last_contain_index ] <= big_block_start or self . _trace [ last_contain_index ] > big_block_end : # This qemu block is not contained in the bigger block return ( False , - 1 ) # Check for future blocks in trace contained in big block for next_contain_index in range ( trace_curr_idx + 1 , len ( self . _trace ) ) : if self . _trace [ next_contain_index ] < big_block_start or self . _trace [ next_contain_index ] > big_block_end : # This qemu block is not contained in bigger block break return ( True , next_contain_index - trace_curr_idx )