Kernel: Debug stacktrace now detects if it kernel panics itself

This commit is contained in:
Bananymous 2023-01-30 18:56:57 +02:00
parent cb3b62d665
commit be502ae616
1 changed files with 17 additions and 4 deletions

View File

@ -9,16 +9,29 @@ namespace Debug
{
struct stackframe
{
stackframe* ebp;
uintptr_t eip;
stackframe* rbp;
uintptr_t rip;
};
stackframe* frame = (stackframe*)__builtin_frame_address(0);
if (!frame)
{
dprintln("Could not get frame address");
return;
}
uintptr_t first_rip = frame->rip;
BAN::Formatter::print(Debug::putchar, "\e[36mStack trace:\r\n");
while (frame)
{
BAN::Formatter::print(Debug::putchar, " {}\r\n", (void*)frame->eip);
frame = frame->ebp;
BAN::Formatter::print(Debug::putchar, " {}\r\n", (void*)frame->rip);
frame = frame->rbp;
if (frame && frame->rip == first_rip)
{
derrorln("looping kernel panic :(");
return;
}
}
}