aboutsummaryrefslogtreecommitdiff
path: root/src/long_mode
diff options
context:
space:
mode:
author5225225 <5225225@mailbox.org>2021-12-19 20:34:52 +0000
committeriximeow <git@iximeow.net>2022-01-02 14:40:07 -0800
commitdd1e281c85cb047c6a4a05a4af0314e064cba088 (patch)
treef902946a28927a3d26c82229782306e2efa6308d /src/long_mode
parent8dda53be56b3ddd17ed72de6a6d2262a2ba82625 (diff)
Wrap unsafe functions to catch errors in debug
Closes https://github.com/iximeow/yaxpeax-x86/issues/16
Diffstat (limited to 'src/long_mode')
-rw-r--r--src/long_mode/display.rs5
-rw-r--r--src/long_mode/mod.rs2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/long_mode/display.rs b/src/long_mode/display.rs
index 35b9c1f..3295ae7 100644
--- a/src/long_mode/display.rs
+++ b/src/long_mode/display.rs
@@ -3,6 +3,7 @@ use core::fmt;
use yaxpeax_arch::{Colorize, ShowContextual, NoColors, YaxColors};
use yaxpeax_arch::display::*;
+use crate::safer_unchecked::GetSaferUnchecked as _;
use crate::MEM_SIZE_STRINGS;
use crate::long_mode::{RegSpec, Opcode, Operand, MergeMode, InstDecoder, Instruction, Segment, PrefixRex, OperandSpec};
@@ -127,7 +128,7 @@ const REG_NAMES: &[&'static str] = &[
];
pub(crate) fn regspec_label(spec: &RegSpec) -> &'static str {
- unsafe { REG_NAMES.get_unchecked((spec.num as u16 + ((spec.bank as u16) << 3)) as usize) }
+ unsafe { REG_NAMES.get_kinda_unchecked((spec.num as u16 + ((spec.bank as u16) << 3)) as usize) }
}
impl fmt::Display for RegSpec {
@@ -1810,7 +1811,7 @@ const MNEMONICS: &[&'static str] = &[
impl Opcode {
fn name(&self) -> &'static str {
unsafe {
- MNEMONICS.get_unchecked(*self as usize)
+ MNEMONICS.get_kinda_unchecked(*self as usize)
}
}
}
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs
index 44cf992..d2cb2f7 100644
--- a/src/long_mode/mod.rs
+++ b/src/long_mode/mod.rs
@@ -10,7 +10,7 @@ pub use crate::MemoryAccessSize;
pub use self::display::{DisplayStyle, InstructionDisplayer};
use core::cmp::PartialEq;
-use core::hint::unreachable_unchecked;
+use crate::safer_unchecked::unreachable_kinda_unchecked as unreachable_unchecked;
use yaxpeax_arch::{AddressDiff, Decoder, Reader, LengthedInstruction};
use yaxpeax_arch::annotation::{AnnotatingDecoder, DescriptionSink, NullSink};