add some debug & add state visibility

@xobs made the `state` element of a process publicly read-only visible
through a function call. I don't think this is a security issue but
please lmk if that's a problem.
This commit is contained in:
bunnie 2024-03-31 17:21:54 +08:00
parent 1af43fba7b
commit ecbce84385

View file

@ -265,6 +265,9 @@ impl Process {
self.state = ProcessState::Free;
Ok(())
}
/// Reveal state for debugging outside the crate.
pub fn state(&self) -> ProcessState { self.state }
}
#[cfg(not(baremetal))]
@ -679,6 +682,12 @@ impl SystemServices {
);
}
CallbackType::Swap(args) => {
#[cfg(feature = "debug-swap")]
{
let pid = crate::arch::process::current_pid();
let hardware_pid = (riscv::register::satp::read().bits() >> 22) & ((1 << 9) - 1);
println!("bef invoke PROCESS_TABLE.current: {}, hw_pid: {}", pid.get(), hardware_pid);
}
arch::syscall::invoke(
arch_process.current_thread_mut(),
pid.get() == 1,