Add better crash dump output for windows

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-07-28 12:51:04 +02:00
parent 69a567b90e
commit 0137a8c193
2 changed files with 30 additions and 2 deletions

View File

@@ -39,8 +39,10 @@ inline LPTSTR ErrorMessage(DWORD dw)
// Declare the static variables of the WheatyExceptionReport class
//
TCHAR WheatyExceptionReport::m_szLogFileName[MAX_PATH];
TCHAR WheatyExceptionReport::m_szDumpFileName[MAX_PATH];
LPTOP_LEVEL_EXCEPTION_FILTER WheatyExceptionReport::m_previousFilter;
HANDLE WheatyExceptionReport::m_hReportFile;
HANDLE WheatyExceptionReport::m_hDumpFile;
HANDLE WheatyExceptionReport::m_hProcess;
// Declare global instance of class
@@ -88,8 +90,19 @@ PEXCEPTION_POINTERS pExceptionInfo)
SYSTEMTIME systime;
GetLocalTime(&systime);
sprintf(m_szLogFileName, "%s\\%s_[%u-%u_%u-%u-%u].txt",
crash_folder_path, pos, systime.wDay, systime.wMonth, systime.wHour, systime.wMinute, systime.wSecond);
sprintf(m_szDumpFileName, "%s\\%s_%s_[%u-%u_%u-%u-%u].dmp",
crash_folder_path, _REVISION, pos, systime.wDay, systime.wMonth, systime.wHour, systime.wMinute, systime.wSecond);
sprintf(m_szLogFileName, "%s\\%s_%s_[%u-%u_%u-%u-%u].txt",
crash_folder_path, _REVISION, pos, systime.wDay, systime.wMonth, systime.wHour, systime.wMinute, systime.wSecond);
m_hDumpFile = CreateFile(m_szDumpFileName,
GENERIC_WRITE,
0,
0,
OPEN_ALWAYS,
FILE_FLAG_WRITE_THROUGH,
0);
m_hReportFile = CreateFile(m_szLogFileName,
GENERIC_WRITE,
@@ -99,6 +112,19 @@ PEXCEPTION_POINTERS pExceptionInfo)
FILE_FLAG_WRITE_THROUGH,
0);
if (m_hDumpFile)
{
MINIDUMP_EXCEPTION_INFORMATION info;
info.ClientPointers = FALSE;
info.ExceptionPointers = pExceptionInfo;
info.ThreadId = GetCurrentThreadId();
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
m_hDumpFile, MiniDumpWithIndirectlyReferencedMemory, &info, 0, 0);
CloseHandle(m_hDumpFile);
}
if (m_hReportFile)
{
SetFilePointer(m_hReportFile, 0, 0, FILE_END);

View File

@@ -108,8 +108,10 @@ class WheatyExceptionReport
// Variables used by the class
static TCHAR m_szLogFileName[MAX_PATH];
static TCHAR m_szDumpFileName[MAX_PATH];
static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter;
static HANDLE m_hReportFile;
static HANDLE m_hDumpFile;
static HANDLE m_hProcess;
};