Define ABORT() using _CrtDbgBreak (if available) on Windows host
authorIvan Maidanski <ivmai@mail.ru>
Thu, 1 Feb 2018 22:21:57 +0000 (01:21 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 1 Feb 2018 22:24:24 +0000 (01:24 +0300)
Issue #173 (bdwgc).

* include/private/gc_priv.h [!CPPCHECK && !PCR && !NO_DEBUGGING
&& (MSWIN32 || MSWINCE)] (ABORT): Use _CrtDbgBreak() instead of
DebugBreak() if _CrtDbgBreak, _DEBUG and _MSC_VER macros are defined.

include/private/gc_priv.h

index 333969f..00bd3ea 100644 (file)
@@ -563,10 +563,15 @@ typedef char * ptr_t;   /* A generic pointer to which we can add        */
 #   elif defined(MSWINCE) && defined(NO_DEBUGGING)
 #     define ABORT(msg) (GC_on_abort(msg), ExitProcess(-1))
 #   elif defined(MSWIN32) || defined(MSWINCE)
-#     define ABORT(msg) { GC_on_abort(msg); DebugBreak(); }
+#     if defined(_CrtDbgBreak) && defined(_DEBUG) && defined(_MSC_VER)
+#       define ABORT(msg) { GC_on_abort(msg); \
+                            _CrtDbgBreak() /* __debugbreak() */; }
+#     else
+#       define ABORT(msg) { GC_on_abort(msg); DebugBreak(); }
                 /* Note that: on a WinCE box, this could be silently    */
                 /* ignored (i.e., the program is not aborted);          */
                 /* DebugBreak is a statement in some toolchains.        */
+#     endif
 #   else
 #     define ABORT(msg) (GC_on_abort(msg), abort())
 #   endif /* !MSWIN32 */