Add initial debug fmt for Backtrace
This commit is contained in:
parent
e6ec0d125e
commit
b637c0e84a
1 changed files with 19 additions and 6 deletions
|
@ -106,6 +106,7 @@ use backtrace_rs as backtrace;
|
||||||
/// previous point in time. In some instances the `Backtrace` type may
|
/// previous point in time. In some instances the `Backtrace` type may
|
||||||
/// internally be empty due to configuration. For more information see
|
/// internally be empty due to configuration. For more information see
|
||||||
/// `Backtrace::capture`.
|
/// `Backtrace::capture`.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Backtrace {
|
pub struct Backtrace {
|
||||||
inner: Inner,
|
inner: Inner,
|
||||||
}
|
}
|
||||||
|
@ -126,12 +127,14 @@ pub enum BacktraceStatus {
|
||||||
Captured,
|
Captured,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
enum Inner {
|
enum Inner {
|
||||||
Unsupported,
|
Unsupported,
|
||||||
Disabled,
|
Disabled,
|
||||||
Captured(Mutex<Capture>),
|
Captured(Mutex<Capture>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct Capture {
|
struct Capture {
|
||||||
actual_start: usize,
|
actual_start: usize,
|
||||||
resolved: bool,
|
resolved: bool,
|
||||||
|
@ -143,11 +146,13 @@ fn _assert_send_sync() {
|
||||||
_assert::<Backtrace>();
|
_assert::<Backtrace>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct BacktraceFrame {
|
struct BacktraceFrame {
|
||||||
frame: backtrace::Frame,
|
frame: backtrace::Frame,
|
||||||
symbols: Vec<BacktraceSymbol>,
|
symbols: Vec<BacktraceSymbol>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct BacktraceSymbol {
|
struct BacktraceSymbol {
|
||||||
name: Option<Vec<u8>>,
|
name: Option<Vec<u8>>,
|
||||||
filename: Option<BytesOrWide>,
|
filename: Option<BytesOrWide>,
|
||||||
|
@ -159,6 +164,20 @@ enum BytesOrWide {
|
||||||
Wide(Vec<u16>),
|
Wide(Vec<u16>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
impl Backtrace {
|
||||||
/// Returns whether backtrace captures are enabled through environment
|
/// Returns whether backtrace captures are enabled through environment
|
||||||
/// variables.
|
/// variables.
|
||||||
|
@ -267,12 +286,6 @@ impl Backtrace {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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 {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let mut capture = match &self.inner {
|
let mut capture = match &self.inner {
|
||||||
Inner::Unsupported => return fmt.write_str("unsupported backtrace"),
|
Inner::Unsupported => return fmt.write_str("unsupported backtrace"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue