Daniele Bartolini 10 месяцев назад
Родитель
Сommit
5c75c05f75
3 измененных файлов с 60 добавлено и 1 удалено
  1. 34 0
      src/core/debug/debug.cpp
  2. 24 0
      src/core/debug/debug.h
  3. 2 1
      src/core/error/error.cpp

+ 34 - 0
src/core/debug/debug.cpp

@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012-2025 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "core/debug/debug.h"
+#if CROWN_PLATFORM_EMSCRIPTEN
+#   include <emscripten/emscripten.h>
+#elif CROWN_PLATFORM_LINUX
+#   include <signal.h>
+#endif
+
+namespace crown
+{
+namespace debug
+{
+	void breakpoint()
+	{
+#if CROWN_COMPILER_MSVC
+		__debugbreak();
+#elif CROWN_PLATFORM_EMSCRIPTEN
+		emscripten_debugger();
+#elif CROWN_PLATFORM_LINUX
+		raise(SIGTRAP);
+#elif CROWN_COMPILER_GCC || CROWN_COMPILER_CLANG
+		__builtin_trap();
+#else
+#   error "Unavailable"
+#endif
+	}
+
+} // namespace debug
+
+} // namespace crown

+ 24 - 0
src/core/debug/debug.h

@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2012-2025 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#pragma once
+
+#include "core/types.h"
+
+/// @defgroup Debug Debug
+/// @ingroup Core
+namespace crown
+{
+/// Debug utils.
+///
+/// @ingroup Debug
+namespace debug
+{
+	///
+	void breakpoint();
+
+} // namespace debug
+
+} // namespace crown

+ 2 - 1
src/core/error/error.cpp

@@ -4,6 +4,7 @@
  */
 
 #include "core/debug/callstack.h"
+#include "core/debug/debug.h"
 #include "core/error/error.h"
 #include "core/memory/temp_allocator.inl"
 #include "core/strings/string_stream.inl"
@@ -25,7 +26,7 @@ namespace error
 		loge(ERROR, buf);
 		loge(ERROR, "Stacktrace:");
 		debug::callstack(ERROR, LogSeverity::LOG_ERROR);
-		exit(EXIT_FAILURE);
+		debug::breakpoint();
 	}
 
 	void abort(const char *format, ...)