From 887627b137365ab9d45c375d710acf06e81b9e54 Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 17 Dec 2019 00:27:20 +0100 Subject: [PATCH] panic: print location info + message --- src/main.rs | 1 + src/panic.rs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index b0a7ab4..346ce97 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ #![feature(naked_functions)] #![feature(never_type)] #![feature(alloc_error_handler)] +#![feature(panic_info_message)] // TODO: disallow unused/dead_code when code moves into a lib crate #![allow(dead_code)] diff --git a/src/panic.rs b/src/panic.rs index f637b59..f8e3493 100644 --- a/src/panic.rs +++ b/src/panic.rs @@ -1,8 +1,18 @@ -use crate::{println, zynq}; +use crate::{print, println, zynq}; #[panic_handler] fn panic(info: &core::panic::PanicInfo) -> ! { - println!("\nPanic: {}", info); + print!("panic at "); + if let Some(location) = info.location() { + print!("{}:{}:{}", location.file(), location.line(), location.column()); + } else { + print!("unknown location"); + } + if let Some(message) = info.message() { + println!(": {}", message); + } else { + println!(""); + } zynq::slcr::RegisterBlock::unlocked(|slcr| slcr.soft_reset()); loop {}