aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2022-01-03 01:18:46 -0800
committeriximeow <me@iximeow.net>2022-01-03 01:18:46 -0800
commitc9a266cd62713f2ff7f5cf637adafd685ee17f16 (patch)
tree15c2e595fba67678e7448e7a2a2f98e9e6da3934 /src
parent32ee819325120425e75e801ae555b5be5591eb5e (diff)
name the fields in the auxiliary data for `print_instr`
Diffstat (limited to 'src')
-rw-r--r--src/main.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 8597aca..d834785 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -161,9 +161,15 @@ struct Printer {
verbose: bool,
}
+struct InstDetails<I: fmt::Display + fmt::Debug> {
+ pub inst_len: usize,
+ pub well_defined: bool,
+ pub inst: I,
+}
+
impl Printer {
// shared generic function to keep display logic consistent regardless of yaxpeax-arch version
- fn print_instr<I, E>(&self, rest: &[u8], addr: usize, x: Result<(usize, bool, I), E>)
+ fn print_instr<I, E>(&self, rest: &[u8], addr: usize, inst_res: Result<InstDetails<I>, E>)
where
I: fmt::Display + fmt::Debug,
E: fmt::Display,
@@ -171,8 +177,8 @@ impl Printer {
// TODO: lock stdout for the whole time? What if an arch implementation tries to log something?
let mut stdout = self.stdout.lock();
write!(stdout, "{:#010x}: ", addr).unwrap();
- match x {
- Ok((inst_len, well_defined, inst)) => {
+ match inst_res {
+ Ok(InstDetails { inst_len, well_defined, inst }) => {
writeln!(stdout, "{:14}: {}", hex::encode(&rest[..inst_len]), inst)
.unwrap();
if self.verbose {
@@ -230,11 +236,11 @@ mod arch_02 {
Err(_) => A::Instruction::min_size(),
};
let generic_res = res.map(|inst| {
- (
- A::Address::zero().wrapping_offset(inst.len()).to_linear(),
- inst.well_defined(),
+ crate::InstDetails {
+ inst_len: A::Address::zero().wrapping_offset(inst.len()).to_linear(),
+ well_defined: inst.well_defined(),
inst,
- )
+ }
});
printer.print_instr(rest, addr.to_linear(), generic_res);
addr += advance_addr;