diff options
Diffstat (limited to 'kernel/src/lib.rs')
-rw-r--r-- | kernel/src/lib.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index b36d731..8ec68e5 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -2,6 +2,7 @@ #![feature(compiler_builtins_lib)] #![feature(custom_test_frameworks)] #![feature(abi_x86_interrupt)] +#![feature(panic_info_message)] #![test_runner(crate::test_runner)] #![reexport_test_harness_main = "test_main"] #![no_std] @@ -34,7 +35,7 @@ pub extern "C" fn _start() -> ! { let mut stdout = OStream::new(); stdout.clear(); - panic!("panic!"); + panic!("panic! at the disco"); core::iter::successors(Some(0), |n| Some(n + 1)) .for_each(|n| write!(&mut stdout, "hello world {}!", n).unwrap()); @@ -45,7 +46,7 @@ pub extern "C" fn _start() -> ! { #[panic_handler] #[no_mangle] -pub extern "C" fn panic_handler(_info: &core::panic::PanicInfo) -> ! { +pub extern "C" fn panic_handler(info: &core::panic::PanicInfo) -> ! { let mut stderr = OStream::new(); stderr.set_state(vga_text::CharState::from_colors( vga_text::Color::LightRed, @@ -60,15 +61,19 @@ pub extern "C" fn panic_handler(_info: &core::panic::PanicInfo) -> ! { )); stderr.print_centered(b"<kernel panic>"); stderr.set_row(14); - let text = _info - .payload() - .downcast_ref::<&str>() - .unwrap_or(&"no panic information is obtainable"); stderr.set_state(vga_text::CharState::from_colors( vga_text::Color::Cyan, vga_text::Color::Red, )); - stderr.print_centered(text.as_bytes()); + stderr.set_centered(true); + write!( + &mut stderr, + "{:?}", + info.message() + .unwrap_or(&format_args!("no panic information obtainable")) + ); + //loop{} + stderr.set_centered(false); if cfg!(test) { write!(serial::SerialStream::new(), "Testing failed\n").unwrap(); qemu::exit_qemu(qemu::QemuExitCode::Failed); |