From 91da2c926a1620b872dc231e23b87a85d0dc2b46 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 20 Apr 2024 14:52:08 +0100 Subject: [PATCH 1/3] allow customisation of the backtrace website --- agb/src/panics_render.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/agb/src/panics_render.rs b/agb/src/panics_render.rs index 190463e9..ed894145 100644 --- a/agb/src/panics_render.rs +++ b/agb/src/panics_render.rs @@ -11,6 +11,8 @@ use crate::{ mod text; +static WEBSITE: Option<&str> = core::option_env!("AGBRS_BACKTRACE_WEBSITE"); + pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! { critical_section::with(|_cs| { dma3_exclusive(|| { @@ -20,7 +22,13 @@ pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! { gba.dma.dma().dma3.disable(); let mut gfx = gba.display.video.bitmap3(); - let qrcode_string_data = format!("https://agbrs.dev/crash#{trace}"); + let website = WEBSITE.unwrap_or("https://agbrs.dev/crash"); + + let qrcode_string_data = if website.is_empty() { + format!("{trace}") + } else { + format!("{website}#{trace}") + }; crate::println!("Stack trace: {qrcode_string_data}"); let location = draw_qr_code(&mut gfx, &qrcode_string_data); @@ -29,7 +37,8 @@ pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! { text::BitmapTextRender::new(&mut gfx, (location, 8).into(), 0x0000); let _ = write!( &mut trace_text_render, - "The game crashed :(\nhttps://agbrs.dev/crash\n{trace}" + "The game crashed :({}{website}\n{trace}", + if website.is_empty() { "" } else { "\n" } ); let mut panic_text_render = From 1c9e829bd16d274f590f239f1189a305c6d5b6ce Mon Sep 17 00:00:00 2001 From: Corwin Date: Tue, 23 Apr 2024 20:09:35 +0100 Subject: [PATCH 2/3] have website not be an option --- agb/src/panics_render.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/agb/src/panics_render.rs b/agb/src/panics_render.rs index ed894145..99571eea 100644 --- a/agb/src/panics_render.rs +++ b/agb/src/panics_render.rs @@ -11,7 +11,12 @@ use crate::{ mod text; -static WEBSITE: Option<&str> = core::option_env!("AGBRS_BACKTRACE_WEBSITE"); +static WEBSITE: &str = { + match core::option_env!("AGBRS_BACKTRACE_WEBSITE") { + Some(x) => x, + None => "", + } +}; pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! { critical_section::with(|_cs| { @@ -22,12 +27,10 @@ pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! { gba.dma.dma().dma3.disable(); let mut gfx = gba.display.video.bitmap3(); - let website = WEBSITE.unwrap_or("https://agbrs.dev/crash"); - - let qrcode_string_data = if website.is_empty() { + let qrcode_string_data = if WEBSITE.is_empty() { format!("{trace}") } else { - format!("{website}#{trace}") + format!("{WEBSITE}#{trace}") }; crate::println!("Stack trace: {qrcode_string_data}"); @@ -37,8 +40,8 @@ pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! { text::BitmapTextRender::new(&mut gfx, (location, 8).into(), 0x0000); let _ = write!( &mut trace_text_render, - "The game crashed :({}{website}\n{trace}", - if website.is_empty() { "" } else { "\n" } + "The game crashed :({}{WEBSITE}\n{trace}", + if WEBSITE.is_empty() { "" } else { "\n" } ); let mut panic_text_render = From a65f6402beec37b96c5e13f6b1bf6deca0e5567e Mon Sep 17 00:00:00 2001 From: Corwin Date: Tue, 23 Apr 2024 20:30:40 +0100 Subject: [PATCH 3/3] fix url to point to us --- agb/src/panics_render.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agb/src/panics_render.rs b/agb/src/panics_render.rs index 99571eea..c881cd18 100644 --- a/agb/src/panics_render.rs +++ b/agb/src/panics_render.rs @@ -14,7 +14,7 @@ mod text; static WEBSITE: &str = { match core::option_env!("AGBRS_BACKTRACE_WEBSITE") { Some(x) => x, - None => "", + None => "https://agbrs.dev/crash#", } }; @@ -30,7 +30,7 @@ pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! { let qrcode_string_data = if WEBSITE.is_empty() { format!("{trace}") } else { - format!("{WEBSITE}#{trace}") + format!("{WEBSITE}{trace}") }; crate::println!("Stack trace: {qrcode_string_data}");