1
0
Fork 0

panic: print location info + message

This commit is contained in:
Astro 2019-12-17 00:27:20 +01:00
parent 0adb0d5c51
commit 887627b137
2 changed files with 13 additions and 2 deletions

View File

@ -5,6 +5,7 @@
#![feature(naked_functions)] #![feature(naked_functions)]
#![feature(never_type)] #![feature(never_type)]
#![feature(alloc_error_handler)] #![feature(alloc_error_handler)]
#![feature(panic_info_message)]
// TODO: disallow unused/dead_code when code moves into a lib crate // TODO: disallow unused/dead_code when code moves into a lib crate
#![allow(dead_code)] #![allow(dead_code)]

View File

@ -1,8 +1,18 @@
use crate::{println, zynq}; use crate::{print, println, zynq};
#[panic_handler] #[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! { 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()); zynq::slcr::RegisterBlock::unlocked(|slcr| slcr.soft_reset());
loop {} loop {}