From c8c8e58f10488fba14adb85c8162fe1aeb467fe4 Mon Sep 17 00:00:00 2001 From: Hankai Zhang Date: Sat, 10 Jun 2023 17:49:36 -0400 Subject: [PATCH] Colorize panic and program crash message --- kernel/src/interrupt.rs | 3 ++- kernel/src/main.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/src/interrupt.rs b/kernel/src/interrupt.rs index 8c5f73f..49858e4 100644 --- a/kernel/src/interrupt.rs +++ b/kernel/src/interrupt.rs @@ -251,6 +251,7 @@ fn cpu_exception_common(frame: &InterruptStackFrame, id: u64, errcode: Option ! { if let Some(mut locked_term) = TERMINAL.as_inner().try_lock() { // The terminal may not yet be initialized. if let Some(ref mut term) = &mut *locked_term { - let _ = core::fmt::write(term, format_args!("{}", panic_info)); + let _ = core::fmt::write(term, format_args!("\x1B[1;31m{}\x1B[m", panic_info)); } }