Kernel: Kernel::Panic now dumps stacktrace to com1
This commit is contained in:
parent
7540fa0385
commit
b9a4530e54
|
@ -117,6 +117,7 @@ _start:
|
|||
call _init
|
||||
|
||||
# call to the kernel itself
|
||||
xorl %ebp, %ebp
|
||||
call kernel_main
|
||||
|
||||
system_halt:
|
||||
|
|
|
@ -9,12 +9,31 @@
|
|||
namespace Kernel
|
||||
{
|
||||
|
||||
static void dump_stacktrace()
|
||||
{
|
||||
struct stackframe
|
||||
{
|
||||
stackframe* ebp;
|
||||
uint32_t eip;
|
||||
};
|
||||
|
||||
stackframe* frame;
|
||||
asm volatile("movl %%ebp, %0" : "=r"(frame));
|
||||
BAN::Formatter::println(Serial::serial_putc, "\e[36mStack trace:");
|
||||
while (frame)
|
||||
{
|
||||
BAN::Formatter::println(Serial::serial_putc, " 0x{8H}", frame->eip);
|
||||
frame = frame->ebp;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
__attribute__((__noreturn__))
|
||||
static void PanicImpl(const char* file, int line, const char* message, Args... args)
|
||||
{
|
||||
derrorln("Kernel panic at {}:{}", file, line);
|
||||
derrorln(message, args...);
|
||||
dump_stacktrace();
|
||||
if (TTY::IsInitialized())
|
||||
{
|
||||
kprint("\e[31mKernel panic at {}:{}\n", file, line);
|
||||
|
|
Loading…
Reference in New Issue