Use inline assembly for MIJIN_TRAP() so the debugger stops at the exact location. Only works for x64, but that's currently my only target.
This commit is contained in:
parent
0e877f4769
commit
b89f19ed98
@ -14,14 +14,24 @@ extern "C" __declspec(dllimport) void __stdcall DebugBreak();
|
|||||||
#define MIJIN_TRAP() DebugBreak()
|
#define MIJIN_TRAP() DebugBreak()
|
||||||
#define MIJIN_FUNC() __FUNCSIG__
|
#define MIJIN_FUNC() __FUNCSIG__
|
||||||
#else // _WIN32
|
#else // _WIN32
|
||||||
#include <csignal>
|
#include <unistd.h>
|
||||||
#define MIJIN_TRAP() (void) std::raise(SIGTRAP)
|
#define MIJIN_TRAP() \
|
||||||
|
{ \
|
||||||
|
const pid_t tid = gettid(); \
|
||||||
|
const pid_t pid = getpid(); \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"syscall" \
|
||||||
|
: \
|
||||||
|
: "D"(pid), "S"(tid), "d"(5), "a"(0xea) \
|
||||||
|
: "rcx", "r11", "memory" \
|
||||||
|
); \
|
||||||
|
}
|
||||||
#define MIJIN_FUNC() "" // TODO: __PRETTY_FUNCTION__ is not working for some reason -.-
|
#define MIJIN_FUNC() "" // TODO: __PRETTY_FUNCTION__ is not working for some reason -.-
|
||||||
#endif // !_WIN32
|
#endif // !_WIN32
|
||||||
|
|
||||||
namespace mijin
|
namespace mijin
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
//
|
||||||
// public defines
|
// public defines
|
||||||
//
|
//
|
||||||
@ -35,7 +45,7 @@ switch (mijin::handleError(msg, source_loc)) \
|
|||||||
break; \
|
break; \
|
||||||
case mijin::ErrorHandling::TRAP: \
|
case mijin::ErrorHandling::TRAP: \
|
||||||
MIJIN_TRAP(); \
|
MIJIN_TRAP(); \
|
||||||
[[fallthrough]]; \
|
break; \
|
||||||
default: /* ABORT */ \
|
default: /* ABORT */ \
|
||||||
std::abort(); \
|
std::abort(); \
|
||||||
}
|
}
|
||||||
@ -76,7 +86,7 @@ if (!static_cast<bool>(condition))
|
|||||||
#define MIJIN_ASSERT_FATAL(condition, msg) \
|
#define MIJIN_ASSERT_FATAL(condition, msg) \
|
||||||
if (!static_cast<bool>(condition)) \
|
if (!static_cast<bool>(condition)) \
|
||||||
{ \
|
{ \
|
||||||
MIJIN_ERROR("Debug assertion failed: " #condition "\nMessage: " msg); \
|
MIJIN_FATAL("Debug assertion failed: " #condition "\nMessage: " msg); \
|
||||||
}
|
}
|
||||||
#else // MIJIN_DEBUG
|
#else // MIJIN_DEBUG
|
||||||
#define MIJIN_ERROR(...)
|
#define MIJIN_ERROR(...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user