forked from M-Labs/zynq-rs
panic: print location info + message
This commit is contained in:
parent
0adb0d5c51
commit
887627b137
|
@ -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)]
|
||||||
|
|
||||||
|
|
14
src/panic.rs
14
src/panic.rs
|
@ -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 {}
|
||||||
|
|
Loading…
Reference in New Issue