create MiniDump on crash in Debug builds
This commit is contained in:
parent
59a57ed7a5
commit
76dd7ae674
4 changed files with 36 additions and 3 deletions
32
src/debug.c
32
src/debug.c
|
@ -1,4 +1,5 @@
|
|||
#include <windows.h>
|
||||
#include <dbghelp.h>>
|
||||
#include <stdio.h>
|
||||
#include "dd.h"
|
||||
#include "ddraw.h"
|
||||
|
@ -12,6 +13,37 @@ DWORD g_dbg_frame_count = 0;
|
|||
static LONGLONG g_dbg_counter_start_time = 0;
|
||||
static double g_dbg_counter_freq = 0.0;
|
||||
|
||||
#if _DEBUG
|
||||
int dbg_exception_handler(EXCEPTION_POINTERS* exception)
|
||||
{
|
||||
HANDLE dmp =
|
||||
CreateFile(
|
||||
"cnc-ddraw.dmp",
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE | FILE_SHARE_READ,
|
||||
0,
|
||||
CREATE_ALWAYS,
|
||||
0,
|
||||
0);
|
||||
|
||||
MINIDUMP_EXCEPTION_INFORMATION info;
|
||||
info.ThreadId = GetCurrentThreadId();
|
||||
info.ExceptionPointers = exception;
|
||||
info.ClientPointers = TRUE;
|
||||
|
||||
MiniDumpWriteDump(
|
||||
GetCurrentProcess(),
|
||||
GetCurrentProcessId(),
|
||||
dmp,
|
||||
0,
|
||||
&info,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
#endif
|
||||
|
||||
void dbg_init()
|
||||
{
|
||||
static int stdout_open = 0;
|
||||
|
|
|
@ -32,6 +32,7 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
|||
#if _DEBUG
|
||||
dbg_init();
|
||||
dprintf("cnc-ddraw = %p\n", hDll);
|
||||
SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)dbg_exception_handler);
|
||||
#endif
|
||||
g_ddraw_module = hDll;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue