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