/// Select a call from `calls` based on specific priority.
///
/// # Panics
/// Panics if the input `calls` is empty.
Select a call from `calls` based on specific priority.
Select a call from ` calls ` based on specific priority .
pub fn select_call(ctx: &mut Context, rng: &mut RngType) -> Option<usize> {
    let mut prios = Vec::with_capacity(ctx.calls.len());
    let mut prio_sum = 0;
    let mut ret = None;
    for call in &ctx.calls {
        let mut prio = 0;
        foreach_call_arg(call, |val| {
            prio += val_prio(ctx.target, val);
        });
        prio_sum += prio;
        prios.push(prio_sum);
    }
    if prio_sum != 0 {
        let idx = choose_weighted(rng, &prios);
        let _syscall = ctx.target.syscall_of(ctx.calls[idx].sid());
        debug_info!(
            "select_call: prios: {:?}",
            prios.iter().enumerate().collect::<Vec<_>>()
        );
        debug_info!(
            "select_call: call-{} {} selected, prio: {}",
            idx,
            _syscall.name(),
            if idx == 0 {
                prios[idx]
            } else {
                prios[idx] - prios[idx - 1]
            }
        );
        ret = Some(idx);
    }
    ret
}
pub fn select_call ( ctx : & mut Context , rng : & mut RngType ) -> Option < usize > { let mut prios = Vec :: with_capacity ( ctx . calls . len ( ) ) ; let mut prio_sum = 0 ; let mut ret = None ; for call in & ctx . calls { let mut prio = 0 ; foreach_call_arg ( call , | val | { prio += val_prio ( ctx . target , val ) ; } ) ; prio_sum += prio ; prios . push ( prio_sum ) ; } if prio_sum != 0 { let idx = choose_weighted ( rng , & prios ) ; let _syscall = ctx . target . syscall_of ( ctx . calls [ idx ] . sid ( ) ) ; debug_info ! ( " " prios iter ( ) enumerate ( ) collect Vec ( ) ) ; debug_info ! ( " " idx _syscall name ( ) if idx 0 { prios [ idx ] } else { prios [ idx ] prios [ idx 1 ] } ) ; ret = Some ( idx ) ; } ret }
Select a call from `calls` based on specific priority.
Select a call from ` calls ` based on specific priority .
ctx
&mut Context
rng
&mut RngType
panics
Panics if the input `calls` is empty.
Panics if the input ` calls ` is empty .