diff --git a/src/backtrace/dbghelp.rs b/src/backtrace/dbghelp.rs index 9d7427ce..c3d99b91 100644 --- a/src/backtrace/dbghelp.rs +++ b/src/backtrace/dbghelp.rs @@ -167,11 +167,21 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) { Some(StackWalkEx) => { let mut stack_frame_ex: STACKFRAME_EX = mem::zeroed(); stack_frame_ex.StackFrameSize = mem::size_of::() as DWORD; - stack_frame_ex.AddrPC.Offset = context.0.Eip as u64; + + cfg_if::cfg_if! { + if #[cfg(target_arch = "x86")] { + stack_frame_ex.AddrPC.Offset = context.0.Eip as u64; + stack_frame_ex.AddrStack.Offset = context.0.Esp as u64; + stack_frame_ex.AddrFrame.Offset = context.0.Ebp as u64; + } else { + stack_frame_ex.AddrPC.Offset = context.0.Pc as u64; + stack_frame_ex.AddrStack.Offset = context.0.Sp as u64; + stack_frame_ex.AddrFrame.Offset = context.0.R11 as u64; + } + } + stack_frame_ex.AddrPC.Mode = AddrModeFlat; - stack_frame_ex.AddrStack.Offset = context.0.Esp as u64; stack_frame_ex.AddrStack.Mode = AddrModeFlat; - stack_frame_ex.AddrFrame.Offset = context.0.Ebp as u64; stack_frame_ex.AddrFrame.Mode = AddrModeFlat; while StackWalkEx( @@ -205,11 +215,21 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) { } None => { let mut stack_frame64: STACKFRAME64 = mem::zeroed(); - stack_frame64.AddrPC.Offset = context.0.Eip as u64; + + cfg_if::cfg_if! { + if #[cfg(target_arch = "x86")] { + stack_frame64.AddrPC.Offset = context.0.Eip as u64; + stack_frame64.AddrStack.Offset = context.0.Esp as u64; + stack_frame64.AddrFrame.Offset = context.0.Ebp as u64; + } else { + stack_frame64.AddrPC.Offset = context.0.Pc as u64; + stack_frame64.AddrStack.Offset = context.0.Sp as u64; + stack_frame64.AddrFrame.Offset = context.0.R11 as u64; + } + } + stack_frame64.AddrPC.Mode = AddrModeFlat; - stack_frame64.AddrStack.Offset = context.0.Esp as u64; stack_frame64.AddrStack.Mode = AddrModeFlat; - stack_frame64.AddrFrame.Offset = context.0.Ebp as u64; stack_frame64.AddrFrame.Mode = AddrModeFlat; while dbghelp.StackWalk64()( diff --git a/src/lib.rs b/src/lib.rs index 7965d94b..c6ce4a92 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -194,7 +194,7 @@ mod lock { #[cfg(all( windows, - any(target_env = "msvc", all(target_env = "gnu", target_arch = "x86")), + any(target_env = "msvc", all(target_env = "gnu", any(target_arch = "x86", target_arch = "arm"))), not(target_vendor = "uwp") ))] mod dbghelp;