Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/core/src/error/backtrace.rs
3075 views
1
use std::backtrace::Backtrace;
2
use std::sync::atomic::{AtomicBool, Ordering};
3
4
static ENABLED: AtomicBool = AtomicBool::new(true);
5
6
fn enabled() -> bool {
7
ENABLED.load(Ordering::Relaxed)
8
}
9
10
/// Forcibly disable capturing backtraces dynamically.
11
///
12
/// XXX: This is only exposed for internal testing, to work around cargo
13
/// workspaces and feature resolution. This method may disappear or change
14
/// at any time. Instead of using this method, you should disable the
15
/// `backtrace` cargo feature.
16
#[doc(hidden)]
17
pub fn disable_backtrace() {
18
ENABLED.store(false, Ordering::Relaxed)
19
}
20
21
#[track_caller]
22
pub fn capture() -> Backtrace {
23
if enabled() {
24
Backtrace::capture()
25
} else {
26
Backtrace::disabled()
27
}
28
}
29
30