Auto merge of #112843 - chenyukang:yukang-more-on-backtrace, r=workingjubilee

Print omitted frames count for short backtrace mode

Fixes #111730
This commit is contained in:
bors 2023-07-30 22:31:52 +00:00
commit d4145eeef4
10 changed files with 35 additions and 8 deletions

View File

@ -60,6 +60,8 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
bt_fmt.add_context()?; bt_fmt.add_context()?;
let mut idx = 0; let mut idx = 0;
let mut res = Ok(()); let mut res = Ok(());
let mut omitted_count: usize = 0;
let mut first_omit = true;
// Start immediately if we're not using a short backtrace. // Start immediately if we're not using a short backtrace.
let mut start = print_fmt != PrintFmt::Short; let mut start = print_fmt != PrintFmt::Short;
backtrace_rs::trace_unsynchronized(|frame| { backtrace_rs::trace_unsynchronized(|frame| {
@ -85,10 +87,27 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
start = true; start = true;
return; return;
} }
if !start {
omitted_count += 1;
}
} }
} }
if start { if start {
if omitted_count > 0 {
debug_assert!(print_fmt == PrintFmt::Short);
// only print the message between the middle of frames
if !first_omit {
let _ = writeln!(
bt_fmt.formatter(),
" [... omitted {} frame{} ...]",
omitted_count,
if omitted_count > 1 { "s" } else { "" }
);
}
first_omit = false;
omitted_count = 0;
}
res = bt_fmt.frame().symbol(frame, symbol); res = bt_fmt.frame().symbol(frame, symbol);
} }
}); });

View File

@ -8,7 +8,7 @@ toml = "0.5"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
anyhow = "1.0.32" anyhow = "1.0.32"
flate2 = "1.0.16" flate2 = "1.0.26"
xz2 = "0.1.7" xz2 = "0.1.7"
tar = "0.4.29" tar = "0.4.29"
sha2 = "0.10.1" sha2 = "0.10.1"

View File

@ -13,8 +13,10 @@
// normalize-stderr-test "\s\d{1,}: .*\n" -> "" // normalize-stderr-test "\s\d{1,}: .*\n" -> ""
// normalize-stderr-test "\s at .*\n" -> "" // normalize-stderr-test "\s at .*\n" -> ""
// normalize-stderr-test ".*note: Some details.*\n" -> "" // normalize-stderr-test ".*note: Some details.*\n" -> ""
// normalize-stderr-test "\n\n[ ]*\n" -> "" // normalize-stderr-test "\n[ ]*\n" -> ""
// normalize-stderr-test "compiler/.*: projection" -> "projection" // normalize-stderr-test "compiler/.*: projection" -> "projection"
// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> ""
// normalize-stderr-test "error: [\s\n]*query stack during panic:\n" -> ""
// this should run-pass // this should run-pass
#![feature(generic_const_exprs)] #![feature(generic_const_exprs)]

View File

@ -1,4 +1,3 @@
error: query stack during panic:
#0 [mir_borrowck] borrow-checking `test::{closure#0}::{constant#1}` #0 [mir_borrowck] borrow-checking `test::{closure#0}::{constant#1}`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{closure#0}::{constant#1}` #1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{closure#0}::{constant#1}`
#2 [mir_for_ctfe] caching mir of `test::{closure#0}::{constant#1}` for CTFE #2 [mir_for_ctfe] caching mir of `test::{closure#0}::{constant#1}` for CTFE
@ -9,4 +8,3 @@ error: query stack during panic:
#7 [analysis] running analysis passes on this crate #7 [analysis] running analysis passes on this crate
end of query stack end of query stack
error: aborting due to previous error error: aborting due to previous error

View File

@ -15,6 +15,8 @@
// normalize-stderr-test ".*note: Some details.*\n" -> "" // normalize-stderr-test ".*note: Some details.*\n" -> ""
// normalize-stderr-test "\n\n[ ]*\n" -> "" // normalize-stderr-test "\n\n[ ]*\n" -> ""
// normalize-stderr-test "compiler/.*: projection" -> "projection" // normalize-stderr-test "compiler/.*: projection" -> "projection"
// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> ""
// normalize-stderr-test "error: [\s\n]*query stack" -> "error: query stack"
#![feature(generic_const_exprs)] #![feature(generic_const_exprs)]
#![allow(incomplete_features)] #![allow(incomplete_features)]

View File

@ -10,7 +10,7 @@
// normalize-stderr-test "\s\d{1,}: .*\n" -> "" // normalize-stderr-test "\s\d{1,}: .*\n" -> ""
// normalize-stderr-test "\s at .*\n" -> "" // normalize-stderr-test "\s at .*\n" -> ""
// normalize-stderr-test ".*note: Some details.*\n" -> "" // normalize-stderr-test ".*note: Some details.*\n" -> ""
// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> ""
#![allow(unconditional_panic)] #![allow(unconditional_panic)]
const X: i32 = 1 / 0; //~ERROR constant const X: i32 = 1 / 0; //~ERROR constant

View File

@ -18,6 +18,9 @@
// normalize-stderr-test ".*note: Some details.*\n" -> "" // normalize-stderr-test ".*note: Some details.*\n" -> ""
// normalize-stderr-test "\n\n[ ]*\n" -> "" // normalize-stderr-test "\n\n[ ]*\n" -> ""
// normalize-stderr-test "compiler/.*: projection" -> "projection" // normalize-stderr-test "compiler/.*: projection" -> "projection"
// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> ""
// normalize-stderr-test "error: [\s\n]*query stack" -> "error: query stack"
// normalize-stderr-test "[\n\s]*\nquery stack during panic:" -> "query stack during panic:"
// edition:2018 // edition:2018
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]

View File

@ -1,9 +1,9 @@
error: error:
--> $DIR/issue-90014-tait2.rs:41:27 --> $DIR/issue-90014-tait2.rs:44:27
| |
LL | fn make_fut(&self) -> Box<dyn for<'a> Trait<'a, Thing = Fut<'a>>> { LL | fn make_fut(&self) -> Box<dyn for<'a> Trait<'a, Thing = Fut<'a>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^query stack during panic: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^query stack during panic:
#0 [typeck] type-checking `<impl at $DIR/issue-90014-tait2.rs:40:1: 40:13>::make_fut` #0 [typeck] type-checking `<impl at $DIR/issue-90014-tait2.rs:43:1: 43:13>::make_fut`
#1 [type_of] computing type of `Fut::{opaque#0}` #1 [type_of] computing type of `Fut::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module #2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate #3 [analysis] running analysis passes on this crate

View File

@ -3,8 +3,10 @@ stack backtrace:
0: std::panicking::begin_panic 0: std::panicking::begin_panic
1: short_ice_remove_middle_frames_2::eight 1: short_ice_remove_middle_frames_2::eight
2: short_ice_remove_middle_frames_2::seven::{{closure}} 2: short_ice_remove_middle_frames_2::seven::{{closure}}
[... omitted 3 frames ...]
3: short_ice_remove_middle_frames_2::fifth 3: short_ice_remove_middle_frames_2::fifth
4: short_ice_remove_middle_frames_2::fourth::{{closure}} 4: short_ice_remove_middle_frames_2::fourth::{{closure}}
[... omitted 4 frames ...]
5: short_ice_remove_middle_frames_2::first 5: short_ice_remove_middle_frames_2::first
6: short_ice_remove_middle_frames_2::main 6: short_ice_remove_middle_frames_2::main
7: core::ops::function::FnOnce::call_once 7: core::ops::function::FnOnce::call_once

View File

@ -4,6 +4,7 @@ stack backtrace:
1: short_ice_remove_middle_frames::seven 1: short_ice_remove_middle_frames::seven
2: short_ice_remove_middle_frames::sixth 2: short_ice_remove_middle_frames::sixth
3: short_ice_remove_middle_frames::fifth::{{closure}} 3: short_ice_remove_middle_frames::fifth::{{closure}}
[... omitted 4 frames ...]
4: short_ice_remove_middle_frames::second 4: short_ice_remove_middle_frames::second
5: short_ice_remove_middle_frames::first::{{closure}} 5: short_ice_remove_middle_frames::first::{{closure}}
6: short_ice_remove_middle_frames::first 6: short_ice_remove_middle_frames::first