Debug messages

This commit is contained in:
Alex
2023-03-03 16:14:13 +02:00
parent aeb175f03b
commit 207eb77160
2 changed files with 15 additions and 6 deletions

View File

@ -42,12 +42,19 @@ EXTERNC __attribute__((weak, noreturn, no_stack_protector)) void __stack_chk_fai
error("Stack smashing detected!");
debug("Current stack check guard value: %#lx", __stack_chk_guard);
KPrint("\eFF0000Stack smashing detected!");
#if defined(__amd64__) || defined(__i386__)
void *Stack = nullptr;
asmv("movq %%rsp, %0"
: "=r"(Stack));
error("Stack address: %#lx", Stack);
while (1)
asmv("cli; hlt");
#elif defined(__aarch64__)
asmv("wfe");
#endif
CPU::Stop();
}
// https://github.com/gcc-mirror/gcc/blob/master/libssp/ssp.c
@ -57,6 +64,7 @@ EXTERNC __attribute__((weak, noreturn, no_stack_protector)) void __chk_fail(void
for (short i = 0; i < 10; i++)
error("Buffer overflow detected!");
KPrint("\eFF0000Buffer overflow detected!");
#if defined(__amd64__) || defined(__i386__)
while (1)
asmv("cli; hlt");