Don't show as much information for uninteresting functions

This commit is contained in:
Gwilym Inzani 2024-04-01 16:36:05 +01:00
parent d729591c0e
commit 087228d946

View file

@ -86,10 +86,17 @@ fn print_address(
}) })
.unwrap_or_default(); .unwrap_or_default();
if is_first { let is_interesting = is_interesting_function(&function_name, &location.filename);
print!("{index}:\t{}", function_name.bold()); let function_name_to_print = if is_interesting {
function_name.bold()
} else { } else {
print!("\t(inlined by) {function_name}"); function_name.normal()
};
if is_first {
print!("{index}:\t{function_name_to_print}");
} else {
print!("\t(inlined by) {function_name_to_print}");
} }
println!( println!(
@ -98,7 +105,7 @@ fn print_address(
location.line.to_string().green() location.line.to_string().green()
); );
if include_code && location.line != 0 { if include_code && location.line != 0 && is_interesting {
print_line_of_code(&frame, location)?; print_line_of_code(&frame, location)?;
} }
@ -155,3 +162,15 @@ fn prettify_path(path: &str) -> Cow<'_, str> {
Cow::Borrowed(path) Cow::Borrowed(path)
} }
} }
fn is_interesting_function(function_name: &str, path: &str) -> bool {
if function_name == "rust_begin_unwind" {
return false; // this is the unwind exception call
}
if path.ends_with("panicking.rs") {
return false; // probably part of rust's internal panic mechanisms
}
true
}