assert.cpp 748 B

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