Show context name and syscall when panicking

This commit is contained in:
Jeremy Soller
2021-10-27 20:28:40 -06:00
parent 9ea278997c
commit 063881d2ca

View File

@@ -3,7 +3,7 @@
use core::alloc::Layout;
use core::panic::PanicInfo;
use crate::{cpu_id, context, interrupt};
use crate::{cpu_id, context, interrupt, syscall};
#[lang = "eh_personality"]
#[no_mangle]
@@ -18,7 +18,19 @@ pub extern "C" fn rust_begin_unwind(info: &PanicInfo) -> ! {
unsafe { interrupt::stack_trace(); }
println!("CPU {}, PID {:?}", cpu_id(), context::context_id());
//WARNING: name cannot be grabed, it may deadlock
// This could deadlock, but at this point we are going to halt anyways
{
let contexts = context::contexts();
if let Some(context_lock) = contexts.current() {
let context = context_lock.read();
println!("NAME: {}", *context.name.read());
if let Some((a, b, c, d, e, f)) = context.syscall {
println!("SYSCALL: {}", syscall::debug::format_call(a, b, c, d, e, f));
}
}
}
println!("HALT");
loop {