(
vm: &mut Vm,
cmplog: CmpLog2Ref,
path: &std::path::Path,
)
| 20 | const MAX_ONE_BYTE_REPLACEMENTS: usize = 16; |
| 21 | |
| 22 | pub fn log_cmplog_data( |
| 23 | vm: &mut Vm, |
| 24 | cmplog: CmpLog2Ref, |
| 25 | path: &std::path::Path, |
| 26 | ) -> anyhow::Result<()> { |
| 27 | use pcode::PcodeDisplay; |
| 28 | use std::io::Write; |
| 29 | |
| 30 | // @debugging: save CmpLog data |
| 31 | let mut log = std::io::BufWriter::new( |
| 32 | std::fs::File::create(path) |
| 33 | .with_context(|| format!("failed to create `{}.txt`", path.display()))?, |
| 34 | ); |
| 35 | for location in cmplog.get_inst_log(&mut vm.cpu).to_vec() { |
| 36 | writeln!(log, "{:#x}: {}", location.addr, location.op.display(&vm.cpu.arch.sleigh))?; |
| 37 | let (a_kind, b_kind) = analysis::analyse_comparisons(&location); |
| 38 | writeln!(log, "\t{a_kind:x?},{b_kind:x?}")?; |
| 39 | |
| 40 | for (a, b) in location.values { |
| 41 | writeln!(log, "\t{a:#x}, {b:#x}")?; |
| 42 | } |
| 43 | } |
| 44 | for location in cmplog.get_call_log(&mut vm.cpu) { |
| 45 | writeln!( |
| 46 | log, |
| 47 | "{:#x}, has_invalid={}, is_indirect={}", |
| 48 | location.addr, location.has_invalid, location.is_indirect |
| 49 | )?; |
| 50 | let (a_kind, b_kind) = analysis::analyse_call_parameters(location); |
| 51 | writeln!(log, "\t{a_kind:x?}\n\t{b_kind:x?}")?; |
| 52 | for (a, b) in &location.values { |
| 53 | writeln!(log, "\t{}, {}", a.escape_ascii(), b.escape_ascii())?; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | Ok(()) |
| 58 | } |
no test coverage detected