| 110 | } |
| 111 | |
| 112 | pub fn log(&mut self, fuzzer: &Fuzzer) { |
| 113 | let elapsed_time = self.last_report.elapsed(); |
| 114 | |
| 115 | let total_time = self.start_time.elapsed(); |
| 116 | let rate = |
| 117 | (self.total_executions - self.last_exec_count) as f64 / elapsed_time.as_secs_f64(); |
| 118 | |
| 119 | eprintln!( |
| 120 | "[{:6} s] {:6.1}k rate= {:5.0}/s {}:{:<4} crash= {:<6} ({} unq) hang= {:<3} ({} unq) cov= {:<5} ({:<4} TB) in= {:<3} ({} new) cycle= {} (find @{})", |
| 121 | total_time.as_secs(), |
| 122 | self.total_executions as f64 / 1000.0, |
| 123 | rate, |
| 124 | self.stage.short_name(), |
| 125 | self.input_id, |
| 126 | self.crashes, |
| 127 | fuzzer.global.crashes.lock().unwrap().len(), |
| 128 | self.timeouts, |
| 129 | fuzzer.global.hangs.lock().unwrap().len(), |
| 130 | fuzzer.coverage.count(), |
| 131 | fuzzer.seen_blocks.total_seen(), |
| 132 | fuzzer.corpus.inputs(), |
| 133 | fuzzer.queue.new_inputs(), |
| 134 | fuzzer.queue.cycles, |
| 135 | fuzzer.queue.found_input_at_cycle |
| 136 | ); |
| 137 | |
| 138 | if self.last_log_time.elapsed() > self.log_rate { |
| 139 | self.last_log_time = Instant::now(); |
| 140 | if let Ok(mut monitor_file) = std::fs::File::options() |
| 141 | .append(true) |
| 142 | .create(true) |
| 143 | .open(fuzzer.workdir.join("stats.csv")) |
| 144 | { |
| 145 | let _ = monitor_file.write_all( |
| 146 | format!( |
| 147 | "{},{},{},{},{},{},{},{},{},{},{},{}\n", |
| 148 | total_time.as_millis(), |
| 149 | self.total_executions, |
| 150 | self.crashes, |
| 151 | fuzzer.global.crashes.lock().unwrap().len(), |
| 152 | self.timeouts, |
| 153 | fuzzer.global.hangs.lock().unwrap().len(), |
| 154 | fuzzer.coverage.count(), |
| 155 | fuzzer.seen_blocks.total_seen(), |
| 156 | fuzzer.corpus.inputs(), |
| 157 | fuzzer.corpus.metadata.total_input_bytes, |
| 158 | fuzzer.corpus.metadata.total_instructions, |
| 159 | fuzzer.dict_items, |
| 160 | ) |
| 161 | .as_bytes(), |
| 162 | ); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | if self.last_dict_items != fuzzer.dict_items { |
| 167 | self.last_dict_items = fuzzer.dict_items; |
| 168 | let mut dict: Vec<(StreamKey, Vec<&DictionaryItem>)> = |
| 169 | fuzzer.dict.iter().map(|(addr, x)| (*addr, x.entries.values().collect())).collect(); |