Kernel: Move dump_stacktrace() to arch folder

It uses mov instruction which has different register on x86/x86-64
This commit is contained in:
Bananymous 2023-01-21 22:16:31 +02:00
parent 9e092c80c0
commit bb051604a1
3 changed files with 27 additions and 17 deletions

View File

@ -0,0 +1,24 @@
#include <kernel/Panic.h>
namespace Kernel
{
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, " {}", (void*)frame->eip);
frame = frame->ebp;
}
}
}

View File

@ -10,4 +10,6 @@ $(ARCHDIR)/CPUID.o \
$(ARCHDIR)/GDT.o \
$(ARCHDIR)/IDT.o \
$(ARCHDIR)/MMU.o \
$(ARCHDIR)/Panic.o \
$(ARCHDIR)/VESA.o \

View File

@ -9,23 +9,7 @@
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;
}
}
void dump_stacktrace();
template<typename... Args>
__attribute__((__noreturn__))