From 943feead3da4439db921f310ed0994f8c9fbf0f7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Mar 2023 17:29:53 +0100 Subject: main: add debug break function --- main/debug-break.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 main/debug-break.cpp (limited to 'main/debug-break.cpp') 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 +#else +#include +#include +#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 +} -- cgit v1.2.3