From 2a1aa240404372b7a0ba66665b2503f36dd28ead Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 18 Jun 2021 12:56:27 +0800 Subject: [PATCH] kernel: debug: add command to print processes This changes the `p` command to only print processes, and renames the existing behavior to `P` which prints processes and threads. Signed-off-by: Sean Cross --- kernel/src/debug.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/kernel/src/debug.rs b/kernel/src/debug.rs index d0fca1e6a..c9e6842ca 100644 --- a/kernel/src/debug.rs +++ b/kernel/src/debug.rs @@ -374,6 +374,27 @@ pub fn irq(_irq_number: usize, _arg: *mut usize) { } b'p' => { println!("Printing processes"); + crate::services::SystemServices::with(|system_services| { + let current_pid = system_services.current_pid(); + for process in &system_services.processes { + if !process.free() { + println!( + "{:?} {}:", + process, + system_services.process_name(process.pid).unwrap_or("") + ); + process.activate().unwrap(); + } + } + system_services + .get_process(current_pid) + .unwrap() + .activate() + .unwrap(); + }); + } + b'P' => { + println!("Printing processes and threads"); crate::services::SystemServices::with(|system_services| { let current_pid = system_services.current_pid(); for process in &system_services.processes { @@ -461,7 +482,8 @@ pub fn irq(_irq_number: usize, _arg: *mut usize) { #[cfg(feature = "gdbserver")] println!(" g | enter the gdb server"); println!(" m | print MMU page tables of all processes"); - println!(" p | print all processes and threads"); + println!(" p | print all processes"); + println!(" P | print all processes and threads"); println!(" r | report RAM usage of all processes"); println!(" s | Suspend PID 3"); println!(" c | Continue PID 3");