Skip to content

Commit 48a0058

Browse files
committed
fix: enable trace_thread_unsynchronized only on windows and noop
1 parent 68e1927 commit 48a0058

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/backtrace/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use core::ffi::c_void;
22
use core::fmt;
33

4-
use self::dbghelp::trace_thread;
5-
64
/// Inspects the current call-stack, passing all active frames into the closure
75
/// provided to calculate a stack trace.
86
///
@@ -79,11 +77,12 @@ pub unsafe fn trace_unsynchronized<F: FnMut(&Frame) -> bool>(mut cb: F) {
7977
/// # Panics
8078
///
8179
/// See information on `trace` for caveats on `cb` panicking.
80+
#[cfg(all(windows, not(target_vendor = "uwp")))]
8281
pub unsafe fn trace_thread_unsynchronized<F: FnMut(&Frame) -> bool>(
8382
thread: *mut c_void,
8483
mut cb: F,
8584
) {
86-
trace_thread(&mut cb, thread)
85+
trace_thread_imp(&mut cb, thread)
8786
}
8887

8988
/// A trait representing one frame of a backtrace, yielded to the `trace`
@@ -171,12 +170,15 @@ cfg_if::cfg_if! {
171170
} else if #[cfg(all(windows, not(target_vendor = "uwp")))] {
172171
mod dbghelp;
173172
use self::dbghelp::trace as trace_imp;
173+
use self::dbghelp::trace_thread as trace_thread_imp;
174174
pub(crate) use self::dbghelp::Frame as FrameImp;
175175
#[cfg(target_env = "msvc")] // only used in dbghelp symbolize
176176
pub(crate) use self::dbghelp::StackFrame;
177177
} else {
178178
mod noop;
179179
use self::noop::trace as trace_imp;
180+
use self::noop::trace_thread as trace_thread_imp;
181+
use self::noop::trace_thread_unsynchronized;
180182
pub(crate) use self::noop::Frame as FrameImp;
181183
}
182184
}

src/backtrace/noop.rs

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ use core::ffi::c_void;
66
#[inline(always)]
77
pub fn trace(_cb: &mut dyn FnMut(&super::Frame) -> bool) {}
88

9+
#[inline(always)]
10+
pub fn trace_thread(cb: &mut dyn FnMut(&super::Frame) -> bool, thread: *mut c_void) {}
11+
12+
pub fn trace_thread_unsynchronized<F: FnMut(&Frame) -> bool>(thread: *mut c_void, mut cb: F) {}
13+
914
#[derive(Clone)]
1015
pub struct Frame;
1116

0 commit comments

Comments
 (0)