Skip to content

Commit 61a0380

Browse files
committed
Update cfg for x86/arm and fix image param
1 parent c1464fa commit 61a0380

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/backtrace/dbghelp.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
133133
}
134134
}
135135

136-
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
136+
#[cfg(any(target_arch = "x86", target_arch = "arm"))]
137137
#[inline(always)]
138138
pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
139139
use core::mem;
@@ -156,6 +156,11 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
156156

157157
let process_handle = GetCurrentProcess();
158158

159+
#[cfg(target_arch = "x86")]
160+
let image = IMAGE_FILE_MACHINE_I386;
161+
#[cfg(target_arch = "arm")]
162+
let image = IMAGE_FILE_MACHINE_ARMNT;
163+
159164
// Attempt to use `StackWalkEx` if we can, but fall back to `StackWalk64`
160165
// since it's in theory supported on more systems.
161166
match (*dbghelp.dbghelp()).StackWalkEx() {
@@ -170,7 +175,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
170175
stack_frame_ex.AddrFrame.Mode = AddrModeFlat;
171176

172177
while StackWalkEx(
173-
IMAGE_FILE_MACHINE_I386 as DWORD,
178+
image as DWORD,
174179
process,
175180
thread,
176181
&mut stack_frame_ex,
@@ -208,7 +213,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
208213
stack_frame64.AddrFrame.Mode = AddrModeFlat;
209214

210215
while dbghelp.StackWalk64()(
211-
IMAGE_FILE_MACHINE_I386 as DWORD,
216+
image as DWORD,
212217
process,
213218
thread,
214219
&mut stack_frame64,

0 commit comments

Comments
 (0)