2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2021-02-17 15:39:32 +01:00
|
|
|
#include <AK/Format.h>
|
2018-10-31 21:31:56 +01:00
|
|
|
#include <assert.h>
|
|
|
|
|
#include <stdio.h>
|
2019-06-07 11:49:03 +02:00
|
|
|
#include <stdlib.h>
|
2020-12-30 15:21:31 +01:00
|
|
|
#include <string.h>
|
2020-10-10 17:47:21 +03:00
|
|
|
#include <sys/internals.h>
|
2021-02-05 12:16:30 +01:00
|
|
|
#include <syscall.h>
|
2019-01-16 12:57:07 +01:00
|
|
|
#include <unistd.h>
|
2018-10-28 09:36:21 +01:00
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
2020-10-10 17:47:21 +03:00
|
|
|
extern bool __stdio_is_initialized;
|
2021-07-12 01:15:22 -06:00
|
|
|
#ifndef NDEBUG
|
2020-04-13 11:20:43 +02:00
|
|
|
void __assertion_failed(const char* msg)
|
2018-10-28 09:36:21 +01:00
|
|
|
{
|
2021-09-17 18:13:50 +02:00
|
|
|
if (__heap_is_stable) {
|
|
|
|
|
dbgln("ASSERTION FAILED: {}", msg);
|
|
|
|
|
if (__stdio_is_initialized)
|
|
|
|
|
warnln("ASSERTION FAILED: {}", msg);
|
|
|
|
|
}
|
2020-12-30 15:21:31 +01:00
|
|
|
|
|
|
|
|
Syscall::SC_set_coredump_metadata_params params {
|
|
|
|
|
{ "assertion", strlen("assertion") },
|
|
|
|
|
{ msg, strlen(msg) },
|
|
|
|
|
};
|
|
|
|
|
syscall(SC_set_coredump_metadata, ¶ms);
|
2021-04-18 08:43:10 +02:00
|
|
|
abort();
|
2018-10-28 09:36:21 +01:00
|
|
|
}
|
2019-04-23 21:52:02 +02:00
|
|
|
#endif
|
2018-10-28 09:36:21 +01:00
|
|
|
}
|
2021-04-11 18:22:48 +02:00
|
|
|
|
2021-04-18 08:43:10 +02:00
|
|
|
void _abort()
|
2021-04-11 18:22:48 +02:00
|
|
|
{
|
|
|
|
|
asm volatile("ud2");
|
|
|
|
|
__builtin_unreachable();
|
|
|
|
|
}
|