Skip to content

Commit 8804977

Browse files
committed
Report crash messages on Windows to the CRT
Provide a Windows implementation of the _dispatch_set_crash_log_* macros which pass the crash message to the CRT using _RPTF0. If libdispatch is linked against a debug version of msvcrt, this will display a dialog with detailed information about the crash and provide an option to attach a debugger. On release versions of msvcrt, this reporting is a no-op.
1 parent 44f67b2 commit 8804977

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/internal.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
293293
#endif
294294
#if defined(_WIN32)
295295
#include <io.h>
296+
#include <crtdbg.h>
296297
#endif
297298

298299
#if defined(__GNUC__) || defined(__clang__)
@@ -876,9 +877,19 @@ _dispatch_ktrace_impl(uint32_t code, uint64_t a, uint64_t b,
876877
#define _dispatch_hardware_crash() \
877878
__asm__(""); __builtin_trap() // <rdar://problem/17464981>
878879

880+
#ifdef _WIN32
881+
#define _dispatch_set_crash_log_cause_and_message(ac, msg) do { \
882+
(void)(ac); \
883+
_dispatch_set_crash_log_message_dynamic((msg)); \
884+
} while (0)
885+
#define _dispatch_set_crash_log_message(msg) \
886+
_dispatch_set_crash_log_message_dynamic((msg))
887+
#define _dispatch_set_crash_log_message_dynamic(msg) _RPTF0(_CRT_ASSERT, (msg))
888+
#else
879889
#define _dispatch_set_crash_log_cause_and_message(ac, msg) ((void)(ac))
880890
#define _dispatch_set_crash_log_message(msg)
881891
#define _dispatch_set_crash_log_message_dynamic(msg)
892+
#endif
882893

883894
#if HAVE_MACH
884895
// MIG_REPLY_MISMATCH means either:

0 commit comments

Comments
 (0)