Kernel: Show QR code with panic logs on kernel panic

This makes debugging on real hardware easier!
This commit is contained in:
2025-10-27 17:27:24 +02:00
parent f519cb2cc0
commit 5f61581e1d
4 changed files with 235 additions and 8 deletions

View File

@@ -74,6 +74,8 @@
namespace Debug
{
void dump_stack_trace();
void dump_qr_code();
void putchar(char);
void print_prefix(const char*, int);

View File

@@ -19,15 +19,26 @@ namespace Kernel
asm volatile("cli");
const bool had_debug_lock = Debug::s_debug_lock.current_processor_has_lock();
derrorln("Kernel panic at {}", location);
if (had_debug_lock)
derrorln(" while having debug lock...");
derrorln(message, BAN::forward<Args>(args)...);
if (!g_paniced)
bool first_panic = false;
{
g_paniced = true;
Debug::dump_stack_trace();
SpinLockGuard _(Debug::s_debug_lock);
derrorln("Kernel panic at {}", location);
if (had_debug_lock)
derrorln(" while having debug lock...");
derrorln(message, BAN::forward<Args>(args)...);
if (!g_paniced)
{
Debug::dump_stack_trace();
g_paniced = true;
first_panic = true;
}
}
if (first_panic)
Debug::dump_qr_code();
asm volatile("ud2");
__builtin_unreachable();
}