make both panic display formats collapse frames

This commit is contained in:
Ashley Mannix 2020-12-16 15:07:39 +10:00 committed by Jakub Duchniewicz
parent 5fb298664c
commit 8423a19f66
2 changed files with 4 additions and 6 deletions

View File

@ -399,12 +399,11 @@ impl fmt::Display for Backtrace {
let mut f = backtrace_rs::BacktraceFmt::new(fmt, style, &mut print_path);
f.add_context()?;
for frame in frames {
let mut f = f.frame();
if frame.symbols.is_empty() {
f.print_raw(frame.frame.ip(), None, None, None)?;
f.frame().print_raw(frame.frame.ip(), None, None, None)?;
} else {
for symbol in frame.symbols.iter() {
f.print_raw_with_column(
f.frame().print_raw_with_column(
frame.frame.ip(),
symbol.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)),
symbol.filename.as_ref().map(|b| match b {

View File

@ -71,7 +71,6 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
let mut hit = false;
let mut stop = false;
let mut frame_fmt = bt_fmt.frame();
backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| {
hit = true;
if print_fmt == PrintFmt::Short {
@ -88,7 +87,7 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
}
if start {
res = frame_fmt.symbol(frame, symbol);
res = bt_fmt.frame().symbol(frame, symbol);
}
});
if stop {
@ -96,7 +95,7 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
}
if !hit {
if start {
res = frame_fmt.print_raw(frame.ip(), None, None, None);
res = bt_fmt.frame().print_raw(frame.ip(), None, None, None);
}
}