Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <AK/Format.h>
8#include <Kernel/API/prctl_numbers.h>
9#include <assert.h>
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <sys/internals.h>
14#include <syscall.h>
15#include <unistd.h>
16
17extern "C" {
18
19extern bool __stdio_is_initialized;
20
21void __assertion_failed(char const* msg)
22{
23 if (__heap_is_stable) {
24 dbgln("ASSERTION FAILED: {}", msg);
25 if (__stdio_is_initialized)
26 warnln("ASSERTION FAILED: {}", msg);
27 }
28
29 Syscall::SC_set_coredump_metadata_params params {
30 { "assertion", strlen("assertion") },
31 { msg, strlen(msg) },
32 };
33 syscall(SC_prctl, PR_SET_COREDUMP_METADATA_VALUE, ¶ms, nullptr);
34 abort();
35}
36}