forked from Bananymous/banan-os
Kernel: Debug stacktrace now detects if it kernel panics itself
This commit is contained in:
parent
cb3b62d665
commit
be502ae616
|
@ -9,16 +9,29 @@ namespace Debug
|
||||||
{
|
{
|
||||||
struct stackframe
|
struct stackframe
|
||||||
{
|
{
|
||||||
stackframe* ebp;
|
stackframe* rbp;
|
||||||
uintptr_t eip;
|
uintptr_t rip;
|
||||||
};
|
};
|
||||||
|
|
||||||
stackframe* frame = (stackframe*)__builtin_frame_address(0);
|
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");
|
BAN::Formatter::print(Debug::putchar, "\e[36mStack trace:\r\n");
|
||||||
while (frame)
|
while (frame)
|
||||||
{
|
{
|
||||||
BAN::Formatter::print(Debug::putchar, " {}\r\n", (void*)frame->eip);
|
BAN::Formatter::print(Debug::putchar, " {}\r\n", (void*)frame->rip);
|
||||||
frame = frame->ebp;
|
frame = frame->rbp;
|
||||||
|
|
||||||
|
if (frame && frame->rip == first_rip)
|
||||||
|
{
|
||||||
|
derrorln("looping kernel panic :(");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue