summaryrefslogtreecommitdiff
path: root/src/os/windows
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2009-12-09 15:24:13 +0000
committerglx <glx@openttd.org>2009-12-09 15:24:13 +0000
commit0c577dfde60efde68b8f047043a94a59db03df35 (patch)
tree22bb1a5253266fbbba70f7d115a2c08187d3d1f2 /src/os/windows
parent7a38435a63942a2f1146083de8c5418d5e62c32e (diff)
downloadopenttd-0c577dfde60efde68b8f047043a94a59db03df35.tar.xz
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
Diffstat (limited to 'src/os/windows')
-rw-r--r--src/os/windows/crashlog_win.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp
index cf17615c9..6654eec61 100644
--- a/src/os/windows/crashlog_win.cpp
+++ b/src/os/windows/crashlog_win.cpp
@@ -20,6 +20,7 @@
#include "../../gamelog.h"
#include <windows.h>
+#include <signal.h>
/**
* Windows implementation for the crash logger.
@@ -407,6 +408,11 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
extern "C" void *_get_safe_esp();
#endif
+static void CDECL CustomAbort(int signal)
+{
+ RaiseException(0xE1212012, 0, 0, NULL);
+}
+
/* static */ void CrashLog::InitialiseCrashLog()
{
#if defined(_MSC_VER)
@@ -421,6 +427,12 @@ extern "C" void *_get_safe_esp();
asm("movl %esp, __safe_esp");
#endif
+ /* SIGABRT is not an unhandled exception, so we need to intercept it. */
+ signal(SIGABRT, CustomAbort);
+#if defined(_MSC_VER)
+ /* Don't show abort message as we will get the crashlog window anyway. */
+ _set_abort_behavior(0, _WRITE_ABORT_MSG);
+#endif
SetUnhandledExceptionFilter(ExceptionHandler);
}