From 14eda2cd17fd861f9a9d2299eef03b805c773e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Sun, 9 Oct 2022 00:16:40 +0300 Subject: [PATCH] =?UTF-8?q?mdbx-windows:=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=20=5FCrtDbg?= =?UTF-8?q?Report()=20=D0=B2=20=D0=BE=D1=82=D0=BB=D0=B0=D0=B4=D0=BE=D1=87?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B0=D1=85?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/osal.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/osal.c b/src/osal.c index 79760a12..e120490a 100644 --- a/src/osal.c +++ b/src/osal.c @@ -20,6 +20,10 @@ #include +#if !MDBX_WITHOUT_MSVC_CRT && defined(_DEBUG) +#include +#endif + static int waitstatus2errcode(DWORD result) { switch (result) { case WAIT_OBJECT_0: @@ -252,9 +256,14 @@ MDBX_NORETURN __cold void assert_fail(const char *msg, const char *func, while (1) { #if defined(_WIN32) || defined(_WIN64) +#if !MDBX_WITHOUT_MSVC_CRT && defined(_DEBUG) + _CrtDbgReport(_CRT_ASSERT, func ? func : "unknown", line, "libmdbx", + "assertion failed: %s", msg); +#else if (IsDebuggerPresent()) DebugBreak(); - FatalExit(ERROR_UNHANDLED_ERROR); +#endif + FatalExit(STATUS_ASSERTION_FAILURE); #else abort(); #endif @@ -278,10 +287,15 @@ __cold void mdbx_panic(const char *fmt, ...) { while (1) { #if defined(_WIN32) || defined(_WIN64) +#if !MDBX_WITHOUT_MSVC_CRT && defined(_DEBUG) + _CrtDbgReport(_CRT_ASSERT, "mdbx.c", 0, "libmdbx", "panic: %s", + const_message); +#else OutputDebugStringA("\r\nMDBX-PANIC: "); OutputDebugStringA(const_message); if (IsDebuggerPresent()) DebugBreak(); +#endif FatalExit(ERROR_UNHANDLED_ERROR); #else __assert_fail(const_message, "mdbx", 0, "panic");