1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

Kernel+LibC: Clean up how assertions work in the kernel and LibC

This also brings LibC's abort() function closer to the spec.
This commit is contained in:
Gunnar Beutner 2021-04-18 08:43:10 +02:00 committed by Andreas Kling
parent 33a9b2a3c3
commit f033416893
13 changed files with 36 additions and 73 deletions

View file

@ -33,6 +33,7 @@
#include <Kernel/Arch/x86/ISRStubs.h>
#include <Kernel/Arch/x86/ProcessorInfo.h>
#include <Kernel/Arch/x86/SafeMem.h>
#include <Kernel/Assertions.h>
#include <Kernel/Debug.h>
#include <Kernel/IO.h>
#include <Kernel/Interrupts/APIC.h>
@ -2419,6 +2420,13 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
dmesgln("ASSERTION FAILED: {}", msg);
dmesgln("{}:{} in {}", file, line, func);
abort();
}
#endif
[[noreturn]] void abort()
{
#ifdef DEBUG
// Switch back to the current process's page tables if there are any.
// Otherwise stack walking will be a disaster.
auto process = Process::current();
@ -2427,9 +2435,17 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
Kernel::dump_backtrace();
Processor::halt();
}
#endif
abort();
}
[[noreturn]] void _abort()
{
asm volatile("ud2");
__builtin_unreachable();
}
NonMaskableInterruptDisabler::NonMaskableInterruptDisabler()
{
IO::out8(0x70, IO::in8(0x70) | 0x80);