From 2ce7205c80058bea79989a115a069d859c91723c Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 25 Aug 2024 15:02:15 +0300 Subject: [PATCH] Kernel: Add command line option to disable debug printing The whole system can crash when debug output and tty output are done at the same time. This patch is just a hack to prevent the crash :D --- kernel/kernel/Debug.cpp | 4 ++++ kernel/kernel/kernel.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/kernel/kernel/Debug.cpp b/kernel/kernel/Debug.cpp index 08a3640e1c..48bf8c3fed 100644 --- a/kernel/kernel/Debug.cpp +++ b/kernel/kernel/Debug.cpp @@ -8,6 +8,7 @@ #include +bool g_disable_debug = false; extern Kernel::TerminalDriver* g_terminal_driver; namespace Debug @@ -70,6 +71,9 @@ namespace Debug { using namespace Kernel; + if (g_disable_debug) + return; + if (Kernel::Serial::has_devices()) return Kernel::Serial::putchar_any(ch); if (Kernel::TTY::is_initialized()) diff --git a/kernel/kernel/kernel.cpp b/kernel/kernel/kernel.cpp index 124334d38d..178e10b281 100644 --- a/kernel/kernel/kernel.cpp +++ b/kernel/kernel/kernel.cpp @@ -65,6 +65,7 @@ static bool should_disable_serial(BAN::StringView full_command_line) return false; } +extern bool g_disable_debug; static ParsedCommandLine cmdline; static void parse_command_line() @@ -81,6 +82,8 @@ static void parse_command_line() cmdline.disable_smp = true; else if (argument == "nousb") cmdline.disable_usb = true; + else if (argument == "nodebug") + g_disable_debug = true; else if (argument.starts_with("ps2=")) { if (argument.size() != 5 || !isdigit(argument[4]))