From 62878b59957291213cc349c5f6c320f1b6d5c965 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Thu, 26 Aug 2021 12:35:20 +0100 Subject: [PATCH] Move arch code around --- src/arch/mod.rs | 15 ++++++++++++++- src/unwinder/arch/mod.rs | 4 ++++ src/{ => unwinder}/arch/x86_64.rs | 11 ----------- src/unwinder/frame.rs | 1 + src/unwinder/mod.rs | 2 ++ 5 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 src/unwinder/arch/mod.rs rename src/{ => unwinder}/arch/x86_64.rs (92%) diff --git a/src/arch/mod.rs b/src/arch/mod.rs index 4bd2cbd..9a06e1c 100644 --- a/src/arch/mod.rs +++ b/src/arch/mod.rs @@ -1,4 +1,17 @@ #[cfg(target_arch = "x86_64")] -mod x86_64; +mod x86_64 { + use gimli::{Register, X86_64}; + + pub struct Arch; + + #[allow(unused)] + impl Arch { + pub const SP: Register = X86_64::RSP; + pub const RA: Register = X86_64::RA; + + pub const UNWIND_DATA_REG: (Register, Register) = (X86_64::RAX, X86_64::RDX); + pub const UNWIND_PRIVATE_DATA_SIZE: usize = 6; + } +} #[cfg(target_arch = "x86_64")] pub use x86_64::*; diff --git a/src/unwinder/arch/mod.rs b/src/unwinder/arch/mod.rs new file mode 100644 index 0000000..4bd2cbd --- /dev/null +++ b/src/unwinder/arch/mod.rs @@ -0,0 +1,4 @@ +#[cfg(target_arch = "x86_64")] +mod x86_64; +#[cfg(target_arch = "x86_64")] +pub use x86_64::*; diff --git a/src/arch/x86_64.rs b/src/unwinder/arch/x86_64.rs similarity index 92% rename from src/arch/x86_64.rs rename to src/unwinder/arch/x86_64.rs index 58dd9c4..207e926 100644 --- a/src/arch/x86_64.rs +++ b/src/unwinder/arch/x86_64.rs @@ -11,17 +11,6 @@ pub struct Context { pub fcw: usize, } -pub struct Arch; - -#[allow(unused)] -impl Arch { - pub const SP: Register = X86_64::RSP; - pub const RA: Register = X86_64::RA; - - pub const UNWIND_DATA_REG: (Register, Register) = (X86_64::RAX, X86_64::RDX); - pub const UNWIND_PRIVATE_DATA_SIZE: usize = 6; -} - impl fmt::Debug for Context { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut fmt = fmt.debug_struct("Context"); diff --git a/src/unwinder/frame.rs b/src/unwinder/frame.rs index 0061702..4a3f796 100644 --- a/src/unwinder/frame.rs +++ b/src/unwinder/frame.rs @@ -6,6 +6,7 @@ use gimli::{ use super::find_fde::{self, FDEFinder, FDESearchResult}; use crate::abi::PersonalityRoutine; use crate::arch::*; +use super::arch::*; use crate::util::*; #[derive(Debug)] diff --git a/src/unwinder/mod.rs b/src/unwinder/mod.rs index 92d4aac..b49450e 100644 --- a/src/unwinder/mod.rs +++ b/src/unwinder/mod.rs @@ -1,3 +1,4 @@ +mod arch; mod find_fde; mod frame; @@ -8,6 +9,7 @@ use gimli::Register; use crate::abi::*; use crate::arch::*; use crate::util::*; +use arch::*; use find_fde::FDEFinder; use frame::Frame;