diff --git a/core/panic/handler.cpp b/core/panic/handler.cpp index 140cf4e..b77e485 100644 --- a/core/panic/handler.cpp +++ b/core/panic/handler.cpp @@ -39,10 +39,11 @@ #include "../../kernel.h" extern const char *x86ExceptionMnemonics[]; -extern void DisplayCrashScreen(CPU::ExceptionFrame *Frame); -extern bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame); +extern void DisplayCrashScreen(CPU::ExceptionFrame *); +extern bool UserModeExceptionHandler(CPU::ExceptionFrame *); extern void DisplayStackSmashing(); extern void DisplayBufferOverflow(); +extern void DisplayAssertionFailed(const char *, int, const char *); Video::Font *CrashFont = nullptr; void *FbBeforePanic = nullptr; @@ -350,3 +351,10 @@ nsa __noreturn void HandleBufferOverflow() DisplayBufferOverflow(); CPU::Stop(); } + +EXTERNC nsa __noreturn void HandleAssertionFailed(const char *File, int Line, + const char *Expression) +{ + DisplayAssertionFailed(File, Line, Expression); + CPU::Stop(); +} diff --git a/core/panic/ui.cpp b/core/panic/ui.cpp index f6ad691..94fe1ef 100644 --- a/core/panic/ui.cpp +++ b/core/panic/ui.cpp @@ -742,8 +742,7 @@ nsa void DisplayBufferOverflow() /* TODO: Add additional info */ } -EXTERNC nsa __noreturn void DisplayAssertionFailed(const char *File, int Line, - const char *Expression) +nsa void DisplayAssertionFailed(const char *File, int Line, const char *Expression) { InitFont(); Display->ClearBuffer(); @@ -768,7 +767,8 @@ EXTERNC nsa __noreturn void DisplayAssertionFailed(const char *File, int Line, ExPrint(" Please create a new issue on \e00AAFFhttps://github.com/Fennix-Project/Fennix\eFAFAFA for further assistance.\n"); Display->UpdateBuffer(); - CPU::Stop(); + + /* TODO: Add additional info */ } nsa void ArrowInput(uint8_t key) diff --git a/include_std/assert.h b/include_std/assert.h index 619dd49..c385630 100644 --- a/include_std/assert.h +++ b/include_std/assert.h @@ -20,18 +20,18 @@ #include -EXTERNC void __attribute__((noreturn)) DisplayAssertionFailed(const char *File, int Line, - const char *Expression); +EXTERNC void __attribute__((noreturn)) HandleAssertionFailed(const char *File, int Line, + const char *Expression); -#define assert(x) \ - do \ - { \ - if (__builtin_expect(!!(!(x)), 0)) \ - { \ - error("Assertion failed! [%s]", #x); \ - DisplayAssertionFailed(__FILE__, __LINE__, #x); \ - __builtin_unreachable(); \ - } \ +#define assert(x) \ + do \ + { \ + if (__builtin_expect(!!(!(x)), 0)) \ + { \ + error("Assertion failed! [%s]", #x); \ + HandleAssertionFailed(__FILE__, __LINE__, #x); \ + __builtin_unreachable(); \ + } \ } while (0) #define assert_allow_continue(x) \