From 522e6534bf9566c277a93ccfba1fd2a2c30485f8 Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Wed, 1 Nov 2023 16:41:03 +0100 Subject: [PATCH] Added _debugBreak() macro. --- source/mijin/util/os.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/mijin/util/os.hpp b/source/mijin/util/os.hpp index e99db35..9104b0f 100644 --- a/source/mijin/util/os.hpp +++ b/source/mijin/util/os.hpp @@ -4,8 +4,10 @@ #if !defined(MIJIN_UTIL_OS_HPP_INCLUDED) #define MIJIN_UTIL_OS_HPP_INCLUDED 1 +#include #include #include +#include "../detect.hpp" namespace mijin { @@ -42,4 +44,16 @@ void setCurrentThreadName(const char* threadName) noexcept; } // namespace mijin +#if MIJIN_TARGET_OS == MIJIN_OS_LINUX || MIJIN_TARGET_OS == MIJIN_OS_OSX +#if !defined(SIGTRAP) +static constexpr int SIGTRAP = 5; +#endif +#define _debugBreak() (void) std::raise(SIGTRAP) +#elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS +extern "C" __declspec(dllimport) void __stdcall DebugBreak(); +#define _debugBreak() DebugBreak() +#else +#define _debugBreak() ((void)0) +#endif + #endif // !defined(MIJIN_UTIL_OS_HPP_INCLUDED)