diff options
| author | iximeow <me@iximeow.net> | 2019-07-20 10:21:22 -0700 | 
|---|---|---|
| committer | iximeow <me@iximeow.net> | 2020-01-12 16:10:13 -0800 | 
| commit | 5f1d1d7123ae613d5a18ca29247e81781568ca0e (patch) | |
| tree | 4fbd27bf09db48def0466b1e147955bbbfd142b0 | |
| parent | ae2dd6a1a39e58db83369f83b1dc46e1f3aa0b84 (diff) | |
begone, warnings
| -rw-r--r-- | src/display.rs | 2 | ||||
| -rw-r--r-- | src/lib.rs | 35 | ||||
| -rw-r--r-- | test/bench.rs | 18 | 
3 files changed, 20 insertions, 35 deletions
| diff --git a/src/display.rs b/src/display.rs index cbf3e61..9d4bc9f 100644 --- a/src/display.rs +++ b/src/display.rs @@ -289,7 +289,6 @@ impl fmt::Display for Opcode {              &Opcode::ENTER => write!(f, "{}", "enter"),              &Opcode::LEAVE => write!(f, "{}", "leave"),              &Opcode::MOV => write!(f, "{}", "mov"), -            &Opcode::MOVSD => write!(f, "{}", "movsd"),              &Opcode::RETURN => write!(f, "{}", "ret"),              &Opcode::PUSHF => write!(f, "{}", "pushf"),              &Opcode::WAIT => write!(f, "{}", "wait"), @@ -489,7 +488,6 @@ impl <T: std::fmt::Write> Colorize<T> for Opcode {              Opcode::MOVDDUP |              Opcode::MOVSLDUP |              Opcode::MOV | -            Opcode::MOVSD |              Opcode::CBW |              Opcode::CDW |              Opcode::LODS | @@ -146,6 +146,7 @@ impl RegSpec {  }  #[allow(non_camel_case_types)] +#[allow(dead_code)]  enum SizeCode {      b,      vd, @@ -762,7 +763,7 @@ const BITWISE_OPCODE_MAP: [Opcode; 8] = [      Opcode::SAL,      Opcode::SAR  ]; -fn read_opcode_660f_map<T: Iterator<Item=u8>>(bytes_iter: &mut T, instruction: &mut Instruction, prefixes: Prefixes, length: &mut u8) -> Result<OperandCode, String> { +fn read_opcode_660f_map<T: Iterator<Item=u8>>(_bytes_iter: &mut T, _instruction: &mut Instruction, _prefixes: Prefixes, _length: &mut u8) -> Result<OperandCode, String> {      Err("660f opcode map unsupported".to_string())  }  fn read_opcode_f20f_map<T: Iterator<Item=u8>>(bytes_iter: &mut T, instruction: &mut Instruction, prefixes: Prefixes, length: &mut u8) -> Result<OperandCode, String> { @@ -1952,11 +1953,13 @@ fn read_opcode<T: Iterator<Item=u8>>(bytes_iter: &mut T, instruction: &mut Instr  fn read_E<T: Iterator<Item=u8>>(bytes_iter: &mut T, prefixes: &Prefixes, m: u8, modbits: u8, width: u8, result: &mut Operand, length: &mut u8) -> Result<(), String> {      read_E_anybank(bytes_iter, prefixes, m, modbits, width, result, length, width_to_gp_reg_bank(width, prefixes.rex().present()))  } +#[allow(non_snake_case)]  fn read_E_xmm<T: Iterator<Item=u8>>(bytes_iter: &mut T, prefixes: &Prefixes, m: u8, modbits: u8, width: u8, result: &mut Operand, length: &mut u8) -> Result<(), String> {      read_E_anybank(bytes_iter, prefixes, m, modbits, width, result, length, RegisterBank::X)  } -fn read_E_anybank<T: Iterator<Item=u8>>(bytes_iter: &mut T, prefixes: &Prefixes, m: u8, modbits: u8, width: u8, result: &mut Operand, length: &mut u8, reg_bank: RegisterBank) -> Result<(), String> { +#[allow(non_snake_case)] +fn read_E_anybank<T: Iterator<Item=u8>>(bytes_iter: &mut T, prefixes: &Prefixes, m: u8, modbits: u8, _width: u8, result: &mut Operand, length: &mut u8, reg_bank: RegisterBank) -> Result<(), String> {      let addr_width = if prefixes.address_size() { 4 } else { 8 };      if modbits == 0b11 {          *result = Operand::Register(RegSpec::from_parts(m, prefixes.rex().b(), reg_bank)) @@ -2153,7 +2156,7 @@ fn read_operands<T: Iterator<Item=u8>>(              read_E(bytes_iter, &instruction.prefixes, m, mod_bits, opwidth, &mut instruction.operands[0], length)          },          OperandCode::AL_Ob => { -            let addr_width = if instruction.prefixes.address_size() { 4 } else { 8 }; +            let _addr_width = if instruction.prefixes.address_size() { 4 } else { 8 };              // stupid RCT thing:              let addr_width = if instruction.prefixes.address_size() { 2 } else { 4 };              let opwidth = 1; @@ -2169,7 +2172,7 @@ fn read_operands<T: Iterator<Item=u8>>(              Ok(())          }          OperandCode::AX_Ov => { -            let addr_width = if instruction.prefixes.address_size() { 4 } else { 8 }; +            let _addr_width = if instruction.prefixes.address_size() { 4 } else { 8 };              // stupid RCT thing:              let addr_width = if instruction.prefixes.address_size() { 2 } else { 4 };              let opwidth = imm_width_from_prefixes_64(SizeCode::vqp, &instruction.prefixes); @@ -2185,7 +2188,7 @@ fn read_operands<T: Iterator<Item=u8>>(              Ok(())          }          OperandCode::Ob_AL => { -            let addr_width = if instruction.prefixes.address_size() { 4 } else { 8 }; +            let _addr_width = if instruction.prefixes.address_size() { 4 } else { 8 };              // stupid RCT thing:              let addr_width = if instruction.prefixes.address_size() { 2 } else { 4 };              let opwidth = 1; @@ -2201,7 +2204,7 @@ fn read_operands<T: Iterator<Item=u8>>(              Ok(())          }          OperandCode::Ov_AX => { -            let addr_width = if instruction.prefixes.address_size() { 4 } else { 8 }; +            let _addr_width = if instruction.prefixes.address_size() { 4 } else { 8 };              // stupid RCT thing:              let addr_width = if instruction.prefixes.address_size() { 2 } else { 4 };              let opwidth = imm_width_from_prefixes_64(SizeCode::vqp, &instruction.prefixes); @@ -2796,26 +2799,6 @@ fn read_operands<T: Iterator<Item=u8>>(                  Err(reason) => Err(reason)              }          }, -        OperandCode::G_E_xmm => { -            let opwidth = 8; -            // TODO: ... -            let modrm = match bytes_iter.next() { -                Some(b) => b, -                None => return Err("Out of bytes".to_string()) -            }; -            *length += 1; -            let (mod_bits, r, m) = octets_of(modrm); - -//                println!("mod_bits: {:2b}, r: {:3b}, m: {:3b}", mod_bits, r, m); -            match read_E_xmm(bytes_iter, &instruction.prefixes, m, mod_bits, opwidth, &mut instruction.operands[1], length) { -                Ok(()) => { -                    instruction.operands[0] = -                        Operand::Register(RegSpec::from_parts(r, instruction.prefixes.rex().r(), RegisterBank::X)); -                    Ok(()) -                }, -                Err(reason) => Err(reason) -            } -        },          OperandCode::Zv_Ivq(opcode_byte) => {              let opwidth = imm_width_from_prefixes_64(SizeCode::vqp, &instruction.prefixes);              let reg_idx = opcode_byte & 0x7; diff --git a/test/bench.rs b/test/bench.rs index cb18e7c..1e4af91 100644 --- a/test/bench.rs +++ b/test/bench.rs @@ -3,13 +3,16 @@  extern crate test;  extern crate yaxpeax_x86; +#[cfg(feature = "capstone_bench")]  use std::ffi::c_void; +#[cfg(feature = "capstone_bench")]  use std::io::Write;  use test::Bencher; -use yaxpeax_x86::{Instruction, Opcode, decode_one}; +/* +use yaxpeax_x86::{Instruction, decode_one};  fn decode(bytes: &[u8]) -> Option<Instruction> {      let mut instr = Instruction::invalid(); @@ -18,11 +21,12 @@ fn decode(bytes: &[u8]) -> Option<Instruction> {          None => None      }  } +*/  #[bench]  fn bench_102000_instrs(b: &mut Bencher) {      b.iter(|| { -        for i in (0..3000) { +        for _i in 0..3000 {              test::black_box(do_decode_swathe());          }      }) @@ -42,7 +46,7 @@ fn bench_102000_intrs_capstone(b: &mut Bencher) {      })  } -const decode_data: [u8; 130] = [ +const DECODE_DATA: [u8; 130] = [      0x48, 0xc7, 0x04, 0x24, 0x00, 0x00, 0x00, 0x00,      0x48, 0x89, 0x44, 0x24, 0x08,      0x48, 0x89, 0x43, 0x18, @@ -80,8 +84,8 @@ const decode_data: [u8; 130] = [  ];  fn do_decode_swathe() { -    let mut buf = [0u8; 128]; -    let mut iter = decode_data.iter().map(|x| *x); +//    let mut buf = [0u8; 128]; +    let mut iter = DECODE_DATA.iter().map(|x| *x);      let mut result = yaxpeax_x86::Instruction::invalid();      loop {          match yaxpeax_x86::decode_one(&mut iter, &mut result) { @@ -134,8 +138,8 @@ fn get_instr(handle: usize) -> *mut c_void {  #[cfg(feature = "capstone_bench")]  fn do_capstone_decode_swathe(cs: usize, instr: *mut c_void) {      unsafe { -        let mut code = &decode_data as *const u8; -        let mut len = decode_data.len(); +        let mut code = &DECODE_DATA as *const u8; +        let mut len = DECODE_DATA.len();          let mut addr = 0u64;          loop {              let result = cs_disasm_iter( | 
