From 2cfb2c7c52f23fa02443445046adb7a1a2c4a119 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 11 Jan 2020 15:07:59 -0800 Subject: be nicer about reaching incomplete parts of armv7 decoder --- src/armv7.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/armv7.rs b/src/armv7.rs index 06f1287..f85038f 100644 --- a/src/armv7.rs +++ b/src/armv7.rs @@ -5,7 +5,7 @@ use std::fmt::{self, Display, Formatter}; use yaxpeax_arch::{Arch, Colorize, Colored, ColorSettings, Decoder, LengthedInstruction, ShowContextual, YaxColors}; -struct ConditionedOpcode(pub Opcode, pub ConditionCode); +pub struct ConditionedOpcode(pub Opcode, pub ConditionCode); impl Display for ConditionedOpcode { fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> { @@ -413,7 +413,7 @@ pub enum ShiftSpec { Register(u8) } -#[derive(Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Operands { RegisterList(u16), OneOperand(u8), @@ -442,6 +442,7 @@ pub enum DecodeError { ExhaustedInput, InvalidOpcode, InvalidOperand, + Incomplete, } impl fmt::Display for DecodeError { @@ -450,6 +451,7 @@ impl fmt::Display for DecodeError { DecodeError::ExhaustedInput => write!(f, "exhausted input"), DecodeError::InvalidOpcode => write!(f, "invalid opcode"), DecodeError::InvalidOperand => write!(f, "invalid operand"), + DecodeError::Incomplete => write!(f, "incomplete decoder"), } } } @@ -953,10 +955,12 @@ impl Decoder for InstDecoder { inst.operands = Operands::ThreeOperandImm(Rn, Rd, imm); } _ => { - unreachable!(); + return Err(DecodeError::Incomplete); +// unreachable!(); } } - panic!("page a5-201"); + return Err(DecodeError::Incomplete); +// panic!("page a5-201"); } 0b10 => { // |c o n d|0 0 0 x|x x x x x x x x x x x x x x x x|1 1 0 1|x x x x| -- cgit v1.1