From: Bart House Date: Sat, 13 Jul 2019 23:00:14 +0000 (-0700) Subject: Add stopping in the debugger when nhassert() is hit in the windows port. X-Git-Tag: v3.6.3.757eca7~136 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d2872dd4f24fb76f29bf34f6f950394910d6d33;p=nethack Add stopping in the debugger when nhassert() is hit in the windows port. When stopping in the debugger after having called impossible, the windowing state will have been modified since the assertion was hit. This made examining state that caused the nhassert to fire no longer possible. To avoid this issue, we now detect the debugger and stop in the debugger prior to impossible. --- diff --git a/sys/winnt/winnt.c b/sys/winnt/winnt.c index 8d513c59e..39978cab4 100644 --- a/sys/winnt/winnt.c +++ b/sys/winnt/winnt.c @@ -718,9 +718,19 @@ nt_assert_failed(expression, filepath, line) { const char * filename; - /* get file name from path */ filename = strrchr(filepath, '\\'); filename = (filename == NULL ? filepath : filename + 1); + + if (IsDebuggerPresent()) { + char message[BUFSIZ]; + snprintf(message, sizeof(message), + "nhassert(%s) failed in file '%s' at line %d", + expression, filename, line); + OutputDebugStringA(message); + DebugBreak(); + } + + /* get file name from path */ impossible("nhassert(%s) failed in file '%s' at line %d", expression, filename, line); }