diff --git a/src/libstd/backtrace.rs b/src/libstd/backtrace.rs index 5ba1c940251..6b4ae77cec7 100644 --- a/src/libstd/backtrace.rs +++ b/src/libstd/backtrace.rs @@ -106,6 +106,7 @@ use backtrace_rs as backtrace; /// previous point in time. In some instances the `Backtrace` type may /// internally be empty due to configuration. For more information see /// `Backtrace::capture`. +#[derive(Debug)] pub struct Backtrace { inner: Inner, } @@ -126,12 +127,14 @@ pub enum BacktraceStatus { Captured, } +#[derive(Debug)] enum Inner { Unsupported, Disabled, Captured(Mutex), } +#[derive(Debug)] struct Capture { actual_start: usize, resolved: bool, @@ -143,11 +146,13 @@ fn _assert_send_sync() { _assert::(); } +#[derive(Debug)] struct BacktraceFrame { frame: backtrace::Frame, symbols: Vec, } +#[derive(Debug)] struct BacktraceSymbol { name: Option>, filename: Option, @@ -159,6 +164,20 @@ enum BytesOrWide { Wide(Vec), } +impl fmt::Debug for BytesOrWide { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + output_filename( + fmt, + match self { + BytesOrWide::Bytes(w) => BytesOrWideString::Bytes(w), + BytesOrWide::Wide(w) => BytesOrWideString::Wide(w), + }, + backtrace::PrintFmt::Full, + crate::env::current_dir().as_ref().ok(), + ) + } +} + impl Backtrace { /// Returns whether backtrace captures are enabled through environment /// variables. @@ -267,12 +286,6 @@ impl Backtrace { } impl fmt::Display for Backtrace { - fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(self, fmt) - } -} - -impl fmt::Debug for Backtrace { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut capture = match &self.inner { Inner::Unsupported => return fmt.write_str("unsupported backtrace"),