Skip to content

Commit 0329af0

Browse files
committed
Fix build errors on thumbv7a-*-windows-msvc targets
Resolves: #572
1 parent e9da96e commit 0329af0

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/backtrace/dbghelp.rs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,21 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
167167
Some(StackWalkEx) => {
168168
let mut stack_frame_ex: STACKFRAME_EX = mem::zeroed();
169169
stack_frame_ex.StackFrameSize = mem::size_of::<STACKFRAME_EX>() as DWORD;
170-
stack_frame_ex.AddrPC.Offset = context.0.Eip as u64;
170+
171+
cfg_if::cfg_if! {
172+
if #[cfg(target_arch = "x86")] {
173+
stack_frame_ex.AddrPC.Offset = context.0.Eip as u64;
174+
stack_frame_ex.AddrStack.Offset = context.0.Esp as u64;
175+
stack_frame_ex.AddrFrame.Offset = context.0.Ebp as u64;
176+
} else {
177+
stack_frame_ex.AddrPC.Offset = context.0.Pc as u64;
178+
stack_frame_ex.AddrStack.Offset = context.0.Sp as u64;
179+
stack_frame_ex.AddrFrame.Offset = context.0.R11 as u64;
180+
}
181+
}
182+
171183
stack_frame_ex.AddrPC.Mode = AddrModeFlat;
172-
stack_frame_ex.AddrStack.Offset = context.0.Esp as u64;
173184
stack_frame_ex.AddrStack.Mode = AddrModeFlat;
174-
stack_frame_ex.AddrFrame.Offset = context.0.Ebp as u64;
175185
stack_frame_ex.AddrFrame.Mode = AddrModeFlat;
176186

177187
while StackWalkEx(
@@ -205,11 +215,21 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
205215
}
206216
None => {
207217
let mut stack_frame64: STACKFRAME64 = mem::zeroed();
208-
stack_frame64.AddrPC.Offset = context.0.Eip as u64;
218+
219+
cfg_if::cfg_if! {
220+
if #[cfg(target_arch = "x86")] {
221+
stack_frame64.AddrPC.Offset = context.0.Eip as u64;
222+
stack_frame64.AddrStack.Offset = context.0.Esp as u64;
223+
stack_frame64.AddrFrame.Offset = context.0.Ebp as u64;
224+
} else {
225+
stack_frame64.AddrPC.Offset = context.0.Pc as u64;
226+
stack_frame64.AddrStack.Offset = context.0.Sp as u64;
227+
stack_frame64.AddrFrame.Offset = context.0.R11 as u64;
228+
}
229+
}
230+
209231
stack_frame64.AddrPC.Mode = AddrModeFlat;
210-
stack_frame64.AddrStack.Offset = context.0.Esp as u64;
211232
stack_frame64.AddrStack.Mode = AddrModeFlat;
212-
stack_frame64.AddrFrame.Offset = context.0.Ebp as u64;
213233
stack_frame64.AddrFrame.Mode = AddrModeFlat;
214234

215235
while dbghelp.StackWalk64()(

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ mod lock {
194194

195195
#[cfg(all(
196196
windows,
197-
any(target_env = "msvc", all(target_env = "gnu", target_arch = "x86")),
197+
any(target_env = "msvc", all(target_env = "gnu", any(target_arch = "x86", target_arch = "arm"))),
198198
not(target_vendor = "uwp")
199199
))]
200200
mod dbghelp;

0 commit comments

Comments
 (0)