fix fuzz and rand crates
This commit is contained in:
parent
f04c68578b
commit
756e23f240
|
@ -27,6 +27,7 @@ impl FormattedIns {
|
|||
Self::fmt_field(field, f)?;
|
||||
if writing_offset {
|
||||
write!(f, ")")?;
|
||||
writing_offset = false;
|
||||
}
|
||||
if i != fields.len() - 1 {
|
||||
write!(f, ", ")?;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use std::io::Write;
|
||||
use std::ops::Range;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use ppc750cl::formatter::SimpleFormatter;
|
||||
use ppc750cl::formatter::FormattedIns;
|
||||
use ppc750cl::Ins;
|
||||
use std::ops::Range;
|
||||
|
||||
fn main() {
|
||||
let start = Instant::now();
|
||||
|
@ -62,7 +63,6 @@ impl MultiFuzzer {
|
|||
// for most of the time.
|
||||
handle.join().expect("thread panicked");
|
||||
}
|
||||
disasm(0xFFFF_FFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,11 +81,14 @@ impl Fuzzer {
|
|||
}
|
||||
|
||||
fn dispatch(&self) -> std::thread::JoinHandle<()> {
|
||||
let mut devnull = DevNull;
|
||||
|
||||
let counter = Arc::clone(&self.counter);
|
||||
let range = self.range.clone();
|
||||
std::thread::spawn(move || {
|
||||
for x in range.clone() {
|
||||
disasm(x);
|
||||
let ins = Ins::new(x, 0x8000_0000);
|
||||
writeln!(&mut devnull, "{}", FormattedIns(ins)).unwrap();
|
||||
if x % (1 << 19) == 0 {
|
||||
counter.store(x, Ordering::Relaxed);
|
||||
}
|
||||
|
@ -95,13 +98,6 @@ impl Fuzzer {
|
|||
}
|
||||
}
|
||||
|
||||
fn disasm(x: u32) {
|
||||
let devnull = DevNull;
|
||||
let mut formatter = SimpleFormatter { writer: devnull };
|
||||
let ins = Ins::new(x, 0x8000_0000u32);
|
||||
ins.write_string(&mut formatter).unwrap();
|
||||
}
|
||||
|
||||
struct DevNull;
|
||||
|
||||
impl std::io::Write for DevNull {
|
||||
|
|
|
@ -1,26 +1,16 @@
|
|||
use rand_core::{RngCore, SeedableRng};
|
||||
use sfmt::SFMT;
|
||||
|
||||
use ppc750cl::formatter::SimpleFormatter;
|
||||
use ppc750cl::formatter::FormattedIns;
|
||||
use ppc750cl::{Ins, Opcode};
|
||||
use std::io::{BufWriter, Write};
|
||||
|
||||
fn main() {
|
||||
let mut rng = SFMT::seed_from_u64(42);
|
||||
let stdout = std::io::stdout();
|
||||
let stdout_lock = stdout.lock();
|
||||
let stream = BufWriter::with_capacity(1_000_000, stdout_lock);
|
||||
let mut formatter = SimpleFormatter { writer: stream };
|
||||
loop {
|
||||
let ins = Ins::new(rng.next_u32(), 0);
|
||||
if ins.op == Opcode::Illegal {
|
||||
continue;
|
||||
}
|
||||
if ins.write_string(&mut formatter).is_err() {
|
||||
return;
|
||||
}
|
||||
if formatter.writer.write_all("\n".as_ref()).is_err() {
|
||||
return;
|
||||
}
|
||||
println!("{}", FormattedIns(ins));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue