kernel: change some println!s to klog!s

Even when the print-debug feature isn't turned on, println! macro is still able to output some critical non-debug info to the console such as panics, process crashes and violations, etc. Debugging messages are printed with klog! macro that's disabled when debug-print feature is not set.
This commit is contained in:
eupn 2023-03-14 18:47:57 +04:00
parent 89a1447df4
commit 7f5656445a
No known key found for this signature in database
GPG key ID: 0BBE77FB42014014
4 changed files with 19 additions and 19 deletions

View file

@ -22,7 +22,7 @@ pub fn handle(irqs_pending: usize) -> Result<xous_kernel::Result, xous_kernel::E
return SystemServices::with_mut(|ss| {
// Disable all other IRQs and redirect into userspace
arch::irq::disable_all_irqs();
// println!("Making a callback to PID{}: {:x?} ({:08x}, {:x?})", pid, f, irq_no as usize, arg);
klog!("Making a callback to PID{}: {:x?} ({:08x}, {:x?})", pid, f, irq_no as usize, arg);
ss.make_callback_to(
*pid,
f.get() as *mut usize,
@ -33,6 +33,7 @@ pub fn handle(irqs_pending: usize) -> Result<xous_kernel::Result, xous_kernel::E
.map(|_| xous_kernel::Result::ResumeProcess)
});
} else {
klog!("[!] Masked an unhandled IRQ #{:?}", irq_no);
// If there is no handler, mask this interrupt
// to prevent an IRQ storm. This is considered
// an error.

View file

@ -126,13 +126,13 @@ pub extern "C" fn kmain() {
}
None => {
#[cfg(feature = "debug-print")]
println!("NO RUNNABLE TASKS FOUND, entering idle state");
klog!("NO RUNNABLE TASKS FOUND, entering idle state");
#[cfg(feature = "debug-print")]
SystemServices::with(|system_services| {
for (test_idx, process) in system_services.processes.iter().enumerate() {
if !process.free() {
println!("PID {}: {:?}", test_idx + 1, process);
klog!("PID {}: {:?}", test_idx + 1, process);
}
}
});

View file

@ -491,7 +491,7 @@ impl SystemServices {
// PID0 doesn't exist -- process IDs are offset by 1.
let pid_idx = pid.get() as usize - 1;
if cfg!(baremetal) && self.processes[pid_idx].mapping.get_pid() != pid {
println!(
klog!(
"Process doesn't match ({} vs {})",
self.processes[pid_idx].mapping.get_pid(),
pid
@ -1049,7 +1049,7 @@ impl SystemServices {
// Ensure the new process can be run.
match new.state {
ProcessState::Free => {
println!("PID {} was free", new_pid);
klog!("PID {} was free", new_pid);
return Err(xous_kernel::Error::ProcessNotFound);
}
ProcessState::Setup(_) | ProcessState::Allocated => new_tid = INITIAL_TID,

View file

@ -367,11 +367,11 @@ fn return_memory(
})
}
WaitingMessage::ScalarMessage(_pid, _tid) => {
println!("WARNING: Tried to wait on a message that was a scalar");
klog!("WARNING: Tried to wait on a message that was a scalar");
return Err(xous_kernel::Error::DoubleFree);
}
WaitingMessage::None => {
println!("WARNING: Tried to wait on a message that didn't exist -- return memory");
klog!("WARNING: Tried to wait on a message that didn't exist -- return memory");
return Err(xous_kernel::Error::DoubleFree);
}
};
@ -463,25 +463,25 @@ fn return_result(
let (client_pid, client_tid) = match result {
WaitingMessage::ScalarMessage(pid, tid) => (pid, tid),
WaitingMessage::ForgetMemory(_) => {
println!(
klog!(
"WARNING: Tried to wait on a scalar message that was actually forgettingmemory"
);
return Err(xous_kernel::Error::DoubleFree);
}
WaitingMessage::BorrowedMemory(_, _, _, _, _) => {
println!(
klog!(
"WARNING: Tried to wait on a scalar message that was actually borrowed memory"
);
return Err(xous_kernel::Error::DoubleFree);
}
WaitingMessage::MovedMemory => {
println!(
klog!(
"WARNING: Tried to wait on a scalar message that was actually moved memory"
);
return Err(xous_kernel::Error::DoubleFree);
}
WaitingMessage::None => {
println!("WARNING ({}:{}): Tried to wait on a message that didn't exist (irq? {}) -- return {:?}", server_pid.get(), server_tid, if in_irq { "yes"} else {"no"}, result);
klog!("WARNING ({}:{}): Tried to wait on a message that didn't exist (irq? {}) -- return {:?}", server_pid.get(), server_tid, if in_irq { "yes"} else {"no"}, result);
return Err(xous_kernel::Error::DoubleFree);
}
};
@ -581,7 +581,7 @@ fn reply_and_receive_next(
MessageResponse { pid, tid, result }
}
WaitingMessage::ForgetMemory(_) => {
println!(
klog!(
"WARNING: Tried to wait on a scalar message that was actually forgetting memory"
);
return Err(xous_kernel::Error::DoubleFree);
@ -605,13 +605,13 @@ fn reply_and_receive_next(
}
}
WaitingMessage::MovedMemory => {
println!(
klog!(
"WARNING: Tried to wait on a scalar message that was actually moved memory"
);
return Err(xous_kernel::Error::DoubleFree);
}
WaitingMessage::None => {
println!("WARNING: Tried to wait on a message that didn't exist -- receive and return scalar");
klog!("WARNING: Tried to wait on a message that didn't exist -- receive and return scalar");
return Err(xous_kernel::Error::DoubleFree);
}
};
@ -745,12 +745,12 @@ fn receive_message(pid: PID, tid: TID, sid: SID, blocking: ExecutionType) -> Sys
}
pub fn handle(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult {
#[cfg(feature = "debug-print")]
print!("KERNEL({}:{}): Syscall {:x?}", pid, tid, call);
klog!("KERNEL({}:{}): Syscall {:x?}, in_irq={}", pid, tid, call, in_irq);
// let call_string = format!("{:x?}", call);
// let start_time = std::time::Instant::now();
#[allow(clippy::let_and_return)]
let result = if in_irq && !call.can_call_from_interrupt() {
klog!("[!] Called {:?} that's cannot be called from the interrupt handler!", call);
Err(xous_kernel::Error::InvalidSyscall)
} else {
handle_inner(pid, tid, in_irq, call)
@ -758,8 +758,7 @@ pub fn handle(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult
// println!("KERNEL [{:2}:{:2}] Syscall took {:7} usec: {}", pid, tid, start_time.elapsed().as_micros(), call_string);
#[cfg(feature = "debug-print")]
println!(
klog!(
" -> ({}:{}) {:x?}",
crate::arch::current_pid(),
crate::arch::process::Process::current().current_tid(),
@ -785,7 +784,7 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
.map(|x| x.get() >= arch::mem::USER_AREA_END)
.unwrap_or(false)
{
println!("Exceeded user area");
klog!("Exceeded user area");
return Err(xous_kernel::Error::BadAddress);
// Don't allow mapping non-page values