1
0
Fork 0

(svn r17410) -Codechange: use the same define for determining whether windows does crash reports instead of using several that aren't necessarily equal

release/1.0
rubidium 2009-09-03 22:32:08 +00:00
parent b92143b53e
commit c9a1f33418
3 changed files with 25 additions and 34 deletions

View File

@ -9,11 +9,21 @@
/** @file crashlog_win.cpp Implementation of a crashlogger for Windows */ /** @file crashlog_win.cpp Implementation of a crashlogger for Windows */
#include "../../stdafx.h" #if defined(WIN32_EXCEPTION_TRACKER)
#include <windows.h>
#include "win32.h" #include "../../stdafx.h"
#include "win32.h"
#include "../../core/alloc_func.hpp"
#include "../../string_func.h"
#include "../../gamelog.h"
#include "../../saveload/saveload.h"
#include "../../fileio_func.h"
#include "../../rev.h"
#include "../../strings_func.h"
#include <windows.h>
#include <dbghelp.h>
#ifdef _MSC_VER
static const char *_exception_string = NULL; static const char *_exception_string = NULL;
void SetExceptionString(const char *s, ...) void SetExceptionString(const char *s, ...)
{ {
@ -26,18 +36,6 @@ void SetExceptionString(const char *s, ...)
_exception_string = strdup(buf); _exception_string = strdup(buf);
} }
#endif
#if defined(_MSC_VER) && !defined(WINCE)
#include "../../core/alloc_func.hpp"
#include "../../string_func.h"
#include "../../gamelog.h"
#include "../../saveload/saveload.h"
#include "../../fileio_func.h"
#include "../../rev.h"
#include <dbghelp.h>
#include "../../strings_func.h"
static void *_safe_esp; static void *_safe_esp;
static char *_crash_msg; static char *_crash_msg;
@ -497,4 +495,4 @@ void Win32InitializeExceptions()
SetUnhandledExceptionFilter(ExceptionHandler); SetUnhandledExceptionFilter(ExceptionHandler);
} }
#endif /* _MSC_VER */ #endif /* WIN32_EXCEPTION_TRACKER */

View File

@ -73,8 +73,8 @@ void ShowOSErrorBox(const char *buf, bool system)
MyShowCursor(true); MyShowCursor(true);
MessageBox(GetActiveWindow(), MB_TO_WIDE(buf), _T("Error!"), MB_ICONSTOP); MessageBox(GetActiveWindow(), MB_TO_WIDE(buf), _T("Error!"), MB_ICONSTOP);
/* if exception tracker is enabled, we crash here to let the exception handler handle it. */ /* If exception tracker is enabled, we crash here to let the exception handler handle it. */
#if defined(WIN32_EXCEPTION_TRACKER) && !defined(_DEBUG) #if defined(WIN32_EXCEPTION_TRACKER) && defined(NDEBUG)
if (system) { if (system) {
SetExceptionString("%s", buf); SetExceptionString("%s", buf);
*(byte*)0 = 0; *(byte*)0 = 0;
@ -383,20 +383,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
argc = ParseCommandLine(cmdline, argv, lengthof(argv)); argc = ParseCommandLine(cmdline, argv, lengthof(argv));
#if defined(WIN32_EXCEPTION_TRACKER) #if defined(WIN32_EXCEPTION_TRACKER)
extern void Win32InitializeExceptions(); void Win32InitializeExceptions();
Win32InitializeExceptions(); Win32InitializeExceptions();
#endif #endif
#if defined(WIN32_EXCEPTION_TRACKER_DEBUG) ttd_main(argc, argv);
_try {
LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep);
#endif
ttd_main(argc, argv);
#if defined(WIN32_EXCEPTION_TRACKER_DEBUG)
} _except (ExceptionHandler(_exception_info())) {}
#endif
return 0; return 0;
} }

View File

@ -229,11 +229,13 @@
#define strncasecmp strnicmp #define strncasecmp strnicmp
#endif #endif
void SetExceptionString(const char *s, ...) WARN_FORMAT(1, 2);
#if defined(NDEBUG) && defined(WITH_ASSERT) #if defined(WIN32_EXCEPTION_TRACKER)
#undef assert void SetExceptionString(const char *s, ...) WARN_FORMAT(1, 2);
#define assert(expression) if (!(expression)) { SetExceptionString("Assertion failed at %s:%d: %s", __FILE__, __LINE__, #expression); *(byte*)0 = 0; } #if defined(NDEBUG) && defined(WITH_ASSERT)
#undef assert
#define assert(expression) if (!(expression)) { SetExceptionString("Assertion failed at %s:%d: %s", __FILE__, __LINE__, #expression); *(byte*)0 = 0; }
#endif
#endif #endif
/* MSVC doesn't have these :( */ /* MSVC doesn't have these :( */