summaryrefslogtreecommitdiffhomepage
path: root/main/debug-break.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-03 17:29:53 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-03 20:34:02 +0100
commit943feead3da4439db921f310ed0994f8c9fbf0f7 (patch)
tree8124337ee7f4b15f453ea1a0f7abd26bdfd4be99 /main/debug-break.cpp
parentf947c96ba400784090aa36c5bde469c92843083d (diff)
main: add debug break function
Diffstat (limited to 'main/debug-break.cpp')
-rw-r--r--main/debug-break.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/main/debug-break.cpp b/main/debug-break.cpp
new file mode 100644
index 00000000..218dbe41
--- /dev/null
+++ b/main/debug-break.cpp
@@ -0,0 +1,18 @@
+#include "floormat/main.hpp"
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <sys/ptrace.h>
+#include <signal.h>
+#endif
+
+void floormat::floormat_main::debug_break()
+{
+#ifdef _WIN32
+ if (IsDebuggerPresent()) [[unlikely]]
+ DebugBreak();
+#else
+ if (ptrace(PTRACE_TRACEME, 0, 1, 0) == -1)
+ ::raise(SIGUSR1);
+#endif
+}