diff options
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/backtrace.rs | 21 | ||||
| -rw-r--r-- | library/std/src/lib.rs | 4 | ||||
| -rw-r--r-- | library/std/src/panicking.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys_common/backtrace.rs | 3 |
4 files changed, 16 insertions, 14 deletions
diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 02e6811bc3f..09f83ea5fca 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -91,6 +91,7 @@ // `Backtrace`, but that's a relatively small price to pay relative to capturing // a backtrace or actually symbolizing it. +use crate::backtrace_rs::{self, BytesOrWideString}; use crate::env; use crate::ffi::c_void; use crate::fmt; @@ -98,8 +99,6 @@ use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst}; use crate::sync::Mutex; use crate::sys_common::backtrace::{lock, output_filename}; use crate::vec::Vec; -use backtrace::BytesOrWideString; -use backtrace_rs as backtrace; /// A captured OS thread stack backtrace. /// @@ -150,7 +149,7 @@ struct BacktraceFrame { } enum RawFrame { - Actual(backtrace::Frame), + Actual(backtrace_rs::Frame), #[cfg(test)] Fake, } @@ -197,7 +196,7 @@ impl fmt::Debug for BacktraceSymbol { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{{ ")?; - if let Some(fn_name) = self.name.as_ref().map(|b| backtrace::SymbolName::new(b)) { + if let Some(fn_name) = self.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)) { write!(fmt, "fn: \"{:#}\"", fn_name)?; } else { write!(fmt, "fn: <unknown>")?; @@ -223,7 +222,7 @@ impl fmt::Debug for BytesOrWide { BytesOrWide::Bytes(w) => BytesOrWideString::Bytes(w), BytesOrWide::Wide(w) => BytesOrWideString::Wide(w), }, - backtrace::PrintFmt::Short, + backtrace_rs::PrintFmt::Short, crate::env::current_dir().as_ref().ok(), ) } @@ -305,7 +304,7 @@ impl Backtrace { let mut frames = Vec::new(); let mut actual_start = None; unsafe { - backtrace::trace_unsynchronized(|frame| { + backtrace_rs::trace_unsynchronized(|frame| { frames.push(BacktraceFrame { frame: RawFrame::Actual(frame.clone()), symbols: Vec::new(), @@ -356,9 +355,9 @@ impl fmt::Display for Backtrace { let full = fmt.alternate(); let (frames, style) = if full { - (&capture.frames[..], backtrace::PrintFmt::Full) + (&capture.frames[..], backtrace_rs::PrintFmt::Full) } else { - (&capture.frames[capture.actual_start..], backtrace::PrintFmt::Short) + (&capture.frames[capture.actual_start..], backtrace_rs::PrintFmt::Short) }; // When printing paths we try to strip the cwd if it exists, otherwise @@ -370,7 +369,7 @@ impl fmt::Display for Backtrace { output_filename(fmt, path, style, cwd.as_ref().ok()) }; - let mut f = backtrace::BacktraceFmt::new(fmt, style, &mut print_path); + let mut f = backtrace_rs::BacktraceFmt::new(fmt, style, &mut print_path); f.add_context()?; for frame in frames { let mut f = f.frame(); @@ -380,7 +379,7 @@ impl fmt::Display for Backtrace { for symbol in frame.symbols.iter() { f.print_raw( frame.frame.ip(), - symbol.name.as_ref().map(|b| backtrace::SymbolName::new(b)), + symbol.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)), symbol.filename.as_ref().map(|b| match b { BytesOrWide::Bytes(w) => BytesOrWideString::Bytes(w), BytesOrWide::Wide(w) => BytesOrWideString::Wide(w), @@ -415,7 +414,7 @@ impl Capture { RawFrame::Fake => unimplemented!(), }; unsafe { - backtrace::resolve_frame_unsynchronized(frame, |symbol| { + backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| { symbols.push(BacktraceSymbol { name: symbol.name().map(|m| m.as_bytes().to_vec()), filename: symbol.filename_raw().map(|b| match b { diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index c6e5b0a492a..30e1514a8b8 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -511,6 +511,10 @@ mod panicking; // compiler pub mod rt; +#[path = "../../backtrace/src/lib.rs"] +#[allow(dead_code, unused_attributes)] +mod backtrace_rs; + // Pull in the `std_detect` crate directly into libstd. The contents of // `std_detect` are in a different repository: rust-lang/stdarch. // diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 9542e7209b4..ab2a6010306 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -171,7 +171,7 @@ fn default_hook(info: &PanicInfo<'_>) { // If this is a double panic, make sure that we print a backtrace // for this panic. Otherwise only print it if logging is enabled. let backtrace_env = if panic_count::get() >= 2 { - RustBacktrace::Print(backtrace_rs::PrintFmt::Full) + RustBacktrace::Print(crate::backtrace_rs::PrintFmt::Full) } else { backtrace::rust_backtrace_env() }; diff --git a/library/std/src/sys_common/backtrace.rs b/library/std/src/sys_common/backtrace.rs index e9b1e86d7ae..d386a656e4f 100644 --- a/library/std/src/sys_common/backtrace.rs +++ b/library/std/src/sys_common/backtrace.rs @@ -1,3 +1,4 @@ +use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt}; use crate::borrow::Cow; /// Common code for printing the backtrace in the same way across the different /// supported platforms. @@ -9,8 +10,6 @@ use crate::path::{self, Path, PathBuf}; use crate::sync::atomic::{self, Ordering}; use crate::sys::mutex::Mutex; -use backtrace_rs::{BacktraceFmt, BytesOrWideString, PrintFmt}; - /// Max number of frames to print. const MAX_NB_FRAMES: usize = 100; |
