diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-01-25 22:14:26 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-02 13:46:42 -0500 |
| commit | 85930c8f444e1ece1c92a0f9e39814f72d867e43 (patch) | |
| tree | fe17fba6104de252f6b2b945a5505d607a6becea /library/std/src/sys_common/backtrace.rs | |
| parent | 498eeb72f590e518e19746b346be53713689e207 (diff) | |
| download | rust-85930c8f444e1ece1c92a0f9e39814f72d867e43.tar.gz rust-85930c8f444e1ece1c92a0f9e39814f72d867e43.zip | |
Configure panic hook backtrace behavior
Diffstat (limited to 'library/std/src/sys_common/backtrace.rs')
| -rw-r--r-- | library/std/src/sys_common/backtrace.rs | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/library/std/src/sys_common/backtrace.rs b/library/std/src/sys_common/backtrace.rs index dc581a0675b..b0b55592f6f 100644 --- a/library/std/src/sys_common/backtrace.rs +++ b/library/std/src/sys_common/backtrace.rs @@ -7,7 +7,6 @@ use crate::fmt; use crate::io; use crate::io::prelude::*; use crate::path::{self, Path, PathBuf}; -use crate::sync::atomic::{self, Ordering}; use crate::sys_common::mutex::StaticMutex; /// Max number of frames to print. @@ -144,62 +143,6 @@ where result } -pub enum RustBacktrace { - Print(PrintFmt), - Disabled, - RuntimeDisabled, -} - -// If the `backtrace` feature of this crate isn't enabled quickly return -// `Disabled` so this can be constant propagated all over the place to -// optimize away callers. -#[cfg(not(feature = "backtrace"))] -pub fn rust_backtrace_env() -> RustBacktrace { - RustBacktrace::Disabled -} - -// For now logging is turned off by default, and this function checks to see -// whether the magical environment variable is present to see if it's turned on. -#[cfg(feature = "backtrace")] -pub fn rust_backtrace_env() -> RustBacktrace { - // Setting environment variables for Fuchsia components isn't a standard - // or easily supported workflow. For now, always display backtraces. - if cfg!(target_os = "fuchsia") { - return RustBacktrace::Print(PrintFmt::Full); - } - - static ENABLED: atomic::AtomicIsize = atomic::AtomicIsize::new(0); - match ENABLED.load(Ordering::SeqCst) { - 0 => {} - 1 => return RustBacktrace::RuntimeDisabled, - 2 => return RustBacktrace::Print(PrintFmt::Short), - _ => return RustBacktrace::Print(PrintFmt::Full), - } - - let (format, cache) = env::var_os("RUST_BACKTRACE") - .map(|x| { - if &x == "0" { - (RustBacktrace::RuntimeDisabled, 1) - } else if &x == "full" { - (RustBacktrace::Print(PrintFmt::Full), 3) - } else { - (RustBacktrace::Print(PrintFmt::Short), 2) - } - }) - .unwrap_or((RustBacktrace::RuntimeDisabled, 1)); - ENABLED.store(cache, Ordering::SeqCst); - format -} - -/// Setting for printing the full backtrace, unless backtraces are completely disabled -pub(crate) fn rust_backtrace_print_full() -> RustBacktrace { - if cfg!(feature = "backtrace") { - RustBacktrace::Print(PrintFmt::Full) - } else { - RustBacktrace::Disabled - } -} - /// Prints the filename of the backtrace frame. /// /// See also `output`. |
