Procházet zdrojové kódy

Move arch code around

Gary Guo před 3 roky
rodič
revize
62878b5995

+ 14 - 1
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::*;

+ 4 - 0
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::*;

+ 0 - 11
src/arch/x86_64.rs → 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");

+ 1 - 0
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)]

+ 2 - 0
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;