(fuzzer: &mut Fuzzer)
| 28 | |
| 29 | impl StageData for HavocStage { |
| 30 | fn start(fuzzer: &mut Fuzzer) -> Result<Self, StageExit> { |
| 31 | fuzzer.copy_current_input(); |
| 32 | |
| 33 | let (Some(id), data) = (fuzzer.input_id, &fuzzer.state.input) |
| 34 | else { |
| 35 | return Err(StageExit::Unsupported); |
| 36 | }; |
| 37 | |
| 38 | let streams = get_non_empty_streams(data); |
| 39 | if streams.is_empty() { |
| 40 | // Must have at least one non-empty stream. |
| 41 | return Err(StageExit::Skip); |
| 42 | } |
| 43 | |
| 44 | let stream_distr = get_stream_weights(fuzzer, id, &streams); |
| 45 | let mutator = HavocMutator::new(); |
| 46 | let attempts = calculate_energy(fuzzer) as u32; |
| 47 | let log2_max_mutations = log2_max_mutations(fuzzer); |
| 48 | let max_mutations = max_mutations(fuzzer); |
| 49 | |
| 50 | fuzzer.corpus[id].metadata.havoc_rounds += 1; |
| 51 | |
| 52 | tracing::trace!( |
| 53 | "[{id}] havoc for {attempts} attempts with {} max mutations", |
| 54 | 2_u64.pow(log2_max_mutations) |
| 55 | ); |
| 56 | Ok(Self { |
| 57 | attempts, |
| 58 | streams, |
| 59 | stream_distr, |
| 60 | mutator, |
| 61 | log2_max_mutations, |
| 62 | max_mutations, |
| 63 | streams_to_extend: HashMap::new(), |
| 64 | saved: false, |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | fn fuzz_one(&mut self, fuzzer: &mut Fuzzer) -> Option<VmExit> { |
| 69 | self.attempts = self.attempts.checked_sub(1)?; |
nothing calls this directly
no test coverage detected