From 087228d9468d349c25230a7fa73c554ce45b20d9 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Mon, 1 Apr 2024 16:36:05 +0100 Subject: [PATCH] Don't show as much information for uninteresting functions --- agb-addr2line/src/main.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/agb-addr2line/src/main.rs b/agb-addr2line/src/main.rs index e91946bd..b23cae53 100644 --- a/agb-addr2line/src/main.rs +++ b/agb-addr2line/src/main.rs @@ -86,10 +86,17 @@ fn print_address( }) .unwrap_or_default(); - if is_first { - print!("{index}:\t{}", function_name.bold()); + let is_interesting = is_interesting_function(&function_name, &location.filename); + let function_name_to_print = if is_interesting { + function_name.bold() } 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!( @@ -98,7 +105,7 @@ fn print_address( 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)?; } @@ -155,3 +162,15 @@ fn prettify_path(path: &str) -> Cow<'_, str> { 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 +}