Skip to content

Commit 4920456

Browse files
committed
Get vaguely working with a test for checking output
1 parent b637c0e commit 4920456

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/libstd/backtrace.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ struct BacktraceFrame {
152152
symbols: Vec<BacktraceSymbol>,
153153
}
154154

155-
#[derive(Debug)]
156155
struct BacktraceSymbol {
157156
name: Option<Vec<u8>>,
158157
filename: Option<BytesOrWide>,
@@ -164,6 +163,16 @@ enum BytesOrWide {
164163
Wide(Vec<u16>),
165164
}
166165

166+
impl fmt::Debug for BacktraceSymbol {
167+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
168+
fmt.debug_struct("BacktraceSymbol")
169+
.field("name", &self.name.as_ref().map(|b| backtrace::SymbolName::new(b)))
170+
.field("filename", &self.filename)
171+
.field("lineno", &self.lineno)
172+
.finish()
173+
}
174+
}
175+
167176
impl fmt::Debug for BytesOrWide {
168177
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
169178
output_filename(
@@ -364,3 +373,19 @@ impl Capture {
364373
}
365374
}
366375
}
376+
377+
#[cfg(test)]
378+
mod tests {
379+
use super::*;
380+
381+
#[test]
382+
fn debug_backtrace_fmt() {
383+
let bt = Backtrace::capture();
384+
eprintln!("uncaptured: {:?}", bt);
385+
let bt = Backtrace::force_capture();
386+
eprintln!("captured: {:?}", bt);
387+
eprintln!("display print: {}", bt);
388+
eprintln!("resolved: {:?}", bt);
389+
unimplemented!();
390+
}
391+
}

0 commit comments

Comments
 (0)